码迷,mamicode.com
首页 > 其他好文 > 详细

Bitmap对图像进行Base64编解码

时间:2015-08-14 19:01:38      阅读:118      评论:0      收藏:0      [点我收藏+]

标签:

  1. public String bitmaptoString(Bitmap bitmap) {
  2. // 将Bitmap转换成字符串
  3. String string = null;
  4. ByteArrayOutputStream bStream = new ByteArrayOutputStream();
  5. bitmap.compress(CompressFormat.PNG, 100, bStream);
  6. byte[] bytes = bStream.toByteArray();
  7. string = Base64.encodeToString(bytes, Base64.DEFAULT);
  8. return string;
  9. }
  1. public Bitmap stringtoBitmap(String string) {
  2. // 将字符串转换成Bitmap类型
  3. Bitmap bitmap = null;
  4. try {
  5. byte[] bitmapArray;
  6. bitmapArray = Base64.decode(string, Base64.DEFAULT);
  7. bitmap = BitmapFactory.decodeByteArray(bitmapArray, 0,
  8. bitmapArray.length);
  9. } catch (Exception e) {
  10. e.printStackTrace();
  11. }
  12. return bitmap;
  13. }





Bitmap对图像进行Base64编解码

标签:

原文地址:http://www.cnblogs.com/fruitbolgs/p/4730646.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!