[SDL] Re: Displaying transparent images
NBarnes
nw_barnes at yahoo.com
Mon Aug 18 21:24:01 PDT 2003
--- Thomas Harte <T.Harte at btinternet.com> wrote:
> > I had a lot of problems loading(and displaying) a gif image that
> > contains some transparent areas..
> Presumably whatever method you are using to load GIFs is telling you
> which colour is the transparent one, or else you are just assuming
> it is colour 0 or something?
>
> What you want to do is to use SDL_SetColorKey to establish the
> transparent colour for the surface with the sprite in it, use
> SDL_SetAlpha to enable SDL_SRCALPHA but leave the alpha flag at 128.
>
> Following this, blit should work with transparent pixels removed.
I'm curious. To set transparency for the chosen transparency color
in my work, I have just the following line of code....
SDL_SetColorKey(spriteImages_p, SDL_SRCCOLORKEY,
SDL_MapRGB(spriteImages_p->format, 0, 255, 255));
with no call to SDL_SetAlpha().
It appears to work fine in my application. Why do you feel the call
to SDL_SetAlpha() is important? What are the consequences of not
having it?
I'm not using .GIFs to load my images, I'm using .BMPs.
NBarnes
__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com
More information about the SDL
mailing list