Saving Text and graphic into Same file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Helllo
I would like to creat a file that contains Text and graphic. Would appricite if anyone could tell me how i can do that. .For example I know I can use richTextBox1.SaveFile but don't know who to add graphics to my saved file
Thanks so muc
A
 
Hi Al,

It can be done as an own defined binary file where you set your own
parameters in.

But in my opinion that is a very unsufficient way and takes a lot of time to
figure it out how.

You can also take a database for that, the newer databases support as well
text storing as image storing in the same tablerow.

Just my thoughts.

Cor
 
Hi Cor
It is currently in Database but I need to creata file for faxing. That is why i need way to put text and graphic together in a file
Thank
Al
 
Hi Al,

I always forget that I did make a sample a for that a short while ago.

I hope this helps?

Cor

\\\
Private abyt() As Byte
Private fo As New OpenFileDialog
Private sf As New SaveFileDialog
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button1.Click
'Reading a picture and put it in a bytearray
If fo.ShowDialog = DialogResult.OK Then
Dim fs As New IO.FileStream(fo.FileName, _
IO.FileMode.Open)
Dim br As New IO.BinaryReader(fs)
abyt = br.ReadBytes(CInt(fs.Length))
br.Close()
'just to show the sample without a fileread error
Dim ms As New IO.MemoryStream(abyt)
Me.PictureBox1.Image = Image.FromStream(ms)
End If
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Button2.Click
'writing a picture from a bytearray
If sf.ShowDialog = DialogResult.OK Then
Dim fs As New IO.FileStream(sf.FileName, _
IO.FileMode.CreateNew)
Dim bw As New IO.BinaryWriter(fs)
bw.Write(abyt)
bw.Close()
End If
End Sub

Private Sub Button3_Click(ByVal sender As System.Object, ByVal _
e As System.EventArgs) Handles Button3.Click
'writing a bytearray to a dataset
Dim ds As New DataSet
ds.Tables.Add(New DataTable("Photo"))
ds.Tables(0).Columns.Add(New DataColumn("Sample"))
ds.Tables(0).Columns(0).DataType =
System.Type.GetType("System.Byte[]")
ds.Tables(0).Rows.Add(ds.Tables(0).NewRow)
ds.Tables(0).Rows(0)(0) = abyt
Dim sf As New SaveFileDialog
If sf.ShowDialog = DialogResult.OK Then
ds.WriteXml(sf.FileName, XmlWriteMode.WriteSchema)
End If
End Sub

Private Sub Button4_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button4.Click
'reading a picture from a dataset
Dim ds As New DataSet
If fo.ShowDialog = DialogResult.OK Then
ds.ReadXml(fo.FileName)
End If
abyt = CType(ds.Tables(0).Rows(0)(0), Byte())
Dim ms As New IO.MemoryStream(abyt)
Me.PictureBox1.Image = Image.FromStream(ms)
End Sub
 
To explain it more, this makes an XML dataset the textfield you have to add
yourself

To be honest, I never thought on that this could be a solution for a
combined text picture file untill you wrote that you already had a dataset.

Cor
 
Back
Top