Android的位图为Base64字符串 [英] Android Bitmap to Base64 String
本文介绍了Android的位图为Base64字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我要如何转换成一个大的位图(照片用手机的摄像头拍摄),用于将Base64字符串?
How do I convert a large Bitmap (photo taken with the phone's camera) to a Base64 String?
推荐答案
使用下面的方法的位图转换为字节数组:
use following method to convert bitmap to byte array:
ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, byteArrayOutputStream);
byte[] byteArray = byteArrayOutputStream .toByteArray();
从字节数组使用下面的方法连接code的base64
to encode base64 from byte array use following method
String encoded = Base64.encodeToString(byteArray, Base64.DEFAULT);
这篇关于Android的位图为Base64字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文