Per-Surface alpha and SDL_DisplayFormatAlpha

Hi,

When I IMG_Load() a .png I get a per-surface alpha of 255. This means that the surface is definitely using 255 as fully opaque. If I blit this surface using SDL_BlitSurface(), it works fine. Now if I use SDL_DisplayFormatAlpha() on the surface, the per-surface alpha becomes 0. This apparently means that 0 is fully opaque now. If I blit it with SDL_BlitSurface(), it still works correctly. Is there a way that I can use to emulate this functionality of SDL_BlitSurface()? What can I use to determine if a surface uses 0 or 255 as fully opaque?

Jonny D_________________________________________________________________
Make every IM count. Download Windows Live Messenger and join the i?m Initiative now. It?s free.??
http://im.live.com/messenger/im/home/?source=TAGWL_June07

Hi,

When I IMG_Load() a .png I get a per-surface alpha of 255. This means that the surface is definitely using 255 as fully opaque. If I blit this surface using SDL_BlitSurface(), it works fine. Now if I use SDL_DisplayFormatAlpha() on the surface, the per-surface alpha becomes 0. This apparently means that 0 is fully opaque now. If I blit it with SDL_BlitSurface(), it still works correctly. Is there a way that I can use to emulate this functionality of SDL_BlitSurface()? What can I use to determine if a surface uses 0 or 255 as fully opaque?

You can’t mix per-pixel and per-surface alpha. It’s zero just because it’s
intialized and then not used afterwards.

See ya!
-Sam Lantinga, Lead Software Engineer, Blizzard Entertainment

I think mixing the two alphas is worthwhile… SDL_BlitSurface() can’t do it, but my own blitter can. If you can slowly fade out an RGB surface by changing the per-surface alpha, why not be able to do it for RGBA surfaces by the same simple method? My question is really about why SDL_image sets the alpha in a newly loaded RGBA (from .png) surface to 255. I upgraded to the latest version and still get this effect. Does it just mean that I have to initialize RGBA surfaces myself every time (or change SDL_image)? If so, my blitter is done and working fine.

Jonny D> To: sdl at lists.libsdl.org> From: slouken at devolution.com> Date: Tue, 12 Jun 2007 23:47:24 -0700> Subject: Re: [SDL] Per-Surface alpha and SDL_DisplayFormatAlpha> > > > Hi,> > > > When I IMG_Load() a .png I get a per-surface alpha of 255. This means that the surface is definitely using 255 as fully opaque. If I blit this surface using SDL_BlitSurface(), it works fine. Now if I use SDL_DisplayFormatAlpha() on the surface, the per-surface alpha becomes 0. This apparently means that 0 is fully opaque now. If I blit it with SDL_BlitSurface(), it still works correctly. Is there a way that I can use to emulate this functionality of SDL_BlitSurface()? What can I use to determine if a surface uses 0 or 255 as fully opaque?> > You can’t mix per-pixel and per-surface alpha. It’s zero just because it’s> intialized and then not used afterwards.> > See ya!> -Sam Lantinga, Lead Software Engineer, Blizzard Entertainment> _______________________________________________> SDL mailing list> SDL at lists.libsdl.org> http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


With Windows Live Hotmail, you can personalize your inbox with your favorite color.
www.windowslive-hotmail.com/learnmore/personalize.html?locale=en-us&ocid=TXT_TAGLM_HMWL_reten_addcolor_0607

I think mixing the two alphas is worthwhile… SDL_BlitSurface() can’t do it, but my own blitter can. If you can slowly fade out an RGB surface by changing the per-surface alpha, why not be able to do it for RGBA surfaces by the same simple method? My question is really about why SDL_image sets the alpha in a newly loaded RGBA (from .png) surface to 255.

This sounds like a bug. If the png has an alpha channel, it should be copied
into the SDL surface. Can you send me a minimal example, along with the image?

Thanks!
-Sam Lantinga, Lead Software Engineer, Blizzard Entertainment