Stretch Blitting

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

SDL itself doesn’t do this (hence SDL_gfx), but you can always role your
own. Depending on what quality you want, versus speed, there are various
ways to do it. (Skipping pixels… averaging source pixels together,
via linear, bi-cubic, etc… and so forth)

I rolled my own scaling routine in Tux Paint. For scaling up, things
were quite blocky until we implemented linear smoothing. It seems fast
enough, though I’m not targetting WinCE.On Sat, Apr 25, 2009 at 03:05:13PM +0200, Vincent R. wrote:

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 ?


-bill!
Sent from my computer

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);

SDL_Flip(screen);On Sat, 25 Apr 2009 15:05:13 +0200, “Vincent R.” <@Vincent_R> wrote:

Vincent R. 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?> On Sat, 25 Apr 2009 15:05:13 +0200, “Vincent R.” wrote:

SDL_Flip(screen);

Vincent R. 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.On Sat, 25 Apr 2009 13:09:51 -0500, “michael brown” wrote:

On Sat, 25 Apr 2009 15:05:13 +0200, “Vincent R.” <@Vincent_R> wrote: