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;

        }


   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;
    }

更多相关文章

  1. android activity 基类 通用方法
  2. Android(安卓)SharedPreferences使用
  3. android 复制字符串到剪贴板
  4. android 获取通讯模块制式类型
  5. android string.xml %问题。
  6. Android(安卓)使用正则表达式
  7. 【android】利用Yahoo API完成天气预报
  8. Android(安卓)ToastUtil
  9. Android(安卓)SharedPreferences使用

随机推荐

  1. android 打开另外一个apk并且传值过去
  2. Activity之间的通信
  3. 指纹识别分析之enroll流程
  4. android点击空白处隐藏键盘(亲测)
  5. Android搜索关键字变色
  6. 使用PhoneGap调用Camera (android)
  7. 使用googleMap 需要获取的apikey方法
  8. android倒计时广告进度条
  9. 【Android(安卓)开发教程】使用Intent发
  10. Android 隐藏及切换显示键盘