美文网首页技术文章阅读笔记
canvas, drawable, bitmap之间的关系

canvas, drawable, bitmap之间的关系

作者: ahking17 | 来源:发表于2017-02-03 11:55 被阅读50次
    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.------------

    相关文章

      网友评论

        本文标题:canvas, drawable, bitmap之间的关系

        本文链接:https://www.haomeiwen.com/subject/lokdittx.html