adding font to an image

eramgarden

Well-known member
Joined
Mar 8, 2004
Messages
579
Im converting a TIF image to JPG and I get this error on the bold line:

Public Sub IP()

Dim strFileToConvert As String
strFileToConvert = "C:\source1.Tif"
Dim b As New Bitmap(strFileToConvert)
Dim g As Graphics()

Dim bold As Font = New Font("Times New Roman", 10, FontStyle.Bold)

g.DrawString("This is a test", bold, Brushes.Black, 10.0F, 10.0F)

b.Save(strFileToConvert + ".jpeg", System.Drawing.Imaging.ImageFormat.Jpeg)

End Sub

how can I add the font? I tried : Dim g As New Graphics() but that didnt work either...

Thx
 
You are declaring an array of Graphics objects. Another thing is that you need to set the Graphics object to the image. Declare it like this:
Code:
    Dim g As Graphics = Graphics.FromImage(b)
 
Last edited by a moderator:
Back
Top