【问题标题】:Opening 32-bit float image causes OutOfMemoryException [duplicate]打开 32 位浮点图像会导致 OutOfMemoryException [重复]
【发布时间】:2017-02-02 19:07:44
【问题描述】:

我正在 Visual Studio 2017 RC 中运行控制台应用程序。执行下面的代码时,我得到一个System.OutOfMemoryException: 'Out of memory.' 异常。

我尝试加载的图像是 32 位浮点图像。
加载 16 位浮点图像可以正常工作。

我已尝试在配置管理器中将Plattform类型设置为x64

using System.Drawing;

namespace ConsoleAppImageTest
{
    class Program
    {
        static void Main(string[] args)
        {
            string PathToFile = @"D:\img\rgb32bitF.tiff";
            Image img = Image.FromFile(PathToFile);
        }
    }
}

【问题讨论】:

  • 彩色还是黑色?
  • rgba(1, 1, 1, 1)。纯白色。我应该将文件上传到哪里以进行 stackoverflow?

标签: c# image floating-point


【解决方案1】:

尝试LibTiff.NET 处理 TIFF 图像。

【讨论】:

    【解决方案2】:

    This answer 提供了打开(32 位)tiff 的解决方案(如M Adeel Khalid 所建议的那样)。

    添加 PresentationCore 参考和using System.Windows.Media.Imaging;

     string PathToFile = @"D:\img\rgb32bitF.tiff";
     Stream imageStreamSource = new FileStream(PathToFile, FileMode.Open, FileAccess.Read, FileShare.Read);
     TiffBitmapDecoder decoder = new TiffBitmapDecoder(imageStreamSource, BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
     BitmapSource bitmapSource = decoder.Frames[0];
    

    【讨论】:

      猜你喜欢
      • 2014-12-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-06-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-12-02
      相关资源
      最近更新 更多