Bitmap - 称作位图,一般位图的文件格式后缀为bmp,当然编码器也有很多如RGB565、RGB888。作为一种逐像素的显示对象执行效率高,但是缺点也很明显存储效率低。我们理解为一种存储对象比较好。
    Drawable - 作为Android平下通用的图形对象,它可以装载常用格式的图像,比如GIF、PNG、JPG,当然也支持BMP,当然还提供一些高级的可视化对象,比如渐变、图形等。

A bitmap is a Drawable. A Drawable is not necessarily a bitmap. Like all thumbs are fingers but not all fingers are thumbs.
Bitmap是Drawable . Drawable不一定是Bitmap .就像拇指是指头,但不是所有的指头都是拇指一样.

The API dictates: API规定:

Though usually not visible to the application, Drawables may take a variety of forms: 尽管通常情况下对于应用是不可见的,Drawables 可以采取很多形式:

Bitmap: the simplest Drawable, a PNG or JPEG image. Bitmap: 简单化的Drawable, PNG 或JPEG图像. 
Nine Patch: an extension to the PNG format allows it to specify information about how to stretch it and place things inside of it.
Shape: contains simple drawing commands instead of a raw bitmap, allowing it to resize better in some cases.
Layers: a compound drawable, which draws multiple underlying drawables on top of each other.
States: a compound drawable that selects one of a set of drawables based on its state.
Levels: a compound drawable that selects one of a set of drawables based on its level.
Scale: a compound drawable with a single child drawable, whose overall size is modified based on the current level.

小结:

对比项          显示清晰度      占用内存     支持缩放    支持色相色差调整      支持旋转     支持透明色       绘制速度           支持像素操作

Bitmap          相同                大                 是                是                            是                是                     慢                      是
Drawable       相同                小                 是               否                            是                 是                     快                      否

Drawable在内存占用和绘制速度这两个非常关键的点上胜过Bitmap

1)Drawable和Bitmap之间可以互相转换。Drawable占用内存远小于Bitmap。
(2)setImageDrawable使用资源文件;setImageBitmap使用bitmap图片,该图片可能是读取本地相册,或者从资源文件转换而来。
(3) public void setImageResource (int resId)占用UI thread;

ImageView iv; 
String fileName = "/data/data/com.test/aa.png; 
Bitmap bm = BitmapFactory.decodeFile(fileName); 
iv.setImageBitmap(bm); //占用内存,ie:

Bitmap image = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
imageView.setImageBitmap(image);

Bitmap image = BitmapFactory.decodeFile(imgFile.getAbsolutePath());
BitmapDrawable bitmapDrawable = new BitmapDrawable(image);
imageView.setImageDrawable(bitmapDrawable);

Drawable和Bitmap区别的更多相关文章

  1. Android Drawable和Bitmap区别

    一.相关概念 1.Drawable就是一个可画的对象,其可能是一张位图(BitmapDrawable),也可能是一个图形(ShapeDrawable),还有可能是一个图层(LayerDrawable) ...

  2. Drawable与Bitmap 自定义

    Drawable简介 Drawable是Android平下通用的图形对象,它可以装载常用格式的图像,比如GIF.PNG.JPG,当然也支持BMP.相比于View,我们并不需要去考虑如何measure. ...

  3. Android Drawable、Bitmap、byte[]之间的转换

    转自http://blog.csdn.net/june5253/article/details/7826597 1.Bitmap-->Drawable Bitmap drawable2Bitma ...

  4. 获取应用图标,Drawable 转bitmap

    获取应用图标: PackageManager p = context.getPackageManager(); Drawable draw=null; ApplicationInfo info; tr ...

  5. 简单谈谈Resource,Drawable和Bitmap之间的转换

    一直接触这些东西,还是归个类整理一下比较好. Resource -> Drawable Drawable draw1 = this.getResources().getDrawable(R.dr ...

  6. android 获取资源文件 r.drawable中的图片转换为drawable、bitmap

    1.R-Drawable Resources resources = mContext.getResources(); Drawable drawable = resources.getDrawabl ...

  7. Android -- Drawable与Bitmap测试

    Drawable                                                                                 以下这个是测试加载10 ...

  8. Drawable和Bitmap转换

    一.Bitmap转Drawable Bitmap mBitMap=getYourBitMap(); //getYourBitMap()是你获取BitMap的方法 BitmapDrawable mBit ...

  9. Drawable、Bitmap、byte[]之间的转换

    android在处理一写图片资源的时候,会进行一些类型的转换: 1 Drawable → Bitmap 的简单方法 ((BitmapDrawable)res.getDrawable(R.drawabl ...

随机推荐

  1. eclipse安装genymotion插件。

    先发个我自己压缩的genymotion和VirtualBox,下载链接:http://pan.baidu.com/s/1o7wgJiU 1.在安装genymotion之后,打开eclipse,如下图操 ...

  2. [转]as3中的SharedObject的保存路径

    SharedObject的保存路径 Windows XP 网络访问: C:\Documents and Settings\[你的用户名]\Application Data\Macromedia\Fla ...

  3. 移动手机端H5无缝间歇平滑向上滚动js代码

    在没结合css3的transform实现平滑过渡前,我都是用的jquery的animate方法,此方法在PC端基本看不出来有稍微卡顿的现象,但是在性能不高的手机上使用该方法,就会有明显的卡顿现象,不够 ...

  4. MySQL索引简述

    文章归属:http://feiyan.info/16.html,我想自己总结,但是发现此君总结的非常详细.直接搬过来了 关于MySQL索引的好处,如果正确合理设计并且使用索引的MySQL是一辆兰博基尼 ...

  5. 【noip 2004】 合并果子

    noip2016结束后的第一份代码--优先队列的练习 合并果子 原题在这里 #include <iostream> #include <queue> #include < ...

  6. 马克飞象 Markdown 使用和学习

    第三方学习网站 http://sspai.com/25137https://maxiang.io/ 使用工具:有道云笔记 https://note.youdao.com/ 新建时使用Mardown类型 ...

  7. 读书笔记 —— 《css秘密花园》

    浏览器兼容性有效性信息查询 : Can I Use? http://caniuse.com/ 自动为css添加浏览器厂商前缀 https://autoprefixer.github.io/ 在线编辑H ...

  8. Python脚本配合Linux计划任务工作

    经常遇到直接运行Python脚本没有问题,但是一放入/etc/crontab之后就歇菜的情况,总结了一下,大致需要注意以下几点: 1. 脚本首行加入#!/usr/bin/env python 2. 脚 ...

  9. 百度地图API的IP定位城市和浏览器定位(转)

    百度地图API提供了Geolocation 和 LocalCity两个服务类. 这俩API可以分别供用户在JavaScript中进行定位和城市确认. 1 本质上,Geolocation这个类是使用了支 ...

  10. alfresco category searches...

    From page 475 of the Alfresco Developer Guide- Category searches use the PATH field, but you constru ...