I'm developing a basic webservice. User send a base 64 string and the serve must return an image.
I have this class :
public class myImage
{
public Byte[] Matrix { get; set; }
public int Width { get; set; }
public int Height { get; set; }
}
The Matrix is a byte array containing the pixel value in greyscale.
I saw a lot of topic (like this one or this one) about converting byte array to Image, but it did not work for me. I added reference to System.Drawing, but I have the error :
The type name 'Image' could not be found in the namespace 'System.Drawing'. This type has been forwarded to assembly 'System.Drawing.Common, Version=0.0.0.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' Consider adding a reference to that assembly.
I saw that I have to return a FileResult
but I can't create the result if I can not use System.Drawing.Image
:
[HttpPost]
[Route("CreateImage")]
public FileResult PostSealCryptItem([FromBody]String base64)
{
MyImage myImg = createImg(base64);
FileResult result = ?;
return result;
}
How can I create a FileResult
from my byte array ?