Results 1 to 8 of 8

Thread: [RESOLVED] Icon -> ByteArray -> Icon

Threaded View

  1. #1

    Thread Starter
    Fanatic Member simonm's Avatar
    Join Date
    Sep 2000
    Location
    Devon, England
    Posts
    796

    [RESOLVED] Icon -> ByteArray -> Icon

    I need to store and retrieve icons in my database (SQL Server 2000, Image field). I have a function to convert the icon to a byte array so it can be stored in the database:
    VB Code:
    1. Public Function GetByteArrayFromIcon(ByVal icoSource As Icon) As Byte()
    2.     Dim msIcon As System.IO.MemoryStream
    3.  
    4.     msIcon = New System.IO.MemoryStream
    5.  
    6.     icoSource.Save(msIcon)
    7.  
    8.     Return msIcon.ToArray
    9. End Function
    But I'm having trouble converting a byte array back into an icon. I've got this so far...but how do I complete it?
    VB Code:
    1. Public Function GetIconFromByteArray(ByVal bytSource As Byte()) As Icon
    2.     Dim msIcon As System.IO.MemoryStream
    3.  
    4.     msIcon = New System.IO.MemoryStream(bytSource)
    5.  
    6.     Return ?????
    7. End Function
    Last edited by simonm; Jan 3rd, 2007 at 06:40 AM.
    Everything I say is either loose interpretation of dubious facts or idle speculation rooted in irrational sentiment.

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