我已经在嵌入HTML的Base64图像,我怎么能解码这个使用C#或VB.net。解码Base64图像
回答
google.com>的base64图像解码C#>http://www.eggheadcafe.com/community/aspnet/2/39033/convert-base64-string-to-image.aspx
Byte[] bitmapData = Convert.FromBase64String(FixBase64ForImage(ImageText));
System.IO.MemoryStream streamBitmap = new System.IO.MemoryStream(bitmapData);
Bitmap bitImage = new Bitmap((Bitmap)Image.FromStream(streamBitmap));
public string FixBase64ForImage(string Image) {
System.Text.StringBuilder sbText = new System.Text.StringBuilder(Image,Image.Length);
sbText.Replace("\r\n", String.Empty); sbText.Replace(" ", String.Empty);
return sbText.ToString();
}
好的答案,但错过了该链接的一个重要功能:`公共字符串FixBase64ForImage(字符串图像){System.Text.StringBuilder sbText =新的System.Text.StringBuilder(图像Image.Length); sbText.Replace(“\ r \ n”,String.Empty); sbText.Replace(“”,String.Empty); return sbText.ToString(); }` – JcFx 2012-12-17 18:24:43
使用Convert.FromBase64String
得到代表图像二进制的byte[]
。
然后,您可以将生成的byte[]
保存到文件中。
将嵌入的图像刮到一个字符串中。使用WebClient
可能是您最好的选择。使用Convert.FromBase64String()
将base64字符串转换为字节数组。使用MemoryStream
和Image.FromStream()
重构图像对象。
在上面的例子中存储器流仍未布置这可能会导致存储器leak.So基本思想是皈依到base64string到的ByteArray []到图像或位图图像创建可通过MemoryStream的 来为你做一个很好的例子 尝试此链接http://www.dailycoding.com/Posts/convert_image_to_base64_string_and_base64_string_to_image.aspx
- 1. Python解码Base64 qUncompress图像
- 2. ASP经典的base64图像解码器
- 3. 解码base64图像并上传
- 4. base64解码图像不下载
- 5. coldfusion拒绝解码base64图像
- 6. 我如何解码base64图像?
- 7. 将base64数据解码为图像
- 8. 带有base64中断图像的编码/解码图像
- 9. Base64编码图像
- 10. Base64编码图像
- 11. PHP的base64解码功能是无法解码的base64图像串
- 12. PHP Alter Base64编码图像
- 13. base64编码图像大小
- 14. PostgreSQL的Base64编码图像进行解码的问题
- 15. Android base64解码/编码图像字符串
- 16. 如何解码由window.btoa使用Java编码的base64图像
- 17. 如何解码使用base64编码的图像字符串
- 18. 对Base64 Ionic的图像进行编码和解码
- 19. 将Base64编码图像加密为另一个有效的Base64编码图像
- 20. 无法从base64解码的意图打开图像
- 21. 如何将base64解码图像添加到开发图中?
- 22. C#图像base64
- 23. Base64 SVG图像
- 24. 如何解码Base64?
- 25. 当从base64解码图像时需要EOFILE吗?
- 26. 如何将base64解码的png图像写入文件?
- 27. 解码base64中的损坏数据以Qt中的图像
- 28. Base64图像解码问题 - 空.png文件?
- 29. Node.js Base64图像解码和写入文件
- 30. 无法在FirebaseListAdapter中显示base64解码图像
http://stackoverflow.com/questions/1915898/base64-decode-in-c-or-java – 2011-02-22 20:16:47