如何在紧凑的框架中生成大图像

发布于 2024-08-31 09:18:18 字数 252 浏览 6 评论 0原文

我需要在我的紧凑框架应用程序中生成大图像(200 DPI 的 A4 图像,PNG 格式就可以了)。由于内存限制,这是不可能以标准方式完成的(这么大的图像将抛出 OOMException)。

是否有任何库提供文件支持的流图像生成?

或者,我可以使用标准位图方法生成许多较小的图像条纹(每个条纹代表大图像的一行),但我需要随后将它们合并在一起 - 有没有什么方法可以将许多较小的图像合并为一个大图像,而无需实例化大型 Bitmap 实例(这会再次导致 OOM)?

I need to generate large images (A4 image at 200 DPI, PNG format would be fine) in my compact framework application. This is impossible to do in standard way due to memory limitations (such big image will throw OOMException).

Is there any library which offers file-backed stream image generation?

Or I could generate many smaller stripes of images (each stripe representing a row of the large image) using standard Bitmap approach, but I need to merge them together afterwards - is there any method how to merge many smaller images into one large without having to instantiate large Bitmap instance (which would again cause OOM)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

歌入人心 2024-09-07 09:18:18

我自己也有类似的需求,所以我结束了编写自己的库。 PNGJ 您可能会发现它很有用,它是 Java 但它应该易于移植到 C#(完全独立于其他库)。它写入和读取 PNG 图像(调色板图像除外),面向行,级别相当低,针对处理巨大图像进行了优化。下载中有一些示例。

更新:我在这里提供了 C#:PNGCS

I had a similar need myself, and I end writing my own library. PNGJ You may found it useful, it's Java but it should be easy to port to C# (completely independent of other libraries). It writes and reads PNG images (except paletted ones), line oriented, rather low level, optimized for handling huge images. There are some examples in the download.

Updated: I've made a C# available here: PNGCS

何以笙箫默 2024-09-07 09:18:18

这很有趣......我为你做了一些谷歌搜索,我发现的唯一有用的东西是这个 OpenNETCF 智能设备框架。类库参考这里建议你看一下ImagingFactoryClass。 CreateImageEncoderToStream 方法可能有用。

如果您有一个可以为您完成合并方法的库,那么合并方法会很酷。我查看了 PNG 规格,发现前景不太乐观。

祝你好运,我希望这会有所帮助。

This is interesting... I did some googling for you, and the only useful thing I found is this OpenNETCF Smart Device Framework. The class library reference is here Suggest you to take a look at ImagingFactoryClass. CreateImageEncoderToStream method might be useful.

Merging approach would be cool if you had a library that would do it for you. I took a look at PNG specifications and its not very promising.

Good luck and I hope this helps.

帅气尐潴 2024-09-07 09:18:18

我刚刚快速实现了 PNG 流编码类 - 虽然它目前仅支持 8bpp 和灰度,但这对于我的场景来说已经足够了。扩展该类以支持 RGB 和更多颜色深度应该很容易。

http://gist.github.com/393409

I just made a quick basic implementation of PNG stream encoding class - it supports just 8bpp and grayscale at the moment though, but that's enough for my scenario. It should be quite easy to extend the class to support RGB and more color depths.

http://gist.github.com/393409

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文