Simple alpha problem

I’m having a pretty simple problem with alphas. I loaded a PNG file,
converted it to its final destination storage surface using
SDL_DisplayFormatAlpha(), and then did: SDL_SetAlpha(my_surface,
SDL_SRCALPHA, 150); and blitted it against a black surface, but it
appears full alpha (no transparency at all). Anybody know whats wrong?
Should I post more information here?–
Chris Thielen <@Christopher_Thielen>

Chris Thielen wrote:

I’m having a pretty simple problem with alphas. I loaded a PNG file,
converted it to its final destination storage surface using
SDL_DisplayFormatAlpha(), and then did: SDL_SetAlpha(my_surface,
SDL_SRCALPHA, 150); and blitted it against a black surface, but it
appears full alpha (no transparency at all). Anybody know whats
wrong?
Should I post more information here?

‘SDL_DisplayFormatAlpha’ creates an alpha channel, and per-surface
alpha is ignored in the presence of an alpha channel. Call,
‘SDL_SetALpha’ on the original surface, then use plain
’SDL_DisplayFormat’.–
Rainer Deyke | root at rainerdeyke.com | http://rainerdeyke.com

Doing this ignores the alpha from the PNG, which is important to retain.
How would I get around this?On Wed, 2002-11-27 at 18:26, Rainer Deyke wrote:

‘SDL_DisplayFormatAlpha’ creates an alpha channel, and per-surface
alpha is ignored in the presence of an alpha channel. Call,
‘SDL_SetALpha’ on the original surface, then use plain
’SDL_DisplayFormat’.


Chris Thielen <@Christopher_Thielen>

Chris Thielen wrote:> On Wed, 2002-11-27 at 18:26, Rainer Deyke wrote:

‘SDL_DisplayFormatAlpha’ creates an alpha channel, and per-surface
alpha is ignored in the presence of an alpha channel. Call,
‘SDL_SetALpha’ on the original surface, then use plain
’SDL_DisplayFormat’.

Doing this ignores the alpha from the PNG, which is important to
retain. How would I get around this?

Iterate through the surface, multiplying each pixel alpha value with
the surface alpha value.


Rainer Deyke | root at rainerdeyke.com | http://rainerdeyke.com

Do you mean to say that after SDL_SetAlpha it is wrong to call
SDL_DisplayFormatAlpha?> ‘SDL_DisplayFormatAlpha’ creates an alpha channel, and per-surface

alpha is ignored in the presence of an alpha channel. Call,
‘SDL_SetALpha’ on the original surface, then use plain
’SDL_DisplayFormat’.

James Turk wrote:

Do you mean to say that after SDL_SetAlpha it is wrong to call
SDL_DisplayFormatAlpha?

Not really “wrong”, but it may not have the behavior you want it to
have. In particular, if the original surface has an alpha channel and
per-surface alpha, the latter is ignored by ‘SDL_DisplayFormatAlpha’.–
Rainer Deyke | root at rainerdeyke.com | http://rainerdeyke.com