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 !!!
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 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…
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.>
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…
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 !!!