Displaying transparent images

Hello boys !!,(I’m new on this mailing list ,so don’t be too severe if I
make mistakes … :))

I had a lot of problems loading(and displaying) a gif image that contains
some transparent areas…
And the ref manual isn’t very clear about this,…anyway,… If someone could
provide me with
a function that loads a gif image,convert it correctly ,and return an
SDL_Surface* that I can blit
on screeen without having to worry about transparency ,it would be nice !!!

Thanks in advence !!!

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.

-Thomas

— 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

I am using BMP, and setting the transparent color to RGB =
(255,255,254).
By using the SDL_SetColorKey alone, I have had no problems displaying
Transparent sprites. Perhaps, you should try either using a BMP, or
checking
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.

                                                        NBarnes

Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design
software http://sitebuilder.yahoo.com


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Hi!
Look at SDL_image library! It allows to load pictures in different
formats. I don’t know about GIF (I never use gif), but you also can fill
transparent parts of your image with unused color and set colorkey:
SDL_SetColorKey(surface, SDL_SRCCOLORKEY,
SDL_MapRGB(surface->format,r,g,b));
where r g b - RGB of transparent color. You can also set alpha chahhel
to surface (alpha blending) - read manual.

Freeman wrote:> Hello boys !!,(I’m new on this mailing list ,so don’t be too severe if I

make mistakes … :))

I had a lot of problems loading(and displaying) a gif image that contains
some transparent areas…
And the ref manual isn’t very clear about this,…anyway,… If someone could
provide me with
a function that loads a gif image,convert it correctly ,and return an
SDL_Surface* that I can blit
on screeen without having to worry about transparency ,it would be nice !!!

Thanks in advence !!!