[SDL] Stretch Blitting

Vincent R. forumer at smartmobili.com
Sat Apr 25 12:24:27 PDT 2009


On Sat, 25 Apr 2009 13:09:51 -0500, "michael brown" <n5qmg at earthlink.net>
wrote:
> Vincent R. wrote:
>> On Sat, 25 Apr 2009 15:05:13 +0200, "Vincent R."
>> <forumer at smartmobili.com> wrote:
>>> Hi,
>>>
>>> I wanted to evaluate SDL on windows CE and I am not convinced.
>>> Firt thing I want to do is to load a png and reduce display size, is
>>> it possible to do it ?
>>> For instance I am loading a 320x240 png and I want to display it as
>> 80x60.
>>>> From what I read there is SDL_gfx but is very slow, so is there any
>>>> other option ?
>>>
>>> Thanks
>>
>> I have found STL_Stretch and I have compiled it for wince.
>> Now I don't really understand how to use it? If someone could provide
>> a very small
>> sample code where a png(240x320) is load and displayed centered in
>> 80x60. I am trying this but with no success :
>>
>> static SDL_Surface *sprite;
>>
>> sprite = IMG_Load(file);
>> converted = SDL_DisplayFormat(sprite);
>>
>> position.x = position.y = 0;
>> position.w = 80;
>> position.h = 60;
>>
>> updates[1] = position;
>> SDL_StretchSurfaceBlit(sprite, NULL, screen, &position);
> 
> Shouldn't this be:
> SDL_StretchSurfaceBlit(converted, NULL, screen, &position);
> 
> I remember you having problems until you called SDL_DisplayFormat.  Don't

> you need to use the "converted" surface?
> 
>> SDL_Flip(screen);
>

I don't know.
Now I am using a sample code found here :
http://gpwiki.org/index.php/C:Displaying_a_Bitmap_With_SDL

I have only replaced SDL_LoadBMP("image.bmp"); by temp =
IMG_Load("test.png");
and bitmap is well displayed.
Then I tried this :

        //Construct the source rectangle for our blit
	rcSrc.x = 0;
	rcSrc.y = 0;
	rcSrc.w = image->w;	//Use image->w to display the entire width of the
image
	rcSrc.h = image->h;	//Use image->h to display the entire height of the
image
	
	//Construct the destination rectangle for our blit
	rcDest.x = 10;		
	rcDest.y = 10;
	rcDest.w = 160;	
	rcDest.h = 120;

        SDL_StretchSurfaceRect(image,  &rcSrc, screen, &rcDest);

But this time bitmap is taking entire screen while.







More information about the SDL mailing list