错误:“读取.tiff文件时,编解码器无法使用提供的流类型”

问题描述 投票:4回答:1

当我尝试使用TiffBitmapDecoder读取.tif图像时,我收到上述错误。我正在使用的代码是

using (Stream stream = new FileStream(filepath,FileMode.Open,FileAccess.Read,FileShare.Read))
            {
                TiffBitmapDecoder decoder = new TiffBitmapDecoder(stream, BitmapCreateOptions.IgnoreImageCache, BitmapCacheOption.None);

                BitmapSource bitmapsource = decoder.Frames[0];
            }

如果有人遇到类似问题并解决了它。请分享一些想法。

c# .net image inputstream tiff
1个回答
0
投票

您可以尝试BitmapDecoder.Create()这允许您读取任何图像的流类型

using (Stream stream = new FileStream(filepath,FileMode.Open,FileAccess.Read,FileShare.Read))
        {
            BitmapDecoder decoder = BitmapDecoder.Create(stream, BitmapCreateOptions.IgnoreImageCache, BitmapCacheOption.None);

            BitmapSource bitmapsource = decoder.Frames[0];
        }
© www.soinside.com 2019 - 2024. All rights reserved.