Sign in to follow this  
rayneolivetti

picking a rect from an SDL_Surface to a new surface

Recommended Posts

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?

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this