gpt4 book ai didi

c# - 错误 : "The codec cannot use the type of stream provided" while reading a . tiff 文件

转载 作者:行者123 更新时间:2023-11-30 12:56:39 28 4
gpt4 key购买 nike

当我尝试使用 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,FileMode.Open,FileAccess.Read,FileShare.Read))
{
BitmapDecoder decoder = BitmapDecoder.Create(stream, BitmapCreateOptions.IgnoreImageCache, BitmapCacheOption.None);

BitmapSource bitmapsource = decoder.Frames[0];
}

关于c# - 错误 : "The codec cannot use the type of stream provided" while reading a . tiff 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39682221/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com