canvas, drawable, bitmap之间的关系
2017-02-03 本文已影响50人
ahking17
In short
Bitmap - is a representation of image in byte form.
Bitmap就是用一个字节数组表示一张图片.
public final class Bitmap implements Parcelable {
/**
* Backing buffer for the Bitmap.
*/
private byte[] mBuffer;
}
Drawable - is an abstraction of anything which can be drawn. (image, gradients, circles, shape, 9 patch, state, layers etc)
Drawable就是可画在屏幕上的任何类型的图形,是一个抽象的代码表示 eg, 图片或是shape.
Canvas - is a place, where you draw. Like real life Canvas. Where you can draw anything.
Canvas 就是一个画布, 可以在上面画任何图形.
canvas.drawRect(leftMargin, 0,
leftMargin + mBarDrawWidth, getHeight(), mFillPaint);
canvas.drawLine(lineX, 0, lineX, getHeight(), mStrokePaint);
canvas.drawBitmap(bitmap, null, rectSrc, paint);
-------DONE.------------