Convert Binary String to Image

All,

I have a binary string that is an image in stored in a database. I am at a loss on how to convert this binary string to an image and display in an item such as picturebox using Vb.net

Thanks
LVL 1
jpadkins49Asked:
Who is Participating?
 
CodeCruiserConnect With a Mentor Commented:
If this is the binary

Inspections.FirmRepSignature

then try

Inspections.FirmRepSignature.ToArray
0
 
CodeCruiserCommented:
You can either write the bytes to a file or create a stream

IO.File.WriteAllBytes("path to picture file", bytearray)

Then
Picturebox1.Image = Image.FromFile("path of file")
0
 
CodeCruiserCommented:
Or

Dim str as New MemoryStream(bytearray)
Picturebox1.Image = Image.FromStream(str)
0
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

 
jpadkins49Author Commented:
Here is what I have written in the meantime, but I get an error on the second line stating 'Value of type system.data.linq.binary' cannot be converted to 1-dimensional array.

 
       Any help is greatly appreciated.
Dim Inspections = Context.InspectionSignatures.Single(Function(p) p.ID_PKEY = 36)
        Dim barrImg As Byte() = CType(Inspections.FirmRepSignature, Byte())
        Dim strfn As String = Convert.ToString(DateTime.Now.ToFileTime())
        Dim fs As New FileStream(strfn, FileMode.CreateNew, FileAccess.Write)
        fs.Write(barrImg, 0, barrImg.Length)
        fs.Flush()
        fs.Close()
        PictureBox1.Image = Image.FromFile(strfn)

Open in new window

0
 
jpadkins49Author Commented:
Thanks for the help. That fixed the problem. I had a temporary lapse in memory and could not figure it out.
0
 
CodeCruiserCommented:
Glad to help :-)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.