内存映射文件如何帮助在Windows窗体应用程序中加载大图像? [英] How Memory Mapped File helps to load a large Image in a Windows Form Application?

查看:128
本文介绍了内存映射文件如何帮助在Windows窗体应用程序中加载大图像?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我的Canvas中加载大位图,如果小图像工作正常,但是大图像会内存不足错误。我认为.Net 4.5的内存映射文件可以在这方面提供帮助。请帮助。

I am trying to load large bitmaps in my Canvas, in case of small images it works fine, but large images gets ''out of memory'' error. I think Memory Mapped File of .Net 4.5 can help in this regard. Please help.

推荐答案

显示图像不仅仅是阅读它。并非所有(实际上很少)图像文件格式都支持碎片加载。这就是为什么大多数图像处理应用程序使用自己的专有格式。在显示之前,图像将转换为其他表示形式。最简单的可以是例如512×512像素的瓦片。在这种转换过程中,MMF可能很有用,但在显示时并非如此。图像数据存储在GDI +句柄后面的内存中,因此如果你想要显示一个图像,你必须适应那个约束,当然还要进入内存。

所以,如果你的图像是平铺的,您可以选择加载哪个,您可以单独缩放它们,并轻松显示它。



其他一些有用的注意事项:在C#中读取大图像 [ ^ ]
Displaying an image is more than just reading it. Not all (actually few) image file formats support fragmented loading. That is why most of the image processing applications use their own proprietary format. Before displaying it, the image is transformed into an other representation. The simplest one could be tiles of 512x512 pixels for example. MMF could be useful during this transformation, but not really while displaying. The image data is stored in memory behind a GDI+ handle, thus if you want to display an image you have to fit in that''s constraints, and into the memory of course.
So, if your image is tiled, you can choose which to load, you can scale them individually, and display it easily.

Some other useful considerations: Read Large Images in C#[^]


问题是GDI没有支持那么大的图像。由于您实际上无法一次显示所有图像,因此需要将图像分解为较小的块(较小的图像文件)并仅加载您真正需要的图像文件。



内存映射文件对你没有帮助。
The problem is that GDI doesn''t support images that large. Since you really can''t display all of the image at once, you need to break the image down into smaller chunks (smaller image files) and load only the image files you really need.

A memory mapped file will NOT help you.


这篇关于内存映射文件如何帮助在Windows窗体应用程序中加载大图像?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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