I tested it and it worked like a charme with the OutputStream.
The following is specific to ASP.NET MVC. To use the common design pattern used in ASP.NET MVC, I created a new MagickImageResult.
The following is specific to ASP.NET MVC. To use the common design pattern used in ASP.NET MVC, I created a new MagickImageResult.
public class MagickImageResult : ActionResult {
public MagickImage Image { get; private set; }
public MagickImageResult(MagickImage image) {
this.Image = image;
}
public override void ExecuteResult(ControllerContext context) {
context.HttpContext.Response.ContentType = this.Image.FormatInfo.MimeType;
context.HttpContext.Response.StatusCode = (int)HttpStatusCode.OK;
this.Image.Write(context.HttpContext.Response.OutputStream);
}
}
To return an image in a MVC-Controller, use the following code:public ActionResult MyAction() {
MagickImage image = new MagickImage();
return new MagickImageResult(image);
}