當前位置: 首頁>>代碼示例>>Java>>正文


Java Canvas.getMatrix方法代碼示例

本文整理匯總了Java中android.graphics.Canvas.getMatrix方法的典型用法代碼示例。如果您正苦於以下問題:Java Canvas.getMatrix方法的具體用法?Java Canvas.getMatrix怎麽用?Java Canvas.getMatrix使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在android.graphics.Canvas的用法示例。


在下文中一共展示了Canvas.getMatrix方法的12個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: configureBounds

import android.graphics.Canvas; //導入方法依賴的package包/類
private void configureBounds(Canvas canvas) {
    Rect clipBounds = canvas.getClipBounds();
    Matrix canvasMatrix = canvas.getMatrix();
    if (ScaleType.CENTER == this.mScaleType) {
        this.mBounds.set(clipBounds);
    } else if (ScaleType.CENTER_CROP == this.mScaleType) {
        applyScaleToRadii(canvasMatrix);
        this.mBounds.set(clipBounds);
    } else if (ScaleType.FIT_XY == this.mScaleType) {
        Matrix m = new Matrix();
        m.setRectToRect(this.mBitmapRect, new RectF(clipBounds), ScaleToFit.FILL);
        this.mBitmapShader.setLocalMatrix(m);
        this.mBounds.set(clipBounds);
    } else if (ScaleType.FIT_START == this.mScaleType || ScaleType.FIT_END == this
            .mScaleType || ScaleType.FIT_CENTER == this.mScaleType || ScaleType
            .CENTER_INSIDE == this.mScaleType) {
        applyScaleToRadii(canvasMatrix);
        this.mBounds.set(this.mBitmapRect);
    } else if (ScaleType.MATRIX == this.mScaleType) {
        applyScaleToRadii(canvasMatrix);
        this.mBounds.set(this.mBitmapRect);
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:24,代碼來源:SelectableRoundedImageView.java

示例2: configureBounds

import android.graphics.Canvas; //導入方法依賴的package包/類
private void configureBounds(Canvas canvas) {
	// I have discovered a truly marvelous explanation of this,
	// which this comment space is too narrow to contain. :)
	// If you want to understand what's going on here,
	// See http://www.joooooooooonhokim.com/?p=289
	Rect clipBounds = canvas.getClipBounds();
	Matrix canvasMatrix = canvas.getMatrix();

	if (ScaleType.CENTER == mmScaleType) {
		mmBounds.set(clipBounds);
	} else if (ScaleType.CENTER_CROP == mmScaleType) {
		applyScaleToRadii(canvasMatrix);
		mmBounds.set(clipBounds);
	} else if (ScaleType.FIT_XY == mmScaleType) {
		Matrix m = new Matrix();
		m.setRectToRect(mmBitmapRect, new RectF(clipBounds), Matrix.ScaleToFit.FILL);
		mmBitmapShader.setLocalMatrix(m);
		mmBounds.set(clipBounds);
	} else if (ScaleType.FIT_START == mmScaleType || ScaleType.FIT_END == mmScaleType
			|| ScaleType.FIT_CENTER == mmScaleType || ScaleType.CENTER_INSIDE == mmScaleType) {
		applyScaleToRadii(canvasMatrix);
		mmBounds.set(mmBitmapRect);
	} else if (ScaleType.MATRIX == mmScaleType) {
		applyScaleToRadii(canvasMatrix);
		mmBounds.set(mmBitmapRect);
	}
}
 
開發者ID:MobClub,項目名稱:BBSSDK-for-Android,代碼行數:28,代碼來源:SelectableRoundedImageView.java

示例3: adjustCanvasForBorder

import android.graphics.Canvas; //導入方法依賴的package包/類
private void adjustCanvasForBorder(Canvas canvas) {
	Matrix canvasMatrix = canvas.getMatrix();
	final float[] values = new float[9];
	canvasMatrix.getValues(values);

	final float scaleFactorX = values[0];
	final float scaleFactorY = values[4];
	final float translateX = values[2];
	final float translateY = values[5];

	final float newScaleX = mmBounds.width()
			/ (mmBounds.width() + mmBorderWidth + mmBorderWidth);
	final float newScaleY = mmBounds.height()
			/ (mmBounds.height() + mmBorderWidth + mmBorderWidth);

	canvas.scale(newScaleX, newScaleY);
	if (ScaleType.FIT_START == mmScaleType || ScaleType.FIT_END == mmScaleType
			|| ScaleType.FIT_XY == mmScaleType || ScaleType.FIT_CENTER == mmScaleType
			|| ScaleType.CENTER_INSIDE == mmScaleType || ScaleType.MATRIX == mmScaleType) {
		canvas.translate(mmBorderWidth, mmBorderWidth);
	} else if (ScaleType.CENTER == mmScaleType || ScaleType.CENTER_CROP == mmScaleType) {
		// First, make translate values to 0
		canvas.translate(
				-translateX / (newScaleX * scaleFactorX),
				-translateY / (newScaleY * scaleFactorY));
		// Then, set the final translate values.
		canvas.translate(-(mmBounds.left - mmBorderWidth), -(mmBounds.top - mmBorderWidth));
	}
}
 
開發者ID:MobClub,項目名稱:BBSSDK-for-Android,代碼行數:30,代碼來源:SelectableRoundedImageView.java

示例4: adjustBorderWidthAndBorderBounds

import android.graphics.Canvas; //導入方法依賴的package包/類
private void adjustBorderWidthAndBorderBounds(Canvas canvas) {
	Matrix canvasMatrix = canvas.getMatrix();
	final float[] values = new float[9];
	canvasMatrix.getValues(values);

	final float scaleFactor = values[0];

	float viewWidth = mmBounds.width() * scaleFactor;
	mmBorderWidth = (mmBorderWidth * mmBounds.width()) / (viewWidth - (2 * mmBorderWidth));
	mmBorderPaint.setStrokeWidth(mmBorderWidth);

	mmBorderBounds.set(mmBounds);
	mmBorderBounds.inset(-mmBorderWidth / 2, -mmBorderWidth / 2);
}
 
開發者ID:MobClub,項目名稱:BBSSDK-for-Android,代碼行數:15,代碼來源:SelectableRoundedImageView.java

示例5: configureBounds

import android.graphics.Canvas; //導入方法依賴的package包/類
private void configureBounds(Canvas canvas) {
    // I have discovered a truly marvelous explanation of this,
    // which this comment space is too narrow to contain. :)
    // If you want to understand what's going on here,
    // See http://www.joooooooooonhokim.com/?p=289
    Rect clipBounds = canvas.getClipBounds();
    Matrix canvasMatrix = canvas.getMatrix();

    if (ScaleType.CENTER == mScaleType) {
        mBounds.set(clipBounds);
    } else if (ScaleType.CENTER_CROP == mScaleType) {
        applyScaleToRadii(canvasMatrix);
        mBounds.set(clipBounds);
    } else if (ScaleType.FIT_XY == mScaleType) {
        Matrix m = new Matrix();
        m.setRectToRect(mBitmapRect, new RectF(clipBounds), Matrix.ScaleToFit.FILL);
        mBitmapShader.setLocalMatrix(m);
        mBounds.set(clipBounds);
    } else if (ScaleType.FIT_START == mScaleType || ScaleType.FIT_END == mScaleType
            || ScaleType.FIT_CENTER == mScaleType || ScaleType.CENTER_INSIDE == mScaleType) {
        applyScaleToRadii(canvasMatrix);
        mBounds.set(mBitmapRect);
    } else if (ScaleType.MATRIX == mScaleType) {
        applyScaleToRadii(canvasMatrix);
        mBounds.set(mBitmapRect);
    }
}
 
開發者ID:PacktPublishing,項目名稱:Expert-Android-Programming,代碼行數:28,代碼來源:SelectableRoundedImageView.java

示例6: adjustCanvasForBorder

import android.graphics.Canvas; //導入方法依賴的package包/類
private void adjustCanvasForBorder(Canvas canvas) {
    Matrix canvasMatrix = canvas.getMatrix();
    final float[] values = new float[9];
    canvasMatrix.getValues(values);

    final float scaleFactorX = values[0];
    final float scaleFactorY = values[4];
    final float translateX = values[2];
    final float translateY = values[5];

    final float newScaleX = mBounds.width()
            / (mBounds.width() + mBorderWidth + mBorderWidth);
    final float newScaleY = mBounds.height()
            / (mBounds.height() + mBorderWidth + mBorderWidth);

    canvas.scale(newScaleX, newScaleY);
    if (ScaleType.FIT_START == mScaleType || ScaleType.FIT_END == mScaleType
            || ScaleType.FIT_XY == mScaleType || ScaleType.FIT_CENTER == mScaleType
            || ScaleType.CENTER_INSIDE == mScaleType || ScaleType.MATRIX == mScaleType) {
        canvas.translate(mBorderWidth, mBorderWidth);
    } else if (ScaleType.CENTER == mScaleType || ScaleType.CENTER_CROP == mScaleType) {
        // First, make translate values to 0
        canvas.translate(
                -translateX / (newScaleX * scaleFactorX),
                -translateY / (newScaleY * scaleFactorY));
        // Then, set the final translate values.
        canvas.translate(-(mBounds.left - mBorderWidth), -(mBounds.top - mBorderWidth));
    }
}
 
開發者ID:PacktPublishing,項目名稱:Expert-Android-Programming,代碼行數:30,代碼來源:SelectableRoundedImageView.java

示例7: adjustBorderWidthAndBorderBounds

import android.graphics.Canvas; //導入方法依賴的package包/類
private void adjustBorderWidthAndBorderBounds(Canvas canvas) {
    Matrix canvasMatrix = canvas.getMatrix();
    final float[] values = new float[9];
    canvasMatrix.getValues(values);

    final float scaleFactor = values[0];

    float viewWidth = mBounds.width() * scaleFactor;
    mBorderWidth = (mBorderWidth * mBounds.width()) / (viewWidth - (2 * mBorderWidth));
    mBorderPaint.setStrokeWidth(mBorderWidth);

    mBorderBounds.set(mBounds);
    mBorderBounds.inset(-mBorderWidth / 2, -mBorderWidth / 2);
}
 
開發者ID:PacktPublishing,項目名稱:Expert-Android-Programming,代碼行數:15,代碼來源:SelectableRoundedImageView.java

示例8: configureBounds

import android.graphics.Canvas; //導入方法依賴的package包/類
private void configureBounds(Canvas canvas) {
    // I have discovered a truly marvelous explanation of this,
    // which this comment space is too narrow to contain. :)
    // If you want to understand what's going on here,
    // See http://www.joooooooooonhokim.com/?p=289
    Rect clipBounds = canvas.getClipBounds();
    Matrix canvasMatrix = canvas.getMatrix();

    if (ScaleType.CENTER == mScaleType) {
        mBounds.set(clipBounds);
    } else if (ScaleType.CENTER_CROP == mScaleType) {
        applyScaleToRadii(canvasMatrix);
        mBounds.set(clipBounds);
    } else if (ScaleType.FIT_XY == mScaleType) {
        Matrix m = new Matrix();
        m.setRectToRect(mBitmapRect, new RectF(clipBounds), Matrix.ScaleToFit.FILL);
        mBitmapShader.setLocalMatrix(m);
        mBounds.set(clipBounds);
    } else if (ScaleType.FIT_START == mScaleType || ScaleType.FIT_END == mScaleType
               || ScaleType.FIT_CENTER == mScaleType || ScaleType.CENTER_INSIDE == mScaleType) {
        applyScaleToRadii(canvasMatrix);
        mBounds.set(mBitmapRect);
    } else if (ScaleType.MATRIX == mScaleType) {
        applyScaleToRadii(canvasMatrix);
        mBounds.set(mBitmapRect);
    }
}
 
開發者ID:LanguidSheep,項目名稱:sealtalk-android-master,代碼行數:28,代碼來源:SelectableRoundedImageView.java

示例9: adjustCanvasForBorder

import android.graphics.Canvas; //導入方法依賴的package包/類
private void adjustCanvasForBorder(Canvas canvas) {
    Matrix canvasMatrix = canvas.getMatrix();
    final float[] values = new float[9];
    canvasMatrix.getValues(values);

    final float scaleFactorX = values[0];
    final float scaleFactorY = values[4];
    final float translateX = values[2];
    final float translateY = values[5];

    final float newScaleX = mBounds.width()
                            / (mBounds.width() + mBorderWidth + mBorderWidth);
    final float newScaleY = mBounds.height()
                            / (mBounds.height() + mBorderWidth + mBorderWidth);

    canvas.scale(newScaleX, newScaleY);
    if (ScaleType.FIT_START == mScaleType || ScaleType.FIT_END == mScaleType
            || ScaleType.FIT_XY == mScaleType || ScaleType.FIT_CENTER == mScaleType
            || ScaleType.CENTER_INSIDE == mScaleType || ScaleType.MATRIX == mScaleType) {
        canvas.translate(mBorderWidth, mBorderWidth);
    } else if (ScaleType.CENTER == mScaleType || ScaleType.CENTER_CROP == mScaleType) {
        // First, make translate values to 0
        canvas.translate(
            -translateX / (newScaleX * scaleFactorX),
            -translateY / (newScaleY * scaleFactorY));
        // Then, set the final translate values.
        canvas.translate(-(mBounds.left - mBorderWidth), -(mBounds.top - mBorderWidth));
    }
}
 
開發者ID:LanguidSheep,項目名稱:sealtalk-android-master,代碼行數:30,代碼來源:SelectableRoundedImageView.java

示例10: adjustBorderWidthAndBorderBounds

import android.graphics.Canvas; //導入方法依賴的package包/類
private void adjustBorderWidthAndBorderBounds(Canvas canvas) {
    Matrix canvasMatrix = canvas.getMatrix();
    final float[] values = new float[9];
    canvasMatrix.getValues(values);

    final float scaleFactor = values[0];

    float viewWidth = mBounds.width() * scaleFactor;
    mBorderWidth = (mBorderWidth * mBounds.width()) / (viewWidth - (2 * mBorderWidth));
    mBorderPaint.setStrokeWidth(mBorderWidth);

    mBorderBounds.set(mBounds);
    mBorderBounds.inset(- mBorderWidth / 2, - mBorderWidth / 2);
}
 
開發者ID:LanguidSheep,項目名稱:sealtalk-android-master,代碼行數:15,代碼來源:SelectableRoundedImageView.java

示例11: configureBounds

import android.graphics.Canvas; //導入方法依賴的package包/類
private void configureBounds(Canvas canvas) {
    Matrix canvasMatrix = canvas.getMatrix();

    applyScaleToRadii(canvasMatrix);
    mBounds.set(mBitmapRect);
}
 
開發者ID:sciage,項目名稱:FinalProject,代碼行數:7,代碼來源:RoundedImageView.java

示例12: draw

import android.graphics.Canvas; //導入方法依賴的package包/類
public void draw(Canvas canvas) {
    if (this.mDelegateDrawable != null) {
        this.mDelegateDrawable.draw(canvas);
        return;
    }
    copyBounds(this.mTmpBounds);
    if (this.mTmpBounds.width() > 0 && this.mTmpBounds.height() > 0) {
        ColorFilter colorFilter = this.mColorFilter == null ? this.mTintFilter : this.mColorFilter;
        canvas.getMatrix(this.mTmpMatrix);
        this.mTmpMatrix.getValues(this.mTmpFloats);
        float canvasScaleX = Math.abs(this.mTmpFloats[0]);
        float canvasScaleY = Math.abs(this.mTmpFloats[4]);
        float canvasSkewX = Math.abs(this.mTmpFloats[1]);
        float canvasSkewY = Math.abs(this.mTmpFloats[3]);
        if (!(canvasSkewX == 0.0f && canvasSkewY == 0.0f)) {
            canvasScaleX = 1.0f;
            canvasScaleY = 1.0f;
        }
        int scaledHeight = (int) (((float) this.mTmpBounds.height()) * canvasScaleY);
        int scaledWidth = Math.min(2048, (int) (((float) this.mTmpBounds.width()) * canvasScaleX));
        scaledHeight = Math.min(2048, scaledHeight);
        if (scaledWidth > 0 && scaledHeight > 0) {
            int saveCount = canvas.save();
            canvas.translate((float) this.mTmpBounds.left, (float) this.mTmpBounds.top);
            if (needMirroring()) {
                canvas.translate((float) this.mTmpBounds.width(), 0.0f);
                canvas.scale(-1.0f, 1.0f);
            }
            this.mTmpBounds.offsetTo(0, 0);
            this.mVectorState.createCachedBitmapIfNeeded(scaledWidth, scaledHeight);
            if (!this.mAllowCaching) {
                this.mVectorState.updateCachedBitmap(scaledWidth, scaledHeight);
            } else if (!this.mVectorState.canReuseCache()) {
                this.mVectorState.updateCachedBitmap(scaledWidth, scaledHeight);
                this.mVectorState.updateCacheStates();
            }
            this.mVectorState.drawCachedBitmapWithRootAlpha(canvas, colorFilter, this.mTmpBounds);
            canvas.restoreToCount(saveCount);
        }
    }
}
 
開發者ID:JackChan1999,項目名稱:boohee_v5.6,代碼行數:42,代碼來源:VectorDrawableCompat.java


注:本文中的android.graphics.Canvas.getMatrix方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。