本文介绍了位图源大小限制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

MSDN备注:

BitmapSource是...

BitmapSource is ...

图像的最大高度和宽度为2 ^ 16像素,每通道32位* 4通道. BitmapSource的最大大小为2 ^ 32字节(64 GB),最大图像大小为4 GB.最小图片大小为1x1

The maximum height and width of an image is 2^16 pixels at 32 bits per channel * 4 channels. The maximum size of a BitmapSource is 2^32 bytes (64 gigabytes) and the maximum image size is four gigapixels. The minimum image size is 1x1

何时/如何BitmapSouce可以达到64GB的大小?

如果我加载的图像大小大于4GB,我总是会收到OverflowException.

I always got a OverflowException, if I loaded a image the size larger than 4GB.

我认为异常是由数组长度的限制引起的,所以如果数组的最大长度为int.MaxValue,为什么位图源的最大大小可以为64gb? /p>

I think the exception was caused by the limit of array's length, so if the max length of array is int.MaxValue, why the max size of a Bitmapsource can be 64gb?

推荐答案

.net对象的大小有限制.

There's a limit on the size of .net objects.

在仍为2Gb的32位系统中-从.Net 1开始就是这种情况.

In 32 bit systems that is still 2Gb - which has been the case since .Net 1.

在64位系统上,除非您在应用程序配置中进行了设置,否则我认为该限制仍然存在:

On 64 bit systems I think that limit is still there unless you have a setting in your app config:

<configuration>
  <runtime>
    <gcAllowVeryLargeObjects enabled="true" />
  </runtime>
</configuration>

文档讨论了数组,但是您可以尝试一下,看看它是否有区别.

The documentation talks about arrays but you could try this and see if it makes any difference.

我没有一张大照片可以自己尝试.

I don't have a huge picture to hand to try this myself.

.

请注意,磁盘上文件的大小可以与内存中的大小不同.

Note that the size of a file on disk can be different from the size in memory.

通常它的内存更大,并且在屏幕上显示图像所需的图像处理通常会大大增加.我不是专家,但是我很惊讶地读取500meg磁盘上的文件可以占用2Gb内存.

It's usually way bigger in memory and image manipulation necessary to show an image on screen often adds greatly. I'm no expert on this but I was surprised to read a file on disk 500meg can take 2Gb memory.


这篇关于位图源大小限制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-20 08:49
查看更多