Base64和Bitmap的相互转换
来源:互联网 发布:手机常用的网络制式 编辑:程序博客网 时间:2024/05/29 07:36
/*
*bitmap转base64
*/
publicstatic String bitmapToBase64(Bitmap bitmap){
String result="";
ByteArrayOutputStream bos=null;
try {
if(null!=bitmap){
bos=new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.JPEG, 90, bos);//将bitmap放入字节数组流中
bos.flush();//将bos流缓存在内存中的数据全部输出,清空缓存
bos.close();
byte []bitmapByte=bos.toByteArray();
result=Base64.encodeToString(bitmapByte, Base64.DEFAULT);
}
}catch (Exception e) {
e.printStackTrace();
}finally{
if(null!=null){
try {
bos.close();
}catch (IOException e) {
e.printStackTrace();
}
}
}
return result;
}
/*
*bitmap转base64
*/
publicstatic Bitmap base64ToBitmap(String base64String){
byte[] bytes = Base64.decode(base64String, Base64.DEFAULT);
Bitmap bitmap=BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
return bitmap;
}
- Base64和Bitmap的相互转换
- Bitmap和Base64的相互转换
- Bitmap和Base64的相互转换
- Android Base64和Bitmap相互转换类
- c# bitmap和base64编码相互转换
- Base64位编码与String字符串的相互转换,Base64与Bitmap的相互转换
- 【Android】Bitmap、InputStream、Drawable、byte[]、Base64之间的相互转换
- android bitmap和base64之间的转换
- android bitmap和base64之间的转换
- android bitmap和base64之间的转换
- android bitmap和base64之间的转换
- android bitmap和base64之间的转换
- android bitmap和base64之间的转换
- android bitmap和base64之间的转换
- android bitmap和base64之间的转换
- android bitmap和base64之间的转换
- Bitmap和Base64之间的转换以及Base64 encode
- 文件和base64流的相互转换
- Git重置改动汇总
- 十分钟搞清字符集和字符编码
- JQuery实现画面的隐藏功能
- SharedPrefence 中context mode属性的意思
- nodeJs 接收上传文件
- Base64和Bitmap的相互转换
- 图片上传
- centos搭建maven私服
- mongoDB 启动与停止
- PullToRefreshListView注意事项
- 来自2016年上半年的.ISO
- java.lang.IllegalArgumentException 错误
- const用法大集合
- Unity视频播放插件(AVPro Windows Media)