本文整理汇总了Java中android.graphics.Matrix.invert方法的典型用法代码示例。如果您正苦于以下问题:Java Matrix.invert方法的具体用法?Java Matrix.invert怎么用?Java Matrix.invert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类android.graphics.Matrix
的用法示例。
在下文中一共展示了Matrix.invert方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: inverseMatrixPoint
import android.graphics.Matrix; //导入方法依赖的package包/类
/**
* 计算点除以矩阵的值
*
* matrix.mapPoints(unknownPoint) -> point
* 已知point和matrix,求unknownPoint的值.
*
* @param point
* @param matrix
* @return unknownPoint
*/
public static float[] inverseMatrixPoint(float[] point, Matrix matrix) {
if (point != null && matrix != null) {
float[] dst = new float[2];
//计算matrix的逆矩阵
Matrix inverse = matrixTake();
matrix.invert(inverse);
//用逆矩阵变换point到dst,dst就是结果
inverse.mapPoints(dst, point);
//清除临时变量
matrixGiven(inverse);
return dst;
} else {
return new float[2];
}
}
示例2: inverseMatrixPoint
import android.graphics.Matrix; //导入方法依赖的package包/类
/**
* 计算点除以矩阵的值
*
* matrix.mapPoints(unknownPoint) point
* 已知point和matrix,求unknownPoint的值.
*
* @param point
* @param matrix
* @return unknownPoint
*/
public static float[] inverseMatrixPoint(float[] point, Matrix matrix) {
if (point != null && matrix != null) {
float[] dst = new float[2];
//计算matrix的逆矩阵
Matrix inverse = matrixTake();
matrix.invert(inverse);
//用逆矩阵变换point到dst,dst就是结果
inverse.mapPoints(dst, point);
//清除临时变量
matrixGiven(inverse);
return dst;
} else {
return new float[2];
}
}
示例3: inverseMatrixPoint
import android.graphics.Matrix; //导入方法依赖的package包/类
/**
* 计算点除以矩阵的值
* <p>
* matrix.mapPoints(unknownPoint) -> point
* 已知point和matrix,求unknownPoint的值.
*
* @param point
* @param matrix
* @return unknownPoint
*/
public static float[] inverseMatrixPoint(float[] point, Matrix matrix) {
if (point != null && matrix != null) {
float[] dst = new float[2];
//计算matrix的逆矩阵
Matrix inverse = matrixTake();
matrix.invert(inverse);
//用逆矩阵变换point到dst,dst就是结果
inverse.mapPoints(dst, point);
//清除临时变量
matrixGiven(inverse);
return dst;
} else {
return new float[2];
}
}
示例4: applyOnSave
import android.graphics.Matrix; //导入方法依赖的package包/类
private static void applyOnSave(Canvas mCanvas, ImageViewTouch processImage,MyHighlightView view) {
if (view != null && view.getContent() instanceof StickerDrawable) {
final StickerDrawable stickerDrawable = ((StickerDrawable) view.getContent());
RectF cropRect = view.getCropRectF();
Rect rect = new Rect((int) cropRect.left, (int) cropRect.top, (int) cropRect.right,
(int) cropRect.bottom);
Matrix rotateMatrix = view.getCropRotationMatrix();
Matrix matrix = new Matrix(processImage.getImageMatrix());
if (!matrix.invert(matrix)) {
}
int saveCount = mCanvas.save(Canvas.MATRIX_SAVE_FLAG);
mCanvas.concat(rotateMatrix);
stickerDrawable.setDropShadow(false);
view.getContent().setBounds(rect);
view.getContent().draw(mCanvas);
mCanvas.restoreToCount(saveCount);
}
}
示例5: isTransformedTouchPointInView
import android.graphics.Matrix; //导入方法依赖的package包/类
/**
* Returns whether the touch point is within the child View
* It is transform aware and will invert the transform Matrix to find the true local points
* This code is taken from {@link ViewGroup#isTransformedTouchPointInView()}
*/
private static boolean isTransformedTouchPointInView(
float x,
float y,
ViewGroup parent,
View child,
PointF outLocalPoint) {
float localX = x + parent.getScrollX() - child.getLeft();
float localY = y + parent.getScrollY() - child.getTop();
Matrix matrix = child.getMatrix();
if (!matrix.isIdentity()) {
float[] localXY = mMatrixTransformCoords;
localXY[0] = localX;
localXY[1] = localY;
Matrix inverseMatrix = mInverseMatrix;
matrix.invert(inverseMatrix);
inverseMatrix.mapPoints(localXY);
localX = localXY[0];
localY = localXY[1];
}
if (child instanceof ReactHitSlopView && ((ReactHitSlopView) child).getHitSlopRect() != null) {
Rect hitSlopRect = ((ReactHitSlopView) child).getHitSlopRect();
if ((localX >= -hitSlopRect.left && localX < (child.getRight() - child.getLeft()) + hitSlopRect.right)
&& (localY >= -hitSlopRect.top && localY < (child.getBottom() - child.getTop()) + hitSlopRect.bottom)) {
outLocalPoint.set(localX, localY);
return true;
}
return false;
} else {
if ((localX >= 0 && localX < (child.getRight() - child.getLeft()))
&& (localY >= 0 && localY < (child.getBottom() - child.getTop()))) {
outLocalPoint.set(localX, localY);
return true;
}
return false;
}
}
示例6: verifySetBounds
import android.graphics.Matrix; //导入方法依赖的package包/类
private void verifySetBounds(Matrix rotationMatrix) {
RectF expectedBounds = new RectF(mBounds);
Matrix inverse = new Matrix();
rotationMatrix.invert(inverse);
inverse.mapRect(expectedBounds);
verify(mDrawable).setBounds(
(int) expectedBounds.left,
(int) expectedBounds.top,
(int) expectedBounds.right,
(int) expectedBounds.bottom);
}
示例7: changeRelativePoint
import android.graphics.Matrix; //导入方法依赖的package包/类
/**
* 基于原点求出相对于图片坐标系的坐标点
* @param locationX 原点x
* @param locationY 原点y
* @param matrix
* @return
*/
public static PointF changeRelativePoint(float locationX,float locationY, Matrix matrix){
float[] arrayOfFloat= new float[2];
arrayOfFloat[0]=locationX;
arrayOfFloat[1]=locationY;
Matrix invertMatrix=new Matrix();
//得到逆矩阵
matrix.invert(invertMatrix);
//将此矩阵应用于2D点阵列,并将转换的点写入数组
invertMatrix.mapPoints(arrayOfFloat);
float x = arrayOfFloat[0];
float y = arrayOfFloat[1];
return new PointF(x,y);
}
示例8: createMatrix
import android.graphics.Matrix; //导入方法依赖的package包/类
private Matrix createMatrix(int srcWidth, int srcHeight, int dstWidth, int dstHeight) {
Matrix matrix = new Matrix();
if (srcWidth != dstWidth || srcHeight != dstHeight) {
float scaleFactorX = dstWidth / (float) srcWidth;
float scaleFactorY = dstHeight / (float) srcHeight;
float scaleFactor = Math.max(scaleFactorX, scaleFactorY);
matrix.postScale(scaleFactor, scaleFactor);
}
matrix.invert(new Matrix());
return matrix;
}
示例9: draw
import android.graphics.Matrix; //导入方法依赖的package包/类
@Deprecated
public void draw(final Canvas canvas, final Matrix source) {
final Matrix matrix = new Matrix(source);
matrix.invert(matrix);
final int saveCount = canvas.save();
canvas.concat(matrix);
canvas.concat(mRotateMatrix);
mContent.setBounds((int) mDrawRect.left, (int) mDrawRect.top, (int) mDrawRect.right, (int) mDrawRect.bottom);
mContent.draw(canvas);
canvas.restoreToCount(saveCount);
}
示例10: draw
import android.graphics.Matrix; //导入方法依赖的package包/类
public void draw(final Canvas canvas, final Matrix source) {
final Matrix matrix = new Matrix(source);
matrix.invert(matrix);
final int saveCount = canvas.save();
canvas.concat(matrix);
canvas.concat(mRotateMatrix);
mContent.setBounds((int) mDrawRect.left, (int) mDrawRect.top, (int) mDrawRect.right,
(int) mDrawRect.bottom);
mContent.draw(canvas);
canvas.restoreToCount(saveCount);
}
示例11: adjustAspectRatio
import android.graphics.Matrix; //导入方法依赖的package包/类
private void adjustAspectRatio(int previewWidth, int previewHeight, int rotation) {
txform.reset();
int viewWidth = getWidth();
int viewHeight = getHeight();
float viewCenterX = viewWidth / 2;
float viewCenterY = viewHeight / 2;
float scale;
if (rotation == Surface.ROTATION_0 || rotation == Surface.ROTATION_180) {
scale = Math.max((float) (viewHeight + clipTop) / previewWidth, (float) (viewWidth + clipLeft) / previewHeight);
} else {
scale = Math.max((float) (viewHeight + clipTop) / previewHeight, (float) (viewWidth + clipLeft) / previewWidth);
}
float previewWidthScaled = previewWidth * scale;
float previewHeightScaled = previewHeight * scale;
float scaleX = previewHeightScaled / (viewWidth);
float scaleY = previewWidthScaled / (viewHeight);
txform.postScale(scaleX, scaleY, viewCenterX, viewCenterY);
if (Surface.ROTATION_90 == rotation || Surface.ROTATION_270 == rotation) {
txform.postRotate(90 * (rotation - 2), viewCenterX, viewCenterY);
} else {
if (Surface.ROTATION_180 == rotation) {
txform.postRotate(180, viewCenterX, viewCenterY);
}
}
if (mirror) {
txform.postScale(-1, 1, viewCenterX, viewCenterY);
}
if (clipTop != 0 || clipLeft != 0) {
txform.postTranslate(-clipLeft / 2, -clipTop / 2);
}
textureView.setTransform(txform);
Matrix matrix = new Matrix();
matrix.postRotate(cameraSession.getDisplayOrientation());
matrix.postScale(viewWidth / 2000f, viewHeight / 2000f);
matrix.postTranslate(viewWidth / 2f, viewHeight / 2f);
matrix.invert(this.matrix);
}
示例12: setMatrix
import android.graphics.Matrix; //导入方法依赖的package包/类
public void setMatrix(Matrix m) {
invertMatrix = new Matrix();
m.invert(invertMatrix);
}
示例13: setPreviewSize
import android.graphics.Matrix; //导入方法依赖的package包/类
void setPreviewSize(boolean fullScreen) {
final int width = preview.getMeasuredWidth();
final int height = preview.getMeasuredHeight();
boolean widthIsMax = width > height;
RectF rectDisplay = new RectF();
RectF rectPreview = new RectF();
// RectF of screen, corresponds to the screen size
rectDisplay.set(0, 0, width, height);
// RectF preview
if (widthIsMax) {
// preview in horizontal orientation
rectPreview.set(0, 0, photoProcessor.getPreviewWidth(), photoProcessor.getPreviewHeight());
} else {
// preview in vertical orientation
// noinspection SuspiciousNameCombination
rectPreview.set(0, 0, photoProcessor.getPreviewHeight(), photoProcessor.getPreviewWidth());
}
Matrix matrix = new Matrix();
// transformation matrix preparation
if (!fullScreen) {
// If the preview is placed into the screen
matrix.setRectToRect(rectPreview, rectDisplay, Matrix.ScaleToFit.START);
} else {
// If the screen is placed in the preview
matrix.setRectToRect(rectDisplay, rectPreview, Matrix.ScaleToFit.START);
matrix.invert(matrix);
}
// transformation
matrix.mapRect(rectPreview);
// setting the surface dimensions from the resulting transformation
final ViewGroup.LayoutParams layoutParams = preview.getLayoutParams();
if (layoutParams.width != (int) rectPreview.right || layoutParams.height != (int) rectPreview.bottom) {
layoutParams.height = (int) (rectPreview.bottom);
layoutParams.width = (int) (rectPreview.right);
preview.setLayoutParams(layoutParams);
} else {
startCameraPreview(preview.getHolder());
}
}