Base64 UTF-8到映像 [英] Base64 UTF-8 to Image
本文介绍了Base64 UTF-8到映像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
嗨
我正在尝试转换已使用UTF-8存储的Base64 gif图像.我收到一个错误参数无效",我不确定我要去哪里.
公共 功能 Base64toImage( ByVal Base64 As 字符串) As System.Drawing.Image
Dim imgSig As System.Drawing.Image
Dim MemStream As System.IO.MemoryStream = >新 System.IO.MemoryStream
Dim utf8 As UTF8Encoding = 新 UTF8Encoding( )
' 将Base64字符串转换为内存流
MemStream = 新建 System.IO.MemoryStream(utf8.GetBytes(Base64))
' 创建图片
imgSig = System.Drawing.Image.FromStream(MemStream)
MemStream.Close()
返回 imgSig
结束 功能
在此先感谢
Marco
解决方案
像utf8一样看起来像我.GetBytes不会返回有效的图像,您需要处理转换,以便结果是gif. /blockquote>
Christian Graus是正确的utf8.GetBytes没有返回有效的图像文件.它正在返回(PersistenceFormat.Base64InkSerializedFormat)我的坏:〜
我做了如何解决此问题的方法,请查看 InkCollector签名变得简单 [
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解决方案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.
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
这篇关于Base64 UTF-8到映像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文