Jump to content
  • Advertisement
Sign in to follow this  
Staryon

SDL: Problem copying an image (newbie)

This topic is 4836 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

Hi, I have a big bitmap with all the frames of a single sprite. I would like to copy the first sprite (they are all 32x32) from that big bitmap to another surface. I'm trying to do this: SDL_Surface *pFullImage, *temp2; if((pFullImage = SDL_LoadBMP(filename)) == NULL) return -1; SDL_Rect dest; dest.x = 0; dest.y = 0; SDL_Rect src; src.x = 0; src.y = 0; src.w = 32; src.h = 32; SDL_BlitSurface(pFullImage, &src, temp2, &dest); However it crashes in SDL_BlitSurface because it says that temp2 is not initialized. Any ideas? Thanks a lot...

Share this post


Link to post
Share on other sites
Advertisement
temp2 is a pointer, but is not yet pointing to anything valid.
Use SDL_CreateSurface to create an image that will hold your bitmap. Then your SDL_BlitSurface will work fine.

One other thing, the dest.w and dest.h values are not initialized. You need to either set them to 32, or - since you are using all of your destination surface - just pass NULL instead of &dest.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!