[SDL] Alpha blending transparent PNGs

David Olofson david at olofson.net
Sat Oct 20 06:02:08 PDT 2007


(What's the matter with your mail client...? The text version comes 
out as a single line of text.)

On Saturday 20 October 2007, Cracker wrote:
[...]
>             Hello again!Thanks for your answers. Speed is important
> in my program, so nothing left but to write my own image
> loading/displaying system and use SDL for input/timer handling only,
> or to not use transparent PNGs.

Well, you should still be able to use SDL for pretty much everything 
but the actual "alpha*alpha" blending, at least for software 
rendering.

Alternatively, glSDL (as of 0.8) will do what you need, using an 
extended blending API, and also has rotation and scaling - but as of 
now, these features are only available when actually rendering over 
OpenGL.
	http://olofson.net/mixed.html


> But is it possible to blend a PNG which has no transparency, but
> instead of a background color, it has completely transparent
> alpha?

Yes, you can use colorkeying together with full surface alpha.


> Thanks again for your help.By the way: is this feature will be added
> to SDL 1.3?

Not sure what the plan is there. 1.3 uses Direct3D or OpenGL where 
available, and there it's trivial to implement. "Alpha*alpha" in 
software means more work and slower blitting, though.


//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