[SDL] Re: Displaying transparent images
Juan Ignacio Carniglia
juancarniglia at fibertel.com.ar
Tue Aug 19 07:21:01 PDT 2003
I am using BMP, and setting the transparent color to RGB =
By using the SDL_SetColorKey alone, I have had no problems displaying
Transparent sprites. Perhaps, you should try either using a BMP, or
the actual RGB values of your transparent color.
Juan Ignacio Carniglia - Programmer - Buenos Aires, Argentina.
> --- 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.
> Do you Yahoo!?
> Yahoo! SiteBuilder - Free, easy-to-use web site design
> software http://sitebuilder.yahoo.com
> SDL mailing list
> SDL at libsdl.org
More information about the SDL