【问题标题】:Can't convert tiff image to a bitmap (matrix)无法将 tiff 图像转换为位图(矩阵)
【发布时间】:2021-01-03 17:07:32
【问题描述】:

函数 GetBitMapColorMatrix 应该解码 tiff 图像并返回描述 tiff 图像的位图,但由于某种原因,我得到了这个异常 -> System.PlatformNotSupportedException: 'System.Drawing is not supported on this platform'。任何帮助将不胜感激。

public Color[][] GetBitMapColorMatrix(string bitmapFilePath)
    {
        Bitmap b1 = new Bitmap(bitmapFilePath);

        int hight = b1.Height;
        int width = b1.Width;

        Color[][] colorMatrix = new Color[width][];
        for (int i = 0; i < width; i++)
        {
            colorMatrix[i] = new Color[hight];
            for (int j = 0; j < hight; j++)
            {
                colorMatrix[i][j] = b1.GetPixel(i, j);
            }
        }
        return colorMatrix;
    }

【问题讨论】:

  • UWP 中似乎就是这种情况,请参阅此处docs.microsoft.com/en-us/answers/questions/16112/…
  • 所以你基本上是在说 uwp 不支持位图
  • 我不是 UWP 方面的专家,所以你不能认为我的话是理所当然的。但是搜索确切的错误消息给了我这个结果。

标签: c# uwp bitmap tiff


【解决方案1】:

UWP 不使用完整的 .net 框架,因此 System.Drawing 中的类不可用。它们是 System.Media.Imaging 命名空间中的一些类,例如 BitmapPalletteBitmapImage,它们可能很有用。我也会看看Win2DSharpDX

【讨论】:

  • 专业提示:“托盘”≠“调色板”;)
  • 这两个 BitmapClasses 实际上是针对 .NET 版本的,而不是 UWP 版本。不管在这种情况下,他的两个选项是您建议的,Win2D 的 CanvasBitmap 或内置的 SoftwareBitmap 类。
  • 你能告诉我如何使用sharpDX解码图像吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2022-01-03
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多