Png alpha and sdl_displayformat

quick question:
i have a png file w/ transparency and no background (fully
transparent), and i bring it in:

alpha_image = IMG_Load(“filename.png”);
SDL_SetAlpha(alpha_image, SDL_SRCALPHA, 0);

and if i blit that, everything’s fine, but if i do

temp = IMG_Load(“filename.png”);
SDL_SetAlpha(temp, SDL_SRCALPHA, 0);
alpha_image = SDL_DisplayFormat(temp);

and blit that (that being alpha_image), i don’t see anything (the entire
image is a circle, 50% transparent, against nothing (no white, black,
etc.))

… so, any idea how to convert it to the correct display format but not
lose alpha channels … or do i even need to convert it?–

El dt, 02-04-2002 a las 12:26, Christopher Thielen escribi?:

quick question:
	i have a png file w/ transparency and no background (fully
transparent), and i bring it in:

alpha_image = IMG_Load("filename.png");
SDL_SetAlpha(alpha_image, SDL_SRCALPHA, 0);

and if i blit that, everything's fine, but if i do

temp = IMG_Load("filename.png");
SDL_SetAlpha(temp, SDL_SRCALPHA, 0);
alpha_image = SDL_DisplayFormat(temp);

use
alpha_image = SDL_DisplayFormatAlpha(temp);
for images with alpha channel
read the documentation

and blit that (that being alpha_image), i don't see anything (the entire
image is a circle, 50% transparent, against nothing (no white, black,
etc.))

... so, any idea how to convert it to the correct display format but not
lose alpha channels ... or do i even need to convert it?-- 
- Chris
Epiar Administrator/Programmer
http://epiar.sourceforge.net/


_______________________________________________
SDL mailing list
SDL at libsdl.org

http://www.libsdl.org/mailman/listinfo/sdl

quick question:
i have a png file w/ transparency and no background (fully
transparent), and i bring it in:

alpha_image = IMG_Load(“filename.png”);
SDL_SetAlpha(alpha_image, SDL_SRCALPHA, 0);

If it already has alpha, you don’t need this SDL_SetAlpha(). That’s really
designed for images that don’t have alpha yet.

and if i blit that, everything’s fine, but if i do

temp = IMG_Load(“filename.png”);
SDL_SetAlpha(temp, SDL_SRCALPHA, 0);
alpha_image = SDL_DisplayFormat(temp);

and blit that (that being alpha_image), i don’t see anything (the entire
image is a circle, 50% transparent, against nothing (no white, black,
etc.))

Because the display surface doesn’t have an alpha channel. So converting an
image causes it to lose it’s alpha channel. Instead, it uses the
SDL_SetAlpha() call you made, sees that you set it to 0 (which is fully
transparent), and so makes the resulting surface fully transparent.

… so, any idea how to convert it to the correct display format but not
lose alpha channels … or do i even need to convert it?

If you can set a screen mode that has an alpha channel, then you wouldn’t
lose it in the conversion. Otherwise, if the screen doesn’t have alpha,
converting it is always going to lose the channel. The only way to not lose
it is to not convert it. If your whole image has a fixed alpha value (50%
in this case), then you can let it not have an alpha channel and just use
SDL_SetAlpha() instead. If the image has various alpha levels, though,
you’ll need to keep the alpha channel, and not convert it.

-Jason

----- Original Message -----
From: chris@luethy.net (Christopher Thielen)
To:
Sent: Tuesday, April 02, 2002 5:26 AM
Subject: [SDL] png alpha and sdl_displayformat