[SDL] Maintaining transparency when concatenating transparent pngs

David Olofson david at olofson.net
Wed Jan 10 13:01:28 PST 2007


On Wednesday 10 January 2007 19:24, james osburn wrote:
> I have a set of png images that have a transparency/alpha channel. i
> want to concatenated
> these images into an SDL surface then use that surface in my
> program. I have 
> already written a small program that does indeed load the png files
> into individual surfaces
> then adds those surfaces to a final strip surface. The problem im
> having is the transparency
> channel is not working correctly.

You have to disable alpha blending (SDL_SetAlpha()) when you're doing 
the "concatenation" blitting, to get the alpha channel data *copied* 
into the destination surface, rather than applied during the blit.

...and, then you need to enable alpha blending on the resulting 
surface for the hopefully preserved alpha channel to have any effect.


//David Olofson - Programmer, Composer, Open Source Advocate

.-------  http://olofson.net - Games, SDL examples  -------.
|        http://zeespace.net - 2.5D rendering engine       |
|       http://audiality.org - Music/audio engine          |
|     http://eel.olofson.net - Real time scripting         |
'--  http://www.reologica.se - Rheology instrumentation  --'




More information about the SDL mailing list