Brian David Berman
Brian David Berman

Reputation: 7684

How to draw text onto a jpg and resave it using system.drawing in c#

Anyone have good example of how to write text onto a jpg image and resave it using System.Drawing in .NET?

Upvotes: 0

Views: 2608

Answers (3)

Josh Stodola
Josh Stodola

Reputation: 82483

Yes you can do it fairly easily...

Bitmap bmp = new Bitmap("C:\\test.jpg");
Graphics gra = Graphics.FromImage(bmp);
string text = "Hello\nWorld";

gra.DrawString(text, new Font("Verdana", 24), Brushes.Black, new PointF(0, 0));
bmp.Save("C:\\test_out.jpg");

Upvotes: 5

Grozz
Grozz

Reputation: 8425

Acquire graphics from image calling CreateGraphics(), use its Graphics.DrawString method and save it as required.

More info: http://msdn.microsoft.com/en-us/library/system.drawing.graphics.drawstring.aspx

Upvotes: 1

Related Questions