加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

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

发布时间:2020-12-15 21:02:17 所属栏目:百科 来源:网络整理
导读:当我尝试使用TiffBitmapDecoder读取.tif图像时,我收到了上述错误.我正在使用的代码是 using (Stream stream = new FileStream(filepath,FileMode.Open,FileAccess.Read,FileShare.Read)) { TiffBitmapDecoder decoder = new TiffBitmapDecoder(stream,Bitmap
当我尝试使用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];
            }

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

解决方法

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

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

            BitmapSource bitmapsource = decoder.Frames[0];
        }

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读