当我尝试使用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];
}