Advertisement

SDL - Saving large images?

Started by July 13, 2011 07:32 PM
0 comments, last by fastcall22 13 years, 4 months ago
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?
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...

This topic is closed to new replies.

Advertisement