我正在开发一个基本的Web服务。用户发送一个base 64字符串,服务必须返回一个图像。
我有这门课:
public class myImage
{
public Byte[] Matrix { get; set; }
public int Width { get; set; }
public int Height { get; set; }
}
矩阵是一个字节数组,包含灰度中的像素值。
我看到了很多话题(比如
this one
或
this one
)关于将字节数组转换为图像,但它不适用于我。我添加了对System.Drawing的引用,但有一个错误:
在命名空间“System.Drawing”中找不到类型名“Image”。此类型已转发到程序集“system.drawing.common,version=0.0.0.0,culture=neutral,publicKeyToken=cc7b13ffcd2dd51”,请考虑添加对该程序集的引用。
我看到我必须返回
FileResult
但如果我不能使用,就无法创建结果
System.Drawing.Image
:
[HttpPost]
[Route("CreateImage")]
public FileResult PostSealCryptItem([FromBody]String base64)
{
MyImage myImg = createImg(base64);
FileResult result = ?;
return result;
}
如何创建
文件过滤
从字节数组?