byte[] flattenBitmap(Bitmap bitmap) {

        // Try go guesstimate how much space the icon will take when serialized

        // to avoid unnecessary allocations/copies during the write.

        int size = bitmap.getWidth() * bitmap.getHeight() * 4;

        ByteArrayOutputStream out = new ByteArrayOutputStream(size);

        try {

            bitmap.compress(Bitmap.CompressFormat.PNG, 100, out);

            out.flush();

            out.close();

            return out.toByteArray();

        } catch (IOException e) {

            Log.w("Favorite", "Could not write icon");

            return null;

        }

    }

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. [转] android 中 任务、进程和线程的区别
  2. 最新消息:Android 4.0新增功能
  3. Android绘制基础及手写绘制实例
  4. android之后台线程(UI与线程交互)
  5. 3g android4 移植 飞思卡尔i.MX 6Quad An
  6. Looper中的消息队列处理机制
  7. 实训心得___刘晓刚
  8. AndroidAPP开发者注意了,安卓开发将迎来
  9. android中关于AsyncTask的学习
  10. 【Android教程】Android用户系统管理