Code example for Matrix

Methods: invert, mapRadius, mapRect, reset

0
            mCropObj = new CropObject(mImageBounds, mImageBounds, 0);
        } 
 
        // If display matrix doesn't exist, create it and its dependencies 
        if (mDisplayMatrix == null || mDisplayMatrixInverse == null) {
            mDisplayMatrix = new Matrix();
            mDisplayMatrix.reset();
            if (!CropDrawingUtils.setImageToScreenMatrix(mDisplayMatrix, mImageBounds, mScreenBounds,
                    mRotation)) {
                Log.w(LOGTAG, "failed to get screen matrix");
                mDisplayMatrix = null;
                return; 
            } 
            mDisplayMatrixInverse = new Matrix();
            mDisplayMatrixInverse.reset();
            if (!mDisplayMatrix.invert(mDisplayMatrixInverse)) {
                Log.w(LOGTAG, "could not invert display matrix");
                mDisplayMatrixInverse = null;
                return; 
            } 
            // Scale min side and tolerance by display matrix scale factor 
            mCropObj.setMinInnerSideSize(mDisplayMatrixInverse.mapRadius(mMinSideSize));
            mCropObj.setTouchTolerance(mDisplayMatrixInverse.mapRadius(mTouchTolerance));
        } 
 
        mScreenImageBounds.set(mImageBounds);
 
        // Draw background shadow 
        if (mDisplayMatrix.mapRect(mScreenImageBounds)) {
            int margin = (int) mDisplayMatrix.mapRadius(mShadowMargin);
            mScreenImageBounds.roundOut(mShadowBounds);
            mShadowBounds.set(mShadowBounds.left - margin, mShadowBounds.top -
                    margin, mShadowBounds.right + margin, mShadowBounds.bottom + margin);
            mShadow.setBounds(mShadowBounds);
            mShadow.draw(canvas);
        } 
 
        // Draw actual bitmap 
        canvas.drawBitmap(mBitmap, mDisplayMatrix, mPaint);
 
        mCropObj.getInnerBounds(mScreenCropBounds);
 
        if (mDisplayMatrix.mapRect(mScreenCropBounds)) {
 
            // Draw overlay shadows 
            Paint p = new Paint();
            p.setColor(mOverlayShadowColor);
            p.setStyle(Paint.Style.FILL);