Results 1 to 2 of 2

Thread: Save image file from Byte array

  1. #1

    Thread Starter
    Frenzied Member stateofidleness's Avatar
    Join Date
    Jan 2009
    Posts
    1,780

    Save image file from Byte array

    Gents,
    I have this code which saves an "Image" to a SQL Server database:

    vb.net Code:
    1. 'You have the images in the PictureBoxes, now you need to store it as a Reference Image
    2.                 'if the user has selected that option
    3.                 Dim ms2 As New MemoryStream()
    4.                 'Save the image to the MemoryStream
    5.                 DirectCast(CameraTable.Controls("camera" & z.ToString), PictureBox).Image.Save _
    6.                 (ms2, Imaging.ImageFormat.Bmp)
    7.                 Dim arrImage() As Byte = ms2.GetBuffer
    8.                 db.SaveReferenceImage(arrImage, z)

    This basically stores a long string of text in the DB such as:

    "0x0asdfwerlkjfasfalskdfjsfj.."

    I am working on a PHP site at the moment that is having trouble reading that data to display the image, so I am attempting to not only save it to the DB, but also save it as a bitmap or other file type to the actual server.

    How can I create an image file (not really picky on which file type) from the "arrImage()" data above?

  2. #2
    Frenzied Member MattP's Avatar
    Join Date
    Dec 2008
    Location
    WY
    Posts
    1,227

    Re: Save image file from Byte array

    Here's an example I wrote a while ago:

    http://www.vbforums.com/showpost.php...95&postcount=4

    The example converts the image to and from a Base64String but you should be able to easily modify it to suit your needs.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width