A.P*_*cat 3 c# .net-core .net-core-2.1
我正在使用 .Net Core 2.1 开发 Web 服务。
我有一个包含所有像素值(灰度)、宽度、高度的字节数组。我想从这些参数创建一个位图。
有我的代码(来自一个有效的 .Net Framework 4 项目):
public FileResult PostSealCryptItem(Byte[] matrix, int width, int height)
{
Bitmap bmp = new Bitmap(width, height, System.Drawing.Imaging.PixelFormat.Format24bppRgb);
for (int y = 0; y < height; y++)
for (int x = 0; x < width; x++)
bmp.SetPixel(x, y, Color.FromArgb(ToArgb(matrix, x, y)));
Byte[] data = BitmapToByteArray(bmp);
FileContentResult result = new FileContentResult(data , "image/png");
return result;
}
Run Code Online (Sandbox Code Playgroud)
但是在 .NET Core 中,我遇到了错误:
找不到类型或命名空间名称“位图”(您是否缺少 using 指令或程序集引用?)
我尝试添加对 System.Drawing 的引用,但没有奏效。
安装 Nuget 包 System.Drawing.Common
它不再包含在 .net core 中,必须手动添加。
归档时间: |
|
查看次数: |
5277 次 |
最近记录: |