I'm trying to concatenate a list of 1600*900 images as a mosaic but i cannot allocate a Bitmap of (for example) 100k per 100k.
And so i'm lookin for a way to create a bitmap file and write on it in a stream-like way.
How can i do? Thank You.
I'm trying to concatenate a list of 1600*900 images as a mosaic but i cannot allocate a Bitmap of (for example) 100k per 100k.
And so i'm lookin for a way to create a bitmap file and write on it in a stream-like way.
How can i do? Thank You.
Although the exact practical value of a 100k-by-100k image is yet to be known, the solution might be:
Create a list of offsets of the source images in the resulting W-by-H mosaic. Some calculations here: 100k-by-100k image can hold approximately 50-by-100 images (5k only, a reasonable number). So you need only ~5000 elements in the offset array which is far from being big. Use this answer (http://stackoverflow.com/questions/8762569/how-is-2d-bin-packing-achieved-programmatically/10339522) to calculate those offsets.
Write the image header to file stream (see the 54-byte header for .BMP format for example)
The "inefficient" part: Write (100k-by-100k)*BytesPerPixel zeroes to the file and then iterate the images writing them to this file one by one.
The InsertImageToStream() is done line-by-line, I think it is pretty straight-forward.
Optimization for the step 3: When the offsets[] array is sorted by Y and then by X you can optimally fill each scanline of the resulting image without excessive FileStream.seek() calls.