Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate huge image in C#

I need to create a huge image (aprox 24000 x 22000) with PixelFormat.Format24bppRgb encoding. I know it will barely impossible to open it...

What I'm trying to do is this:

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

As expected, an exception is thrown as I can't handle a 11GB file in memory easy that way.

But I had an idea: could I write the file as I'm generating it? So, instead of working on RAM, I would be working on the HD.

Just to better explain: I have about 13K tiles and I plan to stitch it together in this stupidly humongous file. As I can iterate them in a give order, I thing I could write it down directly to the memory using unsafe code.

Any suggestions?

like image 476
Rafa Borges Avatar asked May 17 '12 13:05

Rafa Borges


1 Answers

ImageMagick's Large Image Support (tera-pixel) can help you put the image together once you have the tiles that compose it. You can either use use the command line and issue commands to it using this wrapper or use this ImageMagick.NET as an API.

like image 118
Ani Avatar answered Sep 28 '22 23:09

Ani