开发者

TextRenderer.DrawText() does not work on my Web application?

开发者 https://www.devze.com 2023-02-16 04:28 出处:网络
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开发者_如何学JAV

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消