本文整理汇总了Java中android.graphics.Matrix.postConcat方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix.postConcat方法的具体用法?Java Matrix.postConcat怎么用?Java Matrix.postConcat使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Matrix
的用法示例。
在下文中一共展示了Matrix.postConcat方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getProperBaseMatrix
import android.graphics.Matrix; //导入方法依赖的package包/类
private void getProperBaseMatrix(RotateBitmap bitmap, Matrix matrix, boolean includeRotation) {
float viewWidth = getWidth();
float viewHeight = getHeight();
float w = bitmap.getWidth();
float h = bitmap.getHeight();
matrix.reset();
// We limit up-scaling to 3x otherwise the result may look bad if it's a small icon
float widthScale = Math.min(viewWidth / w, 3.0f);
float heightScale = Math.min(viewHeight / h, 3.0f);
float scale = Math.min(widthScale, heightScale);
if (includeRotation) {
matrix.postConcat(bitmap.getRotateMatrix());
}
matrix.postScale(scale, scale);
matrix.postTranslate((viewWidth - w * scale) / 2F, (viewHeight - h * scale) / 2F);
}
示例2: onDraw
import android.graphics.Matrix; //导入方法依赖的package包/类
@Override
public void onDraw(Canvas canvas) {
super.onDraw(canvas);
if (mIsInitialized) {
setMatrix();
Matrix localMatrix1 = new Matrix();
localMatrix1.postConcat(this.mMatrix);
Bitmap bm = getBitmap();
if (bm != null) {
canvas.drawBitmap(bm, localMatrix1, mPaintBitmap);
// draw edit frame
drawEditFrame(canvas);
}
}
}
示例3: buildTransformMatrix
import android.graphics.Matrix; //导入方法依赖的package包/类
public void buildTransformMatrix() {
originalTransformMatrix = new Matrix();
originalTransformMatrix.postScale(scaleX, scaleY, pivotX, pivotY);
originalTransformMatrix.postRotate(rotation, pivotX, pivotY);
originalTransformMatrix.postTranslate(translateX, translateY);
if (parent != null) {
originalTransformMatrix.postConcat(parent.getOriginalTransformMatrix());
}
for (GroupModel groupModel : groupModels) {
groupModel.buildTransformMatrix();
}
}
示例4: getProperBaseMatrix
import android.graphics.Matrix; //导入方法依赖的package包/类
private void getProperBaseMatrix(RotateBitmap bitmap, Matrix matrix) {
float viewWidth = getWidth();
float viewHeight = getHeight();
float w = bitmap.getWidth();
float h = bitmap.getHeight();
int rotation = bitmap.getRotation();
matrix.reset();
// We limit up-scaling to 2x otherwise the result may look bad if it's
// a small icon.
float widthScale = Math.min(viewWidth / w, 2.0f);
float heightScale = Math.min(viewHeight / h, 2.0f);
float scale = Math.min(widthScale, heightScale);
matrix.postConcat(bitmap.getRotateMatrix());
matrix.postScale(scale, scale);
matrix.postTranslate(
(viewWidth - w * scale) / 2F,
(viewHeight - h * scale) / 2F);
}
示例5: scaleAllPaths
import android.graphics.Matrix; //导入方法依赖的package包/类
public void scaleAllPaths(Matrix scaleMatrix) {
this.scaleMatrix = scaleMatrix;
finalTransformMatrix = new Matrix(originalTransformMatrix);
finalTransformMatrix.postConcat(scaleMatrix);
for (GroupModel groupModel : groupModels) {
groupModel.scaleAllPaths(scaleMatrix);
}
for (PathModel pathModel : pathModels) {
pathModel.transform(finalTransformMatrix);
}
for (ClipPathModel clipPathModel : clipPathModels) {
clipPathModel.transform(finalTransformMatrix);
}
}
示例6: pushTransform
import android.graphics.Matrix; //导入方法依赖的package包/类
private void pushTransform(Attributes atts) {
final String transform = getStringAttr("transform", atts);
boolean pushed = transform != null;
transformStack.addLast(pushed);
if (pushed) {
final Matrix matrix = parseTransform(transform);
canvas.save();
canvas.concat(matrix);
matrix.postConcat(matrixStack.getLast());
matrixStack.addLast(matrix);
}
}
示例7: doubleTap
import android.graphics.Matrix; //导入方法依赖的package包/类
/**
* 双击后放大或者缩小
*
* 将图片缩放比例缩放到nextScale指定的值.
* 但nextScale值不能大于最大缩放值不能小于fit center情况下的缩放值.
* 将双击的点尽量移动到控件中心.
*
* @param x 双击的点
* @param y 双击的点
*
* @see #calculateNextScale(float, float)
* @see #getMaxScale()
*/
private void doubleTap(float x, float y) {
if (!isReady()) {
return;
}
//获取第一层变换矩阵
Matrix innerMatrix = MathUtils.matrixTake();
getInnerMatrix(innerMatrix);
//当前总的缩放比例
float innerScale = MathUtils.getMatrixScale(innerMatrix)[0];
float outerScale = MathUtils.getMatrixScale(mOuterMatrix)[0];
float currentScale = innerScale * outerScale;
//控件大小
float displayWidth = getWidth();
float displayHeight = getHeight();
//最大放大大小
float maxScale = getMaxScale();
//接下来要放大的大小
float nextScale = calculateNextScale(innerScale, outerScale);
//如果接下来放大大于最大值或者小于fit center值,则取边界
if (nextScale > maxScale) {
nextScale = maxScale;
}
if (nextScale < innerScale) {
nextScale = innerScale;
}
//开始计算缩放动画的结果矩阵
Matrix animEnd = MathUtils.matrixTake(mOuterMatrix);
//计算还需缩放的倍数
animEnd.postScale(nextScale / currentScale, nextScale / currentScale, x, y);
//将放大点移动到控件中心
animEnd.postTranslate(displayWidth / 2f - x, displayHeight / 2f - y);
//得到放大之后的图片方框
Matrix testMatrix = MathUtils.matrixTake(innerMatrix);
testMatrix.postConcat(animEnd);
RectF testBound = MathUtils.rectFTake(0, 0, getDrawable().getIntrinsicWidth(), getDrawable().getIntrinsicHeight());
testMatrix.mapRect(testBound);
//修正位置
float postX = 0;
float postY = 0;
if (testBound.right - testBound.left < displayWidth) {
postX = displayWidth / 2f - (testBound.right + testBound.left) / 2f;
} else if (testBound.left > 0) {
postX = -testBound.left;
} else if (testBound.right < displayWidth) {
postX = displayWidth - testBound.right;
}
if (testBound.bottom - testBound.top < displayHeight) {
postY = displayHeight / 2f - (testBound.bottom + testBound.top) / 2f;
} else if (testBound.top > 0) {
postY = -testBound.top;
} else if (testBound.bottom < displayHeight) {
postY = displayHeight - testBound.bottom;
}
//应用修正位置
animEnd.postTranslate(postX, postY);
//清理当前可能正在执行的动画
cancelAllAnimator();
//启动矩阵动画
mScaleAnimator = new ScaleAnimator(mOuterMatrix, animEnd);
mScaleAnimator.start();
//清理临时变量
MathUtils.rectFGiven(testBound);
MathUtils.matrixGiven(testMatrix);
MathUtils.matrixGiven(animEnd);
MathUtils.matrixGiven(innerMatrix);
}
示例8: getUnrotatedMatrix
import android.graphics.Matrix; //导入方法依赖的package包/类
public Matrix getUnrotatedMatrix(){
Matrix unrotated = new Matrix();
getProperBaseMatrix(bitmapDisplayed, unrotated, false);
unrotated.postConcat(suppMatrix);
return unrotated;
}
示例9: join
import android.graphics.Matrix; //导入方法依赖的package包/类
public static final void join(Canvas canvas, int dimension, List<Bitmap> bitmaps, int count,
float[] size, float gapSize) {
if (bitmaps == null)
return;
// 旋转角度
float[] rotation = JoinLayout.rotation(count);
// paint
Paint paint = new Paint();
paint.setAntiAlias(true);
Matrix matrixJoin = new Matrix();
// scale as join size
matrixJoin.postScale(size[0], size[0]);
canvas.save();
// canvas.drawColor(Color.RED);
for (int index = 0; index < bitmaps.size(); index++) {
Bitmap bitmap = bitmaps.get(index);
// MATRIX
Matrix matrix = new Matrix();
// scale as destination
matrix.postScale((float) dimension / bitmap.getWidth(),
(float) dimension / bitmap.getHeight());
canvas.save();
matrix.postConcat(matrixJoin);
float[] offset = JoinLayout.offset(count, index, dimension, size);
canvas.translate(offset[0], offset[1]);
// 缩放
Bitmap newBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(),
bitmap.getHeight(), matrix, true);
// 裁剪
Bitmap bitmapOk = createMaskBitmap(newBitmap, newBitmap.getWidth(),
newBitmap.getHeight(), (int) rotation[index], gapSize);
canvas.drawBitmap(bitmapOk, 0, 0, paint);
canvas.restore();
}
canvas.restore();
}
示例10: doubleTap
import android.graphics.Matrix; //导入方法依赖的package包/类
/**
* 双击后放大或者缩小
* <p>
* 将图片缩放比例缩放到nextScale指定的值.
* 但nextScale值不能大于最大缩放值不能小于fit center情况下的缩放值.
* 将双击的点尽量移动到控件中心.
*
* @param x 双击的点
* @param y 双击的点
* @see #calculateNextScale(float, float)
* @see #getMaxScale()
*/
private void doubleTap(float x, float y) {
if (!isReady()) {
return;
}
//获取第一层变换矩阵
Matrix innerMatrix = MathUtils.matrixTake();
getInnerMatrix(innerMatrix);
//当前总的缩放比例
float innerScale = MathUtils.getMatrixScale(innerMatrix)[0];
float outerScale = MathUtils.getMatrixScale(mOuterMatrix)[0];
float currentScale = innerScale * outerScale;
//控件大小
float displayWidth = getWidth();
float displayHeight = getHeight();
//最大放大大小
float maxScale = getMaxScale();
//接下来要放大的大小
float nextScale = calculateNextScale(innerScale, outerScale);
//如果接下来放大大于最大值或者小于fit center值,则取边界
if (nextScale > maxScale) {
nextScale = maxScale;
}
if (nextScale < innerScale) {
nextScale = innerScale;
}
//开始计算缩放动画的结果矩阵
Matrix animEnd = MathUtils.matrixTake(mOuterMatrix);
//计算还需缩放的倍数
animEnd.postScale(nextScale / currentScale, nextScale / currentScale, x, y);
//将放大点移动到控件中心
animEnd.postTranslate(displayWidth / 2f - x, displayHeight / 2f - y);
//得到放大之后的图片方框
Matrix testMatrix = MathUtils.matrixTake(innerMatrix);
testMatrix.postConcat(animEnd);
RectF testBound = MathUtils.rectFTake(0, 0, getDrawable().getIntrinsicWidth(), getDrawable().getIntrinsicHeight());
testMatrix.mapRect(testBound);
//修正位置
float postX = 0;
float postY = 0;
if (testBound.right - testBound.left < displayWidth) {
postX = displayWidth / 2f - (testBound.right + testBound.left) / 2f;
} else if (testBound.left > 0) {
postX = -testBound.left;
} else if (testBound.right < displayWidth) {
postX = displayWidth - testBound.right;
}
if (testBound.bottom - testBound.top < displayHeight) {
postY = displayHeight / 2f - (testBound.bottom + testBound.top) / 2f;
} else if (testBound.top > 0) {
postY = -testBound.top;
} else if (testBound.bottom < displayHeight) {
postY = displayHeight - testBound.bottom;
}
//应用修正位置
animEnd.postTranslate(postX, postY);
//清理当前可能正在执行的动画
cancelAllAnimator();
//启动矩阵动画
mScaleAnimator = new ScaleAnimator(mOuterMatrix, animEnd);
mScaleAnimator.start();
//清理临时变量
MathUtils.rectFGiven(testBound);
MathUtils.matrixGiven(testMatrix);
MathUtils.matrixGiven(animEnd);
MathUtils.matrixGiven(innerMatrix);
}
示例11: doStroke
import android.graphics.Matrix; //导入方法依赖的package包/类
@SuppressWarnings("deprecation")
private void doStroke(Path path) {
// TODO handle degenerate subpaths properly
if (state.style.vectorEffect == VectorEffect.NonScalingStroke) {
// For non-scaling-stroke, the stroke width is not transformed along
// with the path.
// It will be rendered at the same width no matter how the document
// contents are transformed.
// First step: get the current canvas matrix
Matrix currentMatrix = canvas.getMatrix();
// Transform the path using this transform
Path transformedPath = new Path();
path.transform(currentMatrix, transformedPath);
// Reset the current canvas transform completely
canvas.setMatrix(new Matrix());
// If there is a shader (such as a gradient), we need to update its
// transform also
Shader shader = state.strokePaint.getShader();
Matrix currentShaderMatrix = new Matrix();
if (shader != null) {
shader.getLocalMatrix(currentShaderMatrix);
Matrix newShaderMatrix = new Matrix(currentShaderMatrix);
newShaderMatrix.postConcat(currentMatrix);
shader.setLocalMatrix(newShaderMatrix);
}
// Render the transformed path. The stroke width used will be in
// unscaled device units.
canvas.drawPath(transformedPath, state.strokePaint);
// Return the current canvas transform to what it was before all
// this happened
canvas.setMatrix(currentMatrix);
// And reset the shader matrix also
if (shader != null)
shader.setLocalMatrix(currentShaderMatrix);
} else {
canvas.drawPath(path, state.strokePaint);
}
}
示例12: getCurrentImageMatrix
import android.graphics.Matrix; //导入方法依赖的package包/类
/**
* 获取图片总变换矩阵.
*
* 总变换矩阵为内部变换矩阵x外部变换矩阵,决定了原图到所见最终状态的变换
* 当尚未布局或者原图不存在时,其值无意义.所以在调用前需要确保前置条件有效,否则将影响计算结果.
*
* @param matrix 用于填充结果的对象
* @return 如果传了matrix参数则将matrix填充后返回,否则new一个填充返回
*
* @see #getOuterMatrix(Matrix)
* @see #getInnerMatrix(Matrix)
*/
public Matrix getCurrentImageMatrix(Matrix matrix) {
//获取内部变换矩阵
matrix = getInnerMatrix(matrix);
//乘上外部变换矩阵
matrix.postConcat(mOuterMatrix);
return matrix;
}