Jump to content
Xtreme .Net Talk

Recommended Posts

  • *Experts*
Posted

First create a Bitmap object from the file, create graphics from the image and use the DrawString method of the graphics to draw the text. Then simply use the Save method of the Bitmap object.

'First load the image
Dim b As New Bitmap("path")
'get the graphics object from the image so you can draw onto the image
Dim gr As Graphics = Graphics.FromImage(b)
'draw text
gr.DrawString("text", Me.Font, New SolidBrush(Color.Red), 10, 10)
'save the image
b.Save("path")
'dispose
gr.Dispose()
b.Dispose()

Posted (edited)

edit: ah i c, i was supposed to put it in there, sry...

 

gr.DrawString("text", New Font(arguments), New SolidBrush(Color.Red), 10, 10)

Edited by decrypt
  • *Experts*
Posted

If you look closer at the arguments the constructor accepts you will see that it takes much more of them if you want to build a new font without a base one....

[edit]You edited your post so Im not sure where you are with this problem now :)[/edit]

  • *Experts*
Posted

The error is there becuase if you read the required argument type for the combination you showed you will see that it accepts a Font object that will be used as a base for the one you are creating. It doesn't accept a string. The try this and see if its what you want:

 New Font("Times New Roman", 12) '12 is the font's size

  • Leaders
Posted

darn beaten to the post , was just gonna put this ...

you must specify the Font size

        gr.DrawString(TextBox1.Text, New Font("Times New Roman", 12, FontStyle.Regular), New SolidBrush(Color.FromArgb(0, 40, 40)), 10, 10)

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...