Q:

How do I create a 256 megapixels image in C#?

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.

A:

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!

A:

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?

