Jump to content
  • Advertisement
Sign in to follow this  
The Perfect K

SDL - Saving large images?

This topic is 2709 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'm having a strange problem with SDL and I'm not too sure where to find out how to solve it. My dad bought a commercial large scanner to help him archive a bunch of architectural drawings he has. Only problem is that the scanner's thread is messed up, and thus a large, thick black line appears in the middle of all his scans. He's not too computer savvy, so he asked me if I could write a program that would automatically crop out the black line that appears on his scans.

That normally wouldn't be a problem, except that his scans are 14650x14650 big. I'm running into a problem with SDL when I'm trying to save the resulting cropped image as a bmp. I've tried two methods with differing results.

If I load the image into a surface then try to save that surface, I get a small blank BMP as a result. Pseudo code as follows:

SDL_Surface* Image;
Image = load_image("Scan.bmp")
~~a bunch of stuff that crops image~~
SDL_SaveBMP(Image, "Output.bmp");


that would result in a file called output.bmp that is just a tiny white square.

If I blit image onto a screen surface (or really any other surface that's not that big) I can save the bmp, but it'll only save the size of the surface. Pseudo code as follows:
SDL_Surface* screen;
SDL_Surface* image;
~~~code which sets up screen to be 1280x768 big~~
image = load_image("Scan.bmp");
~~~code which blits image to screen~~
SDL_SaveBMP(screen, "Output.bmp");


That would result in a bmp called Output, which is 1280x768 big, which contains a corner of the scan. I'm guessing the problem lies with trying to work with such a large image. I've been trying to look up documentation to see if there are any size restrictions on SDL_SaveBMP but I can't find anything. Anyone know what could be causing this? Or maybe an alternative method I could use?

Share this post


Link to post
Share on other sites
Advertisement
I would first check the return value for SDL_SaveBMP, since it will return -1 on error. (Perhaps SDL_GetError might have some more detail as to the problem?) Another suggestion is to use the SDL_image library, and save images as PNG or JPEG to reduce file size...

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!