【发布时间】:2019-08-31 10:18:51
【问题描述】:
我阅读了How to: Encode and Decode a TIFF Image并复制了代码
// Open a Stream and decode a TIFF image
Stream imageStreamSource = new FileStream("tulipfarm.tif", FileMode.Open,
FileAccess.Read, FileShare.Read);
TiffBitmapDecoder decoder = new TiffBitmapDecoder(imageStreamSource,
BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapSource bitmapSource = decoder.Frames[0];
// Draw the Image
Image myImage = new Image();
myImage.Source = bitmapSource;
myImage.Stretch = Stretch.None;
myImage.Margin = new Thickness(20);
到 Visual Studio 2017 中的控制台应用程序中。我添加了对 PresentationCore 的引用每个 https://stackoverflow.com/a/50192029/9044571 并允许我添加
using System.Windows.Media.Imaging;
但现在我收到与该行关联的错误(错误 CS0144 无法创建抽象类或接口“图像”的实例)
Image myImage = new Image();
我该如何解决这个问题?问题可能是我从控制台应用程序执行此操作吗?
【问题讨论】: