Reputation:
I am making an imaging application. I need a 16000 x 16000 pixel image. This is not impossible because in PhotoShop I can create this image for print. (56 x 56 inches, in 300dpi)
I am using this code:
Image WorkImage = new Bitmap(16000, 16000);
This generates an "Invalid Parameter"
exception, but not when I do 9000 x 9000 Pixels.
MSDN doesn't say anything about the limits in the constructor.
I know that the data in the bitmap object is in memory, because if the array is too big it can throw an "Out Of Memory"
exception, but this is not the case. I would prefer manage this data in a file, but I don't know how.
Thanks.
Upvotes: 2
Views: 899
Reputation:
Really, dont mind where is the Bitmap Data. I only need in the output a file (TIFF) with the 16000 x 16000 pixels image. I think that i can create a class (How the bitmap class and the image class) but with the data in the file itself, where i can edit the image.
I am thinking to check the TIFF structure and create a class for create and edit those files partially buffered in memory. I dont want create a object that are more big than a few MB.
But i want to know if there is some class with BMP or TIFF File editing capability... really i dont know.
Thanks for your previous Answers. :)
Upvotes: 0
Reputation: 12397
Why not generate a bunch of smaller bitmaps? E.g. 16 bitmaps that are 4k x 4k pixels...?
Oh, and although probably not the cause of the exception you got, there are some funny quirks with large objects / the CLR large object heap. This is covered in some other SO topics that you may want to read just for fun since you're playing with large chunks of memory... E.g.: How to get unused memory back from the large object heap LOH from multiple managed apps?
Upvotes: 4
Reputation: 116411
While I agree with Charlie that you're probably better off with several smaller bitmaps, I just ran the code below on my 32 bit Windows with 2 GB RAM, and it took a while to complete, but I received no errors.
var b = new Bitmap(16000, 16000);
Console.WriteLine("size is {0}x{1}", b.Width, b.Height);
Upvotes: 2
Reputation: 13488
Photoshop does not allocate gigantic images in contiguous portions of memory as you are trying to do. There are some memory limitations I've encountered when creating very large images.
Consider subdividing your images. This has the benefit of better memory management. If you edit one of your subdivided images, you won't have to update the entire image.
As an aside, a 16000 x 16000 at 4 bytes per pixel is roughly a gigabyte! That's huge. Good luck!
Upvotes: 6