Jump to content
  • Advertisement
Sign in to follow this  
rayneolivetti

picking a rect from an SDL_Surface to a new surface

This topic is 4282 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

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

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!