I need to work with large monochromatic images. I basically need to add a banner (frame and formatted text) to a hi-res (like 30000x20000px) monochromatic images (A2+ plots at 400dpi).
The default PixelFormat
is Format1bppIndexed
, which makes even those large picture relatively small in size. However, using .NET GDI+ Graphics
object requires unindexed bitmap.
When turning the image to lowest available unindexed PixelFormat.Format16bppGrayscale
:
bmpResized = ImgResized.Clone(New System.Drawing.Rectangle(0, 0, ImgResized.Width, ImgResized.Height),
System.Drawing.Imaging.PixelFormat.Format16bppGrayScale)
...it becomes to large to be handled by Image
and Bitmap
(OutOfMemoryExeption: Not enough memory
- on 32GB machine).
I tried to create the banner separately and join the pictures pixel-wise, however I ran into the very same limitations - SetPixel
requires unindexed bitmap.
Is there any way to overcome those issues?
EDIT: A possible solution would be to create a byte array and edit the bytes as per [https://social.msdn.microsoft.com/Forums/vstudio/en-US/54a096ff-46f3-45ce-8560-bf5a0618ef75/how-to-set-pixel-into-bitmap-with-pixel-format-of-format8bppindexed-?forum=csharpgeneral][1]. However I'm not sure how exactly I can "shift" the 2nd image byte-wise.