Example usage for android.graphics Canvas drawPaint

List of usage examples for android.graphics Canvas drawPaint

Introduction

In this page you can find the example usage for android.graphics Canvas drawPaint.

Prototype

public void drawPaint(@NonNull Paint paint) 

Source Link

Document

Fill the entire canvas' bitmap (restricted to the current clip) with the specified paint.

Usage

From source file:com.guodong.sun.guodong.widget.ZoomImageView.java

@Override
protected void onDraw(Canvas canvas) {
    if (getDrawable() == null) {
        return; // couldn't resolve the URI
    }/* ww w.  j ava 2  s . c o m*/

    if (mState == STATE_TRANSFORM_IN || mState == STATE_TRANSFORM_OUT) {
        if (mTransformStart) {
            initTransform();
        }
        if (mTransfrom == null) {
            super.onDraw(canvas);
            return;
        }

        if (mTransformStart) {
            if (mState == STATE_TRANSFORM_IN) {
                mTransfrom.initStartIn();
            } else {
                mTransfrom.initStartOut();
            }
        }

        if (mTransformStart) {
            Log.d("Dean", "mTransfrom.startScale:" + mTransfrom.startScale);
            Log.d("Dean", "mTransfrom.startScale:" + mTransfrom.endScale);
            Log.d("Dean", "mTransfrom.scale:" + mTransfrom.scale);
            Log.d("Dean", "mTransfrom.startRect:" + mTransfrom.startRect.toString());
            Log.d("Dean", "mTransfrom.endRect:" + mTransfrom.endRect.toString());
            Log.d("Dean", "mTransfrom.rect:" + mTransfrom.rect.toString());
        }

        mPaint.setAlpha(mBgAlpha);
        canvas.drawPaint(mPaint);

        int saveCount = canvas.getSaveCount();
        canvas.save();
        // ?Matrix
        getBmpMatrix();
        canvas.translate(mTransfrom.rect.left, mTransfrom.rect.top);
        canvas.clipRect(0, 0, mTransfrom.rect.width, mTransfrom.rect.height);
        canvas.concat(mSmoothMatrix);
        getDrawable().draw(canvas);
        canvas.restoreToCount(saveCount);
        if (mTransformStart) {
            mTransformStart = false;
            startTransform(mState);
        }
    } else {
        //Transform In???Activity??
        mPaint.setAlpha(255);
        canvas.drawPaint(mPaint);
        super.onDraw(canvas);
    }
}