praveen pvs

praveen pvs

  • NA
  • 1
  • 5.2k

How to convert text to image in vb.net

Aug 16 2010 3:15 AM
Hello Every one

I need to convert text which is string to image in vb.net. I was doing in the following way

Dim OFile As System.IO.File
Dim OWrite As system.IO.TextWriter
OWrite = OFile.CreateText("Signature.tiff")
OWrite.Write(ControlData)  'ControlData is of type string
MessageBox.Show("Signature is recieved and it is saved in Signature.tiff")

signature.tiff is being created but when i opened the image nothing is seen.
Can you tell me what is wrong in this??

I even tried in the following way also

Dim BitMapObject As New Bitmap(400,400)
Dim GraphicsObject As Graphics = Graphics.FromImage(BitMapObject)
Dim objColor As Color
Dim objFont As New Font("Times New Roman", 12)
Dim objPoint As New PointF(5.0F, 5.0F)
Dim objBrushForeColor As New SolidBrush(Color.Blue)
Dim objBrushBackColor As New SolidBrush(Color.Black)
GraphicsObject.DrawString(ControlData,objFont, objBrushForeColor, objPoint)
BitMapObject.Save("Signature.tiff",Imaging.ImageFormat.Tiff)

In this case, signature.tiff is being created, when i clicked on the image to open, some junk message is being showed.
Please tell me if any problem is there.


Will this work in my case? Do i need to import anything for the above code to be worked in my system.
Please help me out.
Thanks..

Answers (2)