本文整理汇总了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);
}
}
示例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);
}
}
示例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));
}
}
示例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);
}
示例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);
}
}
示例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));
}
}
示例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);
}
示例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);
}
}
示例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));
}
}
示例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);
}
示例11: configureBounds
import android.graphics.Canvas; //导入方法依赖的package包/类
private void configureBounds(Canvas canvas) {
Matrix canvasMatrix = canvas.getMatrix();
applyScaleToRadii(canvasMatrix);
mBounds.set(mBitmapRect);
}
示例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);
}
}
}