Click here to Skip to main content
15,888,401 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi
I'm trying to convert a Base64 gif image which has been stored using UTF-8. I get an error "Parameter is not valid", I'm not sure where I'm going wrong.

VB
Public Function Base64toImage(ByVal Base64 As String) As System.Drawing.Image
    Dim imgSig As System.Drawing.Image
    Dim MemStream As System.IO.MemoryStream = New System.IO.MemoryStream
    Dim utf8 As UTF8Encoding = New UTF8Encoding()

    'Convert Base64 string to Memory Stream
    MemStream = New System.IO.MemoryStream(utf8.GetBytes(Base64))

    'creates image
    imgSig = System.Drawing.Image.FromStream(MemStream)

    MemStream.Close()
    Return imgSig
End Function


Thanks in Advance

Marco
Posted

Looks to me like utf8.GetBytes does not return a valid image, you'll need to handle the conversion so that the result is a gif.
 
Share this answer
 
Comments
[no name] 25-Aug-10 5:44am    
I'm not sure, but I'm using utf8.GetBytes Save and Load GIF files with InkCollector and thats working fine.
I don't know if the system.drawing.image only supports bmp or if you have to set it to GIF.
Christian Graus was correct utf8.GetBytes was not returning a valid image file. It was returning (PersistenceFormat.Base64InkSerializedFormat) My Bad:~

I did how ever resolve this matter, have a look at InkCollector Signiture Made Easy[^]

Marco
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900