public Matrix getPixelToValueMatrix() { getValueToPixelMatrix().invert(mMBuffer2); return mMBuffer2; } }
/** * Transforms the given array of touch positions (pixels) (x, y, x, y, ...) * into values on the chart. * * @param pixels */ public void pixelsToValue(float[] pixels) { Matrix tmp = mPixelToValueMatrixBuffer; tmp.reset(); // invert all matrixes to convert back to the original value mMatrixOffset.invert(tmp); tmp.mapPoints(pixels); mViewPortHandler.getMatrixTouch().invert(tmp); tmp.mapPoints(pixels); mMatrixValueToPx.invert(tmp); tmp.mapPoints(pixels); }
private void setMatricesForParent(TransitionValues startValues, TransitionValues endValues) { Matrix endParentMatrix = (Matrix) endValues.values.get(PROPNAME_PARENT_MATRIX); endValues.view.setTag(R.id.parentMatrix, endParentMatrix); Matrix toLocal = mTempMatrix; toLocal.reset(); endParentMatrix.invert(toLocal); Matrix startLocal = (Matrix) startValues.values.get(PROPNAME_MATRIX); if (startLocal == null) { startLocal = new Matrix(); startValues.values.put(PROPNAME_MATRIX, startLocal); } Matrix startParentMatrix = (Matrix) startValues.values.get(PROPNAME_PARENT_MATRIX); startLocal.postConcat(startParentMatrix); startLocal.postConcat(toLocal); }
protected void applyState(State state) { state.get(matrix); matrix.invert(matrixInverse); invalidate(); }
/** * Gets the 4 points of crop window's position relative to the source Bitmap (not the image * displayed in the CropImageView) using the original image rotation.<br> * Note: the 4 points may not be a rectangle if the image was rotates to NOT stright angle (!= * 90/180/270). * * @return 4 points (x0,y0,x1,y1,x2,y2,x3,y3) of cropped area boundaries */ public float[] getCropPoints() { // Get crop window position relative to the displayed image. RectF cropWindowRect = mCropOverlayView.getCropWindowRect(); float[] points = new float[] { cropWindowRect.left, cropWindowRect.top, cropWindowRect.right, cropWindowRect.top, cropWindowRect.right, cropWindowRect.bottom, cropWindowRect.left, cropWindowRect.bottom }; mImageMatrix.invert(mImageInverseMatrix); mImageInverseMatrix.mapPoints(points); for (int i = 0; i < points.length; i++) { points[i] *= mLoadedSampleSize; } return points; }
matrix.invert(pathMatrix); path.transform(pathMatrix);
mImageMatrix.invert(mImageInverseMatrix); mImageInverseMatrix.mapRect(BitmapUtils.RECT);
private void selectItem(float eventX, float eventY) { // Getting first item (in backward order) which contains given click event for (int i = items.size() - 1; i >= 0; i--) { Item item = items.get(i); item.getState().get(matrix); matrix.invert(inverseMatrix); // Taking item's rotation into account point[0] = eventX; point[1] = eventY; inverseMatrix.mapPoints(point); int newX = Math.round(point[0]); int newY = Math.round(point[1]); // Checking if click event is within item's bounds Rect bounds = images.get(item.getImageId()).getBounds(); if (bounds.contains(newX, newY)) { selectItem(item); return; } } selectItem(null); }
private static void checkInverse(Matrix matrix) { final Matrix inverse = new Matrix(); assertThat(matrix.invert(inverse)) .isTrue(); matrix.postConcat(inverse); assertThat(matrix.isIdentity()) .isTrue(); } }
public static void computeNewPosition(@Size(2) float[] point, State initialState, State finalState) { initialState.get(tmpMatrix); tmpMatrix.invert(tmpMatrixInverse); tmpMatrixInverse.mapPoints(point); finalState.get(tmpMatrix); tmpMatrix.mapPoints(point); }
@Test public void testInvert() { final Matrix matrix = new Matrix(); final Matrix inverse = new Matrix(); matrix.setScale(0.0f, 1.0f); assertThat(matrix.invert(inverse)) .isFalse(); matrix.setScale(1.0f, 0.0f); assertThat(matrix.invert(inverse)) .isFalse(); matrix.setScale(1.0f, 1.0f); checkInverse(matrix); matrix.setScale(-3.0f, 5.0f); checkInverse(matrix); matrix.setTranslate(5.0f, 2.0f); checkInverse(matrix); matrix.setScale(-3.0f, 5.0f); matrix.postTranslate(5.0f, 2.0f); checkInverse(matrix); matrix.setScale(-3.0f, 5.0f); matrix.postRotate(-30f, 1.0f, 2.0f); matrix.postTranslate(5.0f, 2.0f); checkInverse(matrix); }
mImageMatrix.invert(mImageInverseMatrix);
if (mBitmap != null && width > 0 && height > 0) { mImageMatrix.invert(mImageInverseMatrix); RectF cropRect = mCropOverlayView.getCropWindowRect(); mImageInverseMatrix.mapRect(cropRect);
/** * Maps point from view-absolute to image-relative coordinates. * This takes into account the zoomable transformation. */ public PointF mapViewToImage(PointF viewPoint) { float[] points = mTempValues; points[0] = viewPoint.x; points[1] = viewPoint.y; mActiveTransform.invert(mActiveTransformInverse); mActiveTransformInverse.mapPoints(points, 0, points, 0, 1); mapAbsoluteToRelative(points, points, 1); return new PointF(points[0], points[1]); }
mImageMatrix.invert(mImageInverseMatrix); mImageInverseMatrix.mapRect(BitmapUtils.RECT);
/** * Gets the 4 points of crop window's position relative to the source Bitmap (not the image * displayed in the CropImageView) using the original image rotation.<br> * Note: the 4 points may not be a rectangle if the image was rotates to NOT stright angle (!= * 90/180/270). * * @return 4 points (x0,y0,x1,y1,x2,y2,x3,y3) of cropped area boundaries */ public float[] getCropPoints() { // Get crop window position relative to the displayed image. RectF cropWindowRect = mCropOverlayView.getCropWindowRect(); float[] points = new float[] { cropWindowRect.left, cropWindowRect.top, cropWindowRect.right, cropWindowRect.top, cropWindowRect.right, cropWindowRect.bottom, cropWindowRect.left, cropWindowRect.bottom }; mImageMatrix.invert(mImageInverseMatrix); mImageInverseMatrix.mapPoints(points); for (int i = 0; i < points.length; i++) { points[i] *= mLoadedSampleSize; } return points; }
mImageMatrix.invert(mImageInverseMatrix);
if (mBitmap != null && width > 0 && height > 0) { mImageMatrix.invert(mImageInverseMatrix); RectF cropRect = mCropOverlayView.getCropWindowRect(); mImageInverseMatrix.mapRect(cropRect);
public Matrix getPixelToValueMatrix() { getValueToPixelMatrix().invert(mMBuffer2); return mMBuffer2; } }
private float[] mapPointFromParentToView(View v, float x, float y) { sTmpPoint[0] = x - v.getLeft(); sTmpPoint[1] = y - v.getTop(); v.getMatrix().invert(sTmpInvMatrix); sTmpInvMatrix.mapPoints(sTmpPoint); return sTmpPoint; }