Android中Bitmap和Drawable
一、相关概念
1、Drawable就是一个可画的对象,其可能是一张位图(BitmapDrawable),也可能是一个图形(ShapeDrawable),还有可能是一个图层(LayerDrawable),我们根据画图的需求,创建相应的可画对象
2、Canvas画布,绘图的目的区域,用于绘图
3、Bitmap位图,用于图的处理
4、Matrix矩阵
二、Bitmap
1、从资源中获取Bitmap
View Code
Resources res = getResources();
Bitmap bmp = BitmapFactory.decodeResource(res, R.drawable.icon);
2、Bitmap → byte[]
3、byte[] → Bitmap
4、Bitmap缩放
5、将Drawable转化为Bitmap
6、获得圆角图片
7、获得带倒影的图片
三、Drawable
1、Bitmap转换成Drawable
2、Drawable缩放