大位图处理(最多3GB) [英] Processing on large bitmaps (up to 3GB)

查看:195
本文介绍了大位图处理(最多3GB)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作的一些大学项目,并卡住了内存问题。
我打开一个位图大约需要1,5GB硬盘上低于code:

I'm working on some university project and got stuck with memory issue. I load a bitmap which takes about 1,5GB on HDD with code below:

Bitmap bmp = new Bitmap(pathToFile); 

问题是,新创建位图对象使用有关的RAM 3,5GB这是我无法理解(这是真正的大包装:E)。我需要的像素阵列,以及使用Bitmap类是真正有用的(我用LockBits()方法后,并处理每字节数组字节),但在这种情况下,它的总拦截。因此,这里是我的问题:

The issue is that the newly created Bitmap object uses about 3,5GB of RAM which is something I can't understand (that's really BIG wrapper :E). I need to get to the pixel array, and the use of Bitmap class is really helpful (I use LockBits() method later, and process the array byte per byte) but in this case it's total blocker. So here is my question:

有没有简单的方法来提取贷款无需额外2GB的像素阵列?

Is there any easy way to extract the pixel array without lending additional 2gb?

我使用C#只是为了提取所需的阵列,这是在C ++后处理 - 也许我可以提取C所有需要的数据++(但似乎这里转换的问题 - 我专注于24bgr格式)?

I'm using c# just to extract the needed array, which is later processed in c++ - maybe I can extract all needed data in c++ (but conversion issue appears here - I'm concentrating on 24bgr format)?

PS:我需要保持整个位图在内存中,因此分成部分是无解的。

PS: I need to keep the whole bitmap in memory so splitting it into parts is no solution.

PS2:只是为了澄清一些问题:我知道文件扩展名和文件格式之间的差异。加载的文件uncom pressed位每大小约1.42GB(16K点¯x32K像素)像素的3个字节,那么为什么Bitmap对象是超过两倍大吗?任何DECOM pressing问题,并转换成其它格式不发生。

PS2: Just to clarify some issues: I know the difference between file extension and file format. The loaded file is uncompressed bitmap 3 bytes per pixel of size ~1.42GB (16k x 32k pixels), so why Bitmap object is more than two times bigger? Any decompressing issues and converting into other format aren't taking place.

推荐答案

您可以使用此解决方案,在C#中更快地工作位图
HTTP://www.$c$cproject .COM /提示/ 240428 /工作与 - 位图快与 - Csharp的

You can use this solution , Work with bitmaps faster in C# http://www.codeproject.com/Tips/240428/Work-with-bitmap-faster-with-Csharp

或者你可以使用内存映射文件

Or you can use memory mapped files

http://visualstudiomagazine.com/articles/2010/ 6月23日/内存映射,files.aspx

这篇关于大位图处理(最多3GB)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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