Creating a huge image in C #

I need to create a huge image (aprox 24000 x 22000) encoded with PixelFormat.Format24bppRgb. I know that it can hardly be opened ...

What I'm trying to do is:

Bitmap final = new Bitmap(width, height, PixelFormat.Format24bppRgb); 

As expected, an exception occurs because I cannot easily process an 11GB file in memory.

But I had an idea: I can write a file, how do I create it? Thus, instead of working with RAM, I will work on HD.

Just to better explain: I have about 13K tiles, and I plan to stitch it together in this silly-bulky file. Since I can repeat them in the feed order, I can write it directly to memory using unsafe code.

Any suggestions?

+6
source share
3 answers

ImageMagick Large image support (tera-pixel) helps you move the image together if you have tiles that make it up. You can use the command line and invoke commands using this wrapper or use this ImageMagick.NET as an API.

+3
source

You can record it in uncompressed BMP format. BMP stores the original color bytes in strings. Thus, you load the first row of tiles, read their individual lines of pixels, and write them as a composite single line in the output image. Thus, you can open only a few fragments and immediately record the recorded image.

But I do not know how to write it as a compressed image, such as JPG or PNG. But I'm sure there is specialized software for this.

+2
source

Depending on what you intend to do with this image upon completion, I would suggest dividing it into 4 and working with it that way. I worked with 10,000 x 10,000 pixels without any CCA.

0
source

Source: https://habr.com/ru/post/915988/


All Articles