android bitmap和base64之间的转换
来源:互联网 发布:部落冲突人王升级数据 编辑:程序博客网 时间:2024/06/07 13:08
- /**
- * bitmap转为base64
- * @param bitmap
- * @return
- */
- public static String bitmapToBase64(Bitmap bitmap) {
- String result = null;
- ByteArrayOutputStream baos = null;
- try {
- if (bitmap != null) {
- baos = new ByteArrayOutputStream();
- bitmap.compress(Bitmap.CompressFormat.JPEG, 100, baos);
- baos.flush();
- baos.close();
- byte[] bitmapBytes = baos.toByteArray();
- result = Base64.encodeToString(bitmapBytes, Base64.DEFAULT);
- }
- } catch (IOException e) {
- e.printStackTrace();
- } finally {
- try {
- if (baos != null) {
- baos.flush();
- baos.close();
- }
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
- return result;
- }
- /**
- * base64转为bitmap
- * @param base64Data
- * @return
- */
- public static Bitmap base64ToBitmap(String base64Data) {
- byte[] bytes = Base64.decode(base64Data, Base64.DEFAULT);
- return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
- }
0 0
- 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之间的转换
- android下Bitmap和base64之间的转换
- Bitmap和Base64之间的转换以及Base64 encode
- 【Android】Bitmap、InputStream、Drawable、byte[]、Base64之间的相互转换
- Base64字节码和Bitmap之间的转换
- android bitmap与base64字符串之间转换
- android bitmap与base64字符串之间转换
- bitmap与base64之间的转换
- Android Base64和Bitmap相互转换类
- Base64和Bitmap的相互转换
- Aandroid在ViewPager中添加ListView
- iOS让你的app一直在后台活着(运行)
- HTML事件属性
- AE自定义工具时通过hook获取axMapControl
- UNLIMITED TABLESPACE 学习
- android bitmap和base64之间的转换
- 详解 $_SERVER 函数中QUERY_STRING和REQUEST_URI区别
- MVC,MVP 和 MVVM 的图示
- 修改debian的系统时间
- HDMI-CEC Control Service
- Android ViewPager + Fragment 替换 TabActivity
- 选择排序法
- Java虚拟机(JVM)参数配置说明
- 单机版五子棋游戏项目的实现