Text -> pic?

L

Lasse Edsvik

Hello

I was wondering if you guys could show me a short simple example how to get
a known text saved to file.jpg with a font and size?

Im using C#
TIA
/Lasse
 
S

Scott Allen

Hi Lasse:

You'll want to create a new Bitmap class from System.Drawing, and then
use a Graphics instance to draw into the Bitmap, which you can then
save.

This would look approximately like:

Bitmap drawing = new Bitmap(320, 200, PixelFormat.Format32bppArgb);
Graphics graphics = Graphics.FromImage(drawing);
graphics.DrawString("Hello" , font, brush, x, y);
drawing.Save("hello.jpg", ImageFormat.Jpeg);


And don't forget to Dispose both Graphics and Bitmap objects.

HTH,
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top