You could try SDL_DisplayFormatAlpha
(http://sdldoc.csn.ul.ie/sdldisplayformatalpha.php ) to convert the
surface, that should keep the alpha channel.
It might not solve the problem, though. When you’re creating the new
smaller surfaces and blitting parts of the strip onto them, SDL_Blit is
probably merging the alpha values of the two surfaces together.
Effectively, it’s rendering your strip image onto the frame image,
rather than copying it.
Maybe someone else can confirm this?
What you probably need to do is create the surfaces, lock both of them,
and actually do a byte for byte copy from one surface->pixels to the
other. You should be able to do it pretty easily by using memcpy and
some simple loops.
That way the alpha values will migrate intact, rather than being mixed
with the destination surface.On Wed, 2003-08-06 at 13:00, Ochendrowitsch Pablo wrote:
Hi, i have a problem loading some sprites.
I have a function that loads an image strip, break it in frames and
save it to an array. Basicaly i need to create an image on the fly for
each frame with
(info is a struct with the width and height of each frame to cut the
SDL_Surface *frame, *strip;
strip = SDL_Load(“myfile.png”);
frame = SDL_CreateRGBSurface(SDL_HWSURFACE||SDL_SRCALPHA, info->width,
info->height, 32, strip->format->Rmask, strip->format->Gmask,
then when i blit a frame to the screen it doesn’t apear.
the only way i find to effectively draw to the screen is if i use a
SDL_DisplayFormat() call, but i lose the alfa chanel.
This only happens if the file has an alfa chanel and if a go through
the frame surface, not if i blit all the strip at once.
Any suggestion please ??
SDL mailing list
SDL at libsdl.org
-------------- next part --------------
A non-text attachment was scrubbed…
Name: not available
Size: 189 bytes
Desc: This is a digitally signed message part