Android Base64字符串转换成图片
16lz
2021-01-23
转自:http://blog.sina.com.cn/s/blog_638686c601013xh0.html
public Bitmap stringtoBitmap(String string){
//将字符串转换成Bitmap类型
Bitmap bitmap=null;
try {
byte[]bitmapArray;
bitmapArray=Base64.decode(string, Base64.DEFAULT);
bitmap=BitmapFactory.decodeByteArray(bitmapArray, 0, bitmapArray.length);
} catch (Exception e) {
e.printStackTrace();
}
return bitmap;
}
public String bitmaptoString(Bitmap bitmap){
//将Bitmap转换成字符串
String string=null;
ByteArrayOutputStream bStream=new ByteArrayOutputStream();
bitmap.compress(CompressFormat.PNG,100,bStream);
byte[]bytes=bStream.toByteArray();
string=Base64.encodeToString(bytes,Base64.DEFAULT);
return string;
}
更多相关文章
- android 判断联网类型
- 「Android问卷调查类型页面及逻辑实现」RadioButton、CheckBox、
- Android的4种文件类型Java,class,dex,apk
- FregClient进程,创建一个BpFregService类型的代理对象
- Android Studio如何轻松整理字符串到string.xml中
- android获取网络类型
- JNI基本数据类型转换
- Android实现DES对字符串加密
- Android 判断网络是否可用以及网络类型(WIFI,2G,3G,4G)