Processing on large bitmaps (up to 3GB)

前端 未结 3 1449
故里飘歌
故里飘歌 2020-12-11 05:15

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 Bi         


        
相关标签:
3条回答
  • 2020-12-11 05:54

    Consider using Memory Mapped Files to access your HUGE data :). An example focused on what you need can be found here: http://visualstudiomagazine.com/articles/2010/06/23/memory-mapped-files.aspx It's in managed code but you might as well use it from equivalent native code.

    Let me know if you need more details.

    0 讨论(0)
  • 2020-12-11 05:59

    You can stop memory caching.

    Instead of

    Bitmap bmp = new Bitmap(pathToFile);

    Use

    var bmp = (Bitmap)Image.FromStream(sourceFileStream, false, false);

    see https://stackoverflow.com/a/47424918/887092

    0 讨论(0)
  • 2020-12-11 06:01

    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/06/23/memory-mapped-files.aspx

    0 讨论(0)
提交回复
热议问题