在C#中生成巨大的图像 [英] Generate huge image in C#

查看:116
本文介绍了在C#中生成巨大的图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用PixelFormat.Format24bppRgb编码创建一个巨大的图像(aprox 24000 x 22000)。我知道打开它几乎是不可能的......

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

我想做的是:

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

正如预期的那样,抛出异常,因为我无法轻松地处理内存中的11GB文件。

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

但我有一个想法:我可以在生成文件时编写文件吗?因此,我不会在RAM上工作,而是在处理HD。

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.

为了更好地解释:我有大约13K的瓷砖,我打算将它拼接在一起愚蠢的文件。因为我可以在给定顺序中迭代它们,所以我可以使用不安全的代码将其直接写入内存。

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.

有任何建议吗?

推荐答案

ImageMagick的大图像支持(tera-pixel)可以帮助您在构成图像后将图像放在一起。您可以使用命令行并使用包装器向其发出命令,或使用此 ImageMagick.NET 作为API。

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.

这篇关于在C#中生成巨大的图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆