有没有什么办法可以将base64字符串转换为Android中的图像?我在通过套接字连接的服务器的xml中接收到这个base64字符串。将base64字符串转换为Android中的图像
6
A
回答
1
查看http://www.source-code.biz/base64coder/java/或其他任何将base64字符串转换为字节数组的示例,然后使用ImageIcon(byte[] imageData)
构造函数。
2
现在在Android中有Base64实用程序,但它们仅适用于Android OS 2.2。
0
无法获得任何解决方案(即使在Stackoverflow上)后,我构建了一个插件,将Base64 PNG字符串转换为我共享的文件here。 希望有所帮助。
0
如果你想的base64字符串转换为图像文件(例如.png格式等),并将其保存到某个文件夹,你可以使用此代码:
byte[] btDataFile = Base64.decode(base64Image, Base64.DEFAULT);
String fileName = YOUR_FILE_NAME + ".png";
try {
File folder = new File(context.getExternalFilesDir("") + /PathToFile);
if(!folder.exists()){
folder.mkdirs();
}
File myFile = new File(folder.getAbsolutePath(), fileName);
myFile.createNewFile();
FileOutputStream osf = new FileOutputStream(myFile);
osf.write(btDataFile);
osf.flush();
osf.close();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
并确保您已在您的清单文件中给出了以下所需权限:
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
相关问题
- 1. 将png或jpg图像转换为Android中的Base64字符串
- 2. 如何将base64字符串图像转换为android中的blob?
- 3. 将Base64字符串转换为android中的图像
- 4. 将base64字符串转换为Android中的图像
- 5. 如何在Android中将Base64 Blob字符串转换为图像?
- 6. Android - 将字符串转换为图像
- 7. 如何将图像转换为文件中的Base64字符串?
- 8. 使用Phonegap将图像转换为iOS上的Base64字符串
- 9. 将base64字符串转换为与OpenCV兼容的图像
- 10. 将图像文件转换为base64使用javascript的字符串
- 11. 将ASW S3上的.tif图像转换为base64字符串C#
- 12. 将base64字符串转换为位图的Android代码
- 13. Phonegap插件:如何将Base64字符串转换为Android中的PNG图像
- 14. 如何将图像从Picturebox(VB6中的图像)转换为字符串(Base64)?
- 15. 如何将图像转换为Base64字符串?
- 16. 使用Base64算法将图像转换为字符串
- 17. 如何将Base64字符串转换为Png图像Mvc5 C#?
- 18. JavaScript - 将数据base64字符串转换为图像
- 19. React-Native:将图像url转换为base64字符串
- 20. 如何将base64字符串转换为PIL图像对象
- 21. 将图像从ImageView转换为Base64字符串
- 22. Ionic 2 - 需要将图像从url转换为base64字符串
- 23. 如何将base64字符串转换为图像?
- 24. 使用javascript将base64字符串转换为图像
- 25. 如何将base64字符串转换为图像文件?
- 26. 将Base64字符串转换为图像文件?
- 27. NodeJS将Base64字符串转换为jpeg图像 - NodeJS或mysql
- 28. Android将位图转换为Base64字符串问题
- 29. java将inputStream转换为base64字符串
- 30. 将base64字符串转换为X509 certifcate
可能重复的[如何将图像转换为Base64字符串?](http://stackoverflow.com/questions/4830711/how-to-convert-一个图像 - 到 - 的base64〜应变G) – 2012-07-09 10:19:38