如何将html渲染为图像格式

时间:2011-06-13 10:19:26

标签: c# asp.net

我想将“Hello dalvir”呈现为图像格式,以便hello dalvir在图像中显示为红色。我怎么能用C#来做。

1 个答案:

答案 0 :(得分:1)

这是代码......

Font MyFont = new Font(FontFamily, Font,FontStyle.Bold, GraphicsUnit.Point);
MyGraphics = Graphics.FromImage(bmpImage);
MyGraphics.Clear(Color.FromName("Red"));
MyGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
MyGraphics.DrawString("Hello dalvir", MyFont,
                    new SolidBrush(Color.FromName("Red")), 0, 0);
MyGraphics.Flush();