picking a rect from an SDL_Surface to a new surface

Started by
2 comments, last by rip-off 17 years, 7 months ago
Here's what happens: I'm loading a 8-bit png file, and call SDL_DisplayFormat. I blit it, and transparency works fine. Now, I create a new SDL_Surface with SDL_CreateRGBSurface, using the values from the previous surface. Then I blit a part of previous surface to the newly created one, thinking I've cropped the part I wanted. But when I blit the new surface, I no longer have transparency. I tried SDL_SetColorKey(), directly copying surface->format from the old to new one (and surface->flags as well), but it's same. How do I do that?
Advertisement
By "transparency" do you mean alpha blending or colorkeying? Also can you post the call to SDL_CreateRGBSurface because you need to pass either SDL_SRCCOLORKEY or SDL_SRCALPHA as a flag.
Color keying. And yes, I'm passing SDL_SRCCOLORKEY as the first parameter.
Rather than digging my error, would post something works?

Thanks in advance! :)
The alpha values of the destination arent modified during a blit. The source alpha values are only used to control the amount of the source blended in with the destination.

You can make a copysurface function that is slower than blitsurface, that loks the surfaces, loops through all the pixels and uses getpixel and putpixel ( described here ) to do a full copy. Finally unlock the surfaces.

This topic is closed to new replies.

Advertisement