我使用以下方法创建一些图像。
我的问题是如何在.cshtml页面(MVC3)中显示它?我必须使用哪种Razor 语法?
public FileContentResult DisplayFont()
{
int fontSize = 12;
string fontName = "Arial";
System.Drawing.Font rectangleFont = new System.Drawing.Font(fontName, fontSize, FontStyle.Bold);
int height = 150;
int width = 250;
Bitmap bitmap = new Bitmap(width, height, PixelFormat.Format24bppRgb);
Graphics g = Graphics.FromImage(bitmap);
g.SmoothingMode = SmoothingMode.AntiAlias;
Color backgroundColor = Color.White;
g.Clear(backgroundColor);
g.DrawString(fontName, rectangleFont,SystemBrushes.WindowText, new PointF(10, 40));
MemoryStream outputStream = new MemoryStream();
bitmap.Save(outputStream, ImageFormat.Jpeg);
byte[] byteArray = outputStream.ToArray();
g.Dispose();
bitmap.Dispose();
return new FileContentResult(byteArray, "image/jpeg");
}