PocketMatrix forums

A read-only archive of the PocketMatrix forums (2001–2014). Posting and accounts are closed.

preventing scalling

How do I prevent an image scalling - I have a 500x500 image which gets scalled to the size of the window. How do I prevent this?
Use a source RECT to define the portion of your 500x500 image you want drawn to the backbuffer. Otherwise, your image will be scaled down to fit.
How would I go about this, I'm new to this & I'm still experimenting (but I'm writing a map renderer for the pocket pc for a research project I'm currently employed on).
Here's what you would basically do in the ProcessNextFrame method:

1) Determine what your current display size is and store those dimensions for later use:


Code:

POINT _ptDisplaySize = {backbuffer.GetWidth(), backbuffer.GetHeight()};


2) Next you'll need to keep track of where your 'viewport' is located at. The viewport is the visible portion of your large surface that you want to see:

Code:

POINT _ptViewportLoc = {50,50};


3) Assuming you've already created your large surface we just need to BLT the visible portion of it to the backbuffer:

Code:

RECT r = {_ptViewportLoc.x, _ptViewportLoc.y, _ptViewportLoc.x + _ptDisplaySize.x, _ptViewportLoc.y + _ptDisplaySize.y};

HRESULT hr = backbuffer.BltFast(0, 0, &_cgsLargeSurface, &r;, 0, NULL);

if(hr != GD_OK) return hr;


That's a basic way of displaying a viewport into a surface that is larger than your display. An obvious enhancement to this is to adjust RECT r so its values never go beyond the bounds of the large surface. You could define _ptViewportLoc outside of ProcessNextFrame and alter its values with the stylus or dPad to create a simple scrolling feature as well.

Hope this helps!
thanks, that's exactly what I needed.