Android中Bitmap, Drawable, Byte之间的转化
1. Bitmap 转化为 byte
ByteArrayOutputStream out = new ByteArrayOutputStream();
bitmap.compress(Bitmap.CompressFormat.PNG, 100, out); //100%保存
byte[] array= out.toByteArray();
2. byte转化为bitmap
final ContentResolver contentResolver = context.getContentResolver();
final PackageManager manager = context.getPackageManager();
final Cursor c = contentResolver.query(uri, null, null, null, null);
final int icon3DIndex = c.getColumnIndexOrThrow(ColumnName);
byte[] data = c.getBlob(icon3DIndex);
Bitmap bitmap = BitmapFactory.decodeByteArray(data, 0, data.length);
3. bitmap转化为Drawable
Drawable drawable = new FastBitmapDrawable(bitmap);
...
4. Drawable转化为bitmap
a. BitmapDrawable, FastBitmapDrawable直接用getBitmap
b. 其他类型的Drawable用Canvas画到一个bitmap上
Canvas canvas = new Canvas(bitmap)
drawable.draw(canvas);
Android中Bitmap, Drawable, Byte之间的转化的更多相关文章
- Android中Bitmap, Drawable, Byte,ID之间的转化
Android中Bitmap, Drawable, Byte,ID之间的转化 1. Bitmap 转化为 byte ByteArrayOutputStream out = new ByteArray ...
- Android中 Bitmap Drawable Paint的获取、转换以及使用
比如Drawable中有一系列连续的图片,img_0.png, img_1.png, img_2.png ... 如果要动态获取这些图片,通过"R.drawable.img_x"的 ...
- java中string与byte[]之间的转化分析
背景:最近接触zookeeper的java开发,由于zookeeper中传的好像都是byte[]的数据(需要进一步确认),好多情况下都需要进行转换. 1)和zookeeper原生API不同,通过zkc ...
- Android Bitmap Drawable byte[] InputStream 相互转换方法
用android处理图片的时候,由于得到的资源不一样,所以经常要在各种格式中相互转化,以下介绍了 Bitmap Drawable byte[] InputStream 之间的转换方法: import ...
- Android中的Drawable和动画
Android中Drawable是一种可以在Canvas上进行绘制抽象的概念,种类很多,常见的颜色和图片都可以是一个Drawable.Drawable有很多种,它们表示一种图像的概念,但是它们又不全是 ...
- Java中InputStream和String之间的转化
https://blog.csdn.net/lmy86263/article/details/60479350 在Java中InputStream和String之间的转化十分普遍,本文主要是总结一下转 ...
- Android中各种Drawable总结
在Android中,Drawable使用广泛,但是种类也多,基于<Android开发艺术探索>中对Drawable的讲解,总结了如下表格.
- android中Bitmap的放大和缩小的方法
android中Bitmap的放大和缩小的方法 时间 2013-06-20 19:02:34 CSDN博客原文 http://blog.csdn.net/ada168855/article/det ...
- Android Drawable、Bitmap、byte[]之间的转换
转自http://blog.csdn.net/june5253/article/details/7826597 1.Bitmap-->Drawable Bitmap drawable2Bitma ...
随机推荐
- c++ Constructor FAQ 继续
这一章的时候,才明白什么是编译器的声明只会是一个默认的构造.这也解释了为什么同一似乎没有意义的界定,如果不还声明默认构造函数的意义. Q:当编译器隐含定义了一个默认的构造函数. 答: 一个隐式声明的默 ...
- Installshield设置feature为必须选中状态,即必定安装状态
原文:Installshield设置feature为必须选中状态,即必定安装状态 上一篇: 解决卸载时残留目标文件夹的问题Installation Designer --> Organizati ...
- SQL点滴29—错误无处不在
原文:SQL点滴29-错误无处不在 我只想说以下是很基础的sql知识,但是很容易犯错.所以睁大我们的眼睛,屏住我们的呼吸,小心的检查吧! 案例1if not exists (select OrderI ...
- win7下的PHP+IIS配置,找不到php5isapi.dll的问题,版本5.4.9
原文:win7下的PHP+IIS配置,找不到php5isapi.dll的问题,版本5.4.9 问题:PHP新手配置,在官网上下载的压缩包.按网上的找的教程配置IIS时发现,在解压包里找不到php5is ...
- Android项目--Json解析
在过去的一段时间里,我希望做一个天气的应用,但是由于老版的天气接口已经不能用了.只能更新到2014年3月4日. 不过有些东西,哪来学习一下,也是可以的. 比如:http://m.weather.com ...
- beanutils中Lazy
public class LazyBean { // public static void main(String[] args) {// DynaBean dynaBean=ne ...
- Javascript多线程引擎(九)
Javascript多线程引擎(九)--垃圾回收 垃圾回收这个话题对Programer来说是非常老旧的话题, 从手动的malloc/free 到半自动的 引用计数 再到全自动的 mark-sweep ...
- Julia is a high-level, high-performance dynamic programming language for technical computing, with syntax that is familiar to users of other technical
http://julialang.org/ julia | source | downloads | docs | blog | community | teaching | publications ...
- WebService支持多平台上传文件的实现
WebService支持多平台上传文件的实现 要使用网站上传文件,在ASP.NET的范畴,我基本上能想到的有两类,一类是通过HTTP POST请求获得文件信息,另外一类是通过WebService或 ...
- C#版考题
某软件大赛C#版考题整理——[单选题] 一.单选题(10小题共20.0分) 1. 以下JavaScript代码的正确输出结果是:(). 1 2 3 4 5 6 7 8 9 <script t ...