Is it possible to resize surfaces with transarent areasintact?

you could always use opengl, opengl is set up so that you can easily resize
images when you draw them to the screen with hardware accelerated scaling (:> ----- Original Message -----

From: joakim.kolsjo@home.se (Joakim Kolsjo)
To:
Sent: Wednesday, September 01, 2004 8:02 PM
Subject: [SDL] Is it possible to resize surfaces with transarent
areasintact?

Hello, i’m writing a game where i need to resize some of my images before
using them acording to how big the map is and how big of a resolution the
user has. I’ve been unable to do so while getting the transparent areas
correct, instead i get black areas where it used to be transparent.

The following code generates this problem:
SDL_Surface *temp = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
bpp, 0, 0, 0, 0);
SDL_BlitSurface(some_image, 0, temp, 0); // The same effect as when i use
my resize code
SDL_BlitSurface(temp, 0, screen, some_dest); // When i do this the
transparent areas in the original “some_image” is black.

How do i keep the transparent information when i copy the surface? This
copy must be done on a per pixel basis so that i can use scale variables
like this:
//getPixel(src, (int)(xwscale), (int)(yhscale), r, g, b);
//setPixel(dst, x, y, r, g, b);

// I’ve attempted to include alpha like this, but it would not work
though… but is this really what im looking for anyway?
SDL_GetRGBA(((Uint32*)src->pixels)[x + ysrc->w], src->format, &r, &g, &b,
&a);
((Uint32
)dst->pixels)[x + y*dst->w] = SDL_MapRGBA(src->format, r, g, b,
a);

Thanks in advance / Jocke


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

you could always use opengl, opengl is set up so that you can easily resize
images when you draw them to the screen with hardware accelerated scaling (:

We’ll… as long as im doing nothing but drawing 2d graphics, i think i don’t want to make life hard for people that run the game on computers without 3d accelerator cards or correct drivers. Besides i really want to know things like this, i would like to know how SDL handle transparency… seems very strange to me, there is no property of the pixels that say, “hey im transparent!”, like it would if you would have all transparent ones of a color like 0xff00ff.On Wed, 1 Sep 2004 18:20:44 -0700 “Alan Wolfe” wrote:

----- Original Message -----
From: “Joakim Kolsj?” <joakim.kolsjo at home.se>
To:
Sent: Wednesday, September 01, 2004 8:02 PM
Subject: [SDL] Is it possible to resize surfaces with transarent
areasintact?

Hello, i’m writing a game where i need to resize some of my images before
using them acording to how big the map is and how big of a resolution the
user has. I’ve been unable to do so while getting the transparent areas
correct, instead i get black areas where it used to be transparent.

The following code generates this problem:
SDL_Surface *temp = SDL_CreateRGBSurface(SDL_SWSURFACE, width, height,
bpp, 0, 0, 0, 0);
SDL_BlitSurface(some_image, 0, temp, 0); // The same effect as when i use
my resize code
SDL_BlitSurface(temp, 0, screen, some_dest); // When i do this the
transparent areas in the original “some_image” is black.

How do i keep the transparent information when i copy the surface? This
copy must be done on a per pixel basis so that i can use scale variables
like this:
//getPixel(src, (int)(xwscale), (int)(yhscale), r, g, b);
//setPixel(dst, x, y, r, g, b);

// I’ve attempted to include alpha like this, but it would not work
though… but is this really what im looking for anyway?
SDL_GetRGBA(((Uint32*)src->pixels)[x + ysrc->w], src->format, &r, &g, &b,
&a);
((Uint32
)dst->pixels)[x + y*dst->w] = SDL_MapRGBA(src->format, r, g, b,
a);

Thanks in advance / Jocke


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl