Sign in to follow this  
silverphyre673

Loading a part of an image in SDL

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

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