I have to render text into GDI(not GDI+) and save as image in C#.NET web application not windows application, SO for that I have chosen TextRenderer.DrawText()
, to render the text into开发者_如何学JAVA GDI, But I am getting an red lined highlight below the TextRenderer
with message if mouse over "The name 'TextRenderer' does not exist in the current context" . here my code is:
Bitmap Bit = new Bitmap(1000,500);
Graphics g = Graphics.FromImage(Bit);
g.Clear(Color.Red);
TextRenderer.DrawText(graphics, myText, new Font("Ariel", 50, FontStyle.Regular), new Point(20, 20), Color.Black, Color.Gold);
Bit.Save(pathToSaveImg + "image.png", ImageFormat.Png);
Bit.Dispose();
So PLEASE help if any Thanks.
To use TextRenderer
you need to include the line
using System.Windows.Forms;
on top of your code file and reference the System.Windows.Forms.dll
in your project.
精彩评论