tags:

views:

25

answers:

2

Hello Everyone

I need to write some data which is string to tiff file. I am 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)
MessageBox.Show("Signature is recieved and it is saved in Signature.tiff")

ControlData is the string which is to be written to the file. I am capturing the signature from the user. This function gets the data in string format and i need to create a tiff file using the string data.

When i did in this way, signature.tiff is created but when i opened the image it is giving no preview available.

Can you tell me what is the problem or correct way of doing this?

Thanks a lot.

A: 

TIFF files are binary image files. You are writing the string to a text file. Try opening the file in Notepad to check.

You need a way to create an image in memory and save it to TIFF format.

You could use a PictureBox control. Write the string onto the PictureBox then save as a TIFF.

MarkJ
Hello Mark, Thanks for your reply I have looked at the link but it just went above my head. Is there any simpler way to do this? Instead of tiff when i used jpg file format, it gave same error. Can you help me out of this?The problem in simpler words: Data is there in string format, i have to store and display as image.Can you show me some direction to go for this?Thanks.
A: 
Dim format As StringFormat = New StringFormat()

Dim MyRect As Rectangle = New Rectangle(0, 0, 400, 400)
Dim MyGraphics As Graphics = Me.CreateGraphics()
Dim MyImg As Image = New Bitmap(MyRect.Width, MyRect.Height, MyGraphics)
Dim imageGraphics As Graphics = Graphics.FromImage(MyImg)
imageGraphics.FillRectangle(Brushes.White, MyRect)

format.Alignment = StringAlignment.Center
format.LineAlignment = StringAlignment.Center
imageGraphics.DrawString("Hello Everyone", objFont, Brushes.Black, RectangleF.op_Implicit(MyRect))

MyGraphics.DrawImage(MyImg, MyRect)

MyImg.Save(filename)

Just see this may help you all for converting text string to image. Thanks.