当前位置: 首页>>代码示例>>Java>>正文


Java Matrix.invert方法代码示例

本文整理汇总了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];
    }
}
 
开发者ID:ZhouKanZ,项目名称:SweepRobot,代码行数:26,代码来源:PinchImageView.java

示例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];
    }
}
 
开发者ID:abook23,项目名称:godlibrary,代码行数:26,代码来源:PinchImageView.java

示例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];
    }
}
 
开发者ID:JJS-CN,项目名称:JBase,代码行数:26,代码来源:PinchImageView.java

示例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);
        }
    }
 
开发者ID:Sherchen,项目名称:AnimationsDemo,代码行数:23,代码来源:EffectUtil.java

示例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;
  }
}
 
开发者ID:qq565999484,项目名称:RNLearn_Project1,代码行数:44,代码来源:TouchTargetHelper.java

示例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);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:12,代码来源:OrientedDrawableTest.java

示例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);
}
 
开发者ID:ZhouKanZ,项目名称:SweepRobot,代码行数:22,代码来源:DegreeManager.java

示例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;
}
 
开发者ID:reneweb,项目名称:react-native-tensorflow,代码行数:14,代码来源:ImageRecognizer.java

示例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);
}
 
开发者ID:junchenChow,项目名称:exciting-app,代码行数:15,代码来源:MyHighlightView.java

示例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);
    }
 
开发者ID:Sherchen,项目名称:AnimationsDemo,代码行数:16,代码来源:MyHighlightView.java

示例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);
}
 
开发者ID:chengzichen,项目名称:KrGallery,代码行数:47,代码来源:CameraView.java

示例12: setMatrix

import android.graphics.Matrix; //导入方法依赖的package包/类
public void setMatrix(Matrix m) {
    invertMatrix = new Matrix();
    m.invert(invertMatrix);
}
 
开发者ID:pooyafaroka,项目名称:PlusGram,代码行数:5,代码来源:Input.java

示例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());
    }
}
 
开发者ID:humaniq,项目名称:humaniq-android,代码行数:45,代码来源:PhotoFragment.java


注:本文中的android.graphics.Matrix.invert方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。