【发布时间】:2020-06-05 06:40:33
【问题描述】:
我只是想对位图图像进行编码和解码,但 Image 类显然不存在。我要离开this page 来创建一个解码器。我在
处遇到错误Image drawnImg = new Image();
它说,“找不到类型或命名空间”,我使用的每个导入都没有修复这个错误。我在这里错过了什么图书馆?
代码如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Remoting.Metadata.W3cXsd2001;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Media.Imaging;
using System.Drawing;
namespace Thompson_BmpDecodeEncode
{
class Thompson_BmpDecodeEndoce
{
static void Main(string[] args)
{
Uri img = new Uri("<FilePath to image.bmp>", UriKind.RelativeOrAbsolute);
BmpBitmapDecoder decoder2 = new BmpBitmapDecoder(img,
BitmapCreateOptions.PreservePixelFormat, BitmapCacheOption.Default);
BitmapSource bitmapSource2 = decoder2.Frames[0];
Image drawnImg = new Image();
Console.ReadKey();
}
}
}
【问题讨论】:
-
你试过去你最喜欢的搜索引擎并输入
c# image class吗?这就是你要找的东西吗? -
点击Project --> Add Reference,然后选择左侧的Framework。在右侧找到 System.Drawing 并在其旁边打勾。点击确定。
-
您的目标是什么:Winforms、WPF、ASP..?您应该始终正确标记您的问题,以便人们可以在问题页面上看到它!