"Dragon" <ba***********@hotmail.com> wrote in message
news:O%******************@TK2MSFTNGP12.phx.gbl...
Hi,
Does anyone know of any examples for writing text into images? I have a
program that collects some system information and I would like to write
that text into a BMP or JPG file.
Thank you.
Tested this and it works ;)
Dim img As System.Drawing.Bitmap
Dim canvas As System.Drawing.Graphics
' Create a blank image.
img = New System.Drawing.Bitmap( _
200, _
200, _
System.Drawing.Imaging.PixelFormat.Format32bppArgb _
)
Try
' Create the canvas.
canvas = System.Drawing.Graphics.FromImage(img)
' Paint a background.
canvas.Clear(System.Drawing.Color.White)
' Draw the "Hello World!" string.
canvas.DrawString( _
"Hello World!", _
New System.Drawing.Font("Verdana", 12), _
System.Drawing.Brushes.Black, _
10, _
10 _
)
' Save the image to disk.
img.Save( _
"C:\HelloWorld.jpg", _
System.Drawing.Imaging.ImageFormat.Jpeg _
)
img.Save( _
"C:\HelloWorld.bmp", _
System.Drawing.Imaging.ImageFormat.Bmp _
)
Finally
' Cleanup.
If Not canvas Is Nothing
canvas.Dispose()
End If
img.Dispose()
End Try
HTH,
Mythran ;)