什么是C#.NET位图的最大分辨率? [英] What is the maximum resolution of C# .NET Bitmap?

查看:222
本文介绍了什么是C#.NET位图的最大分辨率?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

从理论上讲,它应该是65,535点¯x65,535给你有足够的内存,17GB左右。

Theoretically, it should be 65,535 x 65,535 given you have enough memory, about 17GB.

然而,创造了.NET 4.5控制台应用程序来测试它,它抛出System.ArgumentException:参数是无效的。

However, creating a .NET 4.5 Console Application to test it out, it throws System.ArgumentException: Parameter is not valid.

该应用程序是专为64位平台。运行在64位平台的32GB内存。最大分辨率我已经能够得到22000点¯x22000像素。

The application is built for 64bit platform. Running on 64bit platform with 32GB of memory. Maximum resolution I've been able to get is 22,000 x 22,000 pixels.

我找不到关于这个的任何文档。

I could not find any documentation on this.

和古怪的行为是,即使22,000点¯x22000像素,它并不总是工作。有时工作,而且有时会抛出异常。这让我觉得它涉及到邻近的内存分配,但有关于空闲内存30GB。

And odd behavior is that even at 22,000 x 22,000 pixels, it doesn't always work. It sometimes works, and it sometimes throws the exception. This make me think it's related to contiguous memory allocation, but there is about 30GB of free memory.

没有任何人有这种经验吗?如果我想和说干就干,100,000×10万像素的图像和更大,这将是除了实现我自己的位图的最佳方式?

Does anybody have any experience with this? And if I wanted to work with say, 100,000 x 100,000 pixel image and larger, what would be the best way besides implementing my own bitmap?

编辑:问题不是.NET最大对象的大小。这可以通过定位为64位的平台,并在应用程序配置设置gcAllowVeryLargeObjects标志来克服。通过这种方式,我可以得到单个整数数组消耗超过15GB的内存应用。到目前为止,答案似乎在于在GDI +的底层实现,但我如何围绕它得到什么?

The problem isn't .NET Maximum Object Size. This can be overcome by targeting for 64bit platforms, and setting the gcAllowVeryLargeObjects flag in the application config. In this way, I can get the application to consume over 15GB of memory with a single array of integers. So far, the answer seems to lie in the underlying implementation of the GDI+, but how do I get around it?

推荐答案

这是一个GDI +限制由Windows强加的。 GDI +创建位图的象素数据的存储器映射文件图。窗口限制,他们可以是多大,因为记录在这个MSDN文章

This is a GDI+ limitation imposed by Windows. GDI+ creates a memory-mapped file view for the pixel data of the bitmap. Windows restricts how large they can be, as documented in this MSDN article:

这是由一个名为备份文件映射对象的大小由磁盘空间的限制。查看文件的大小限制为未保留虚拟内存最大可用连续块。这是至多2 GB的减去虚拟存储器已经由过程保留

The size of a file mapping object that is backed by a named file is limited by disk space. The size of a file view is limited to the largest available contiguous block of unreserved virtual memory. This is at most 2 GB minus the virtual memory already reserved by the process.

最大可用连续块是在32位进程的限制,往往〜600 MB左右徘徊,给予或采取。 2 GB限制踢上64位进程。技术上GDI +可以通过重新映射视图绕过这个限制。但它没有,核心LockBits()方法(大量内部使用)将是非常难用。

"Largest available continuous block" is the restriction in a 32-bit process, tends to hover around ~600 MB, give or take. The 2 GB limit kicks in on a 64-bit process. Technically GDI+ could bypass this limit by remapping the view. But it doesn't, the core LockBits() method (heavily used internally) would be very hard to use.

要使用你需要移动到GDI +,WIC(的 Windows图像处理组件)。通过System.Windows.Media.Imaging命名空间暴露.NET。

To use larger bitmaps you need to move to the successor of GDI+, WIC (Windows Imaging Component). Exposed in .NET through the System.Windows.Media.Imaging namespace.

这篇关于什么是C#.NET位图的最大分辨率?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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