Jump to content
  • Advertisement
Sign in to follow this  
silverphyre673

Loading a part of an image in SDL

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

I am having trouble thinking of a way to do this. I need to make a clock for my game, and I stored the graphics for each number (0-9) in a single bitmap image. I wanted to know how you would use SDL's image loading functions to load a piece of the image. I've done stuff like this before, so I understand how the process works mathematically, I just need to know what function to call (SDL_LoadBMP takes just one argument, the file name). If vanilla SDL doesn't have this capability, will I find it in the SDL_Image library? Thanks a bunch.

Share this post


Link to post
Share on other sites
Advertisement
Load the entire bitmap at once, and then blit the individual parts of it, either to new surfaces, or directly to the screen as needed.

Share this post


Link to post
Share on other sites
OK... Actually, thinking on it now, I can just store it all in one big image and just blit the parts I need. Don't know why I didn't think of this immediately. Must be the heat =)

Thanks, though.

Share this post


Link to post
Share on other sites
To address the original question, if you, or someone else reading, actually wanted to load parts of a BMP, then you would have to write your own custom function utilizing SDL_rwops. Basically it'd just be a matter of loading the right portion of the BMP from the file (heavy usage of seek/set/read) then use the right rwops function, probabally the SDL_RWFromMem, and then pass that to the SDL_LoadBMP_RW function.

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!