Sign in to follow this  
The Perfect K

SDL - Saving large images?

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:

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

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:
[code]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");[/code]

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
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 [url=http://www.libsdl.org/projects/SDL_image/]SDL_image library[/url], and save images as PNG or JPEG to reduce file size...

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