List of usage examples for android.graphics Matrix invert
public boolean invert(Matrix inverse)
From source file:Main.java
/** * Gets invert matrix./*from www . j a v a2 s .com*/ * * @param matrix original matrix * @return invert matrix */ public static Matrix getInvertMatrix(Matrix matrix) { Matrix invertMatrix = new Matrix(); matrix.invert(invertMatrix); return invertMatrix; }
From source file:Main.java
/** * Calculates the transformation matrix according to M(transformation) * M(source) = M(target). * * @param source source matrix/*from www . j av a2s . c o m*/ * @param target target matrix * @return delta matrix */ public static Matrix getTransformationMatrix(Matrix source, Matrix target) { Matrix delta = new Matrix(); source.invert(delta); delta.postConcat(target); return delta; }
From source file:com.almalence.util.Util.java
public static void initializeMeteringMatrix() { Matrix matrix = new Matrix(); Util.prepareMatrix(matrix, CameraController.isFrontCamera(), 0, ApplicationScreen.getPreviewWidth(), ApplicationScreen.getPreviewHeight()); matrix.invert(mMeteringMatrix); }
From source file:com.mediatek.galleryfeature.stereo.segment.ImageShow.java
/** * This function calculates a screen to image Transformation matrix. * * @param reflectRotation// ww w.ja v a 2 s.com * set true if you want the rotation encoded. * TODO useless, to be removed. * @return Screen to Image transformation matrix */ protected Matrix getScreenToImageMatrix(boolean reflectRotation) { Rect originalBounds = mMasterImage.getOriginalBounds(); int imgWidth = originalBounds.width(); int imgHeight = originalBounds.height(); Matrix m = mMasterImage.getImageToScreenMatrix(imgWidth, imgHeight, getWidth(), getHeight()); Matrix invert = new Matrix(); m.invert(invert); return invert; }
From source file:android.support.transition.ChangeTransform.java
private void setMatricesForParent(TransitionValues startValues, TransitionValues endValues) { Matrix endParentMatrix = (Matrix) endValues.values.get(PROPNAME_PARENT_MATRIX); endValues.view.setTag(R.id.parent_matrix, endParentMatrix); Matrix toLocal = mTempMatrix;/*from w w w.j av a2 s .c om*/ 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); }
From source file:com.android.gallery3d.filtershow.imageshow.ImageShow.java
/** * This function calculates a to Screen Image Transformation matrix * * @param reflectRotation set true if you want the rotation encoded * @return Screen to Image transformation matrix *///from w ww. ja v a 2 s .co m protected Matrix getScreenToImageMatrix(boolean reflectRotation) { Matrix m = getImageToScreenMatrix(reflectRotation); Matrix invert = new Matrix(); m.invert(invert); return invert; }
From source file:com.fractview.ImageViewFragment.java
private void applyTouch(Matrix bitmapMatrix, Matrix prefsMatrix) { // Did we only move? final float[] bm = new float[9]; bitmapMatrix.getValues(bm);//from w ww . j a va 2s . c om if (bm[0] == 1f && bm[1] == 0f && bm[3] == 0f && bm[4] == 1f) { Log.d(TAG, "We only moved!"); taskFragment.modifyImage(new UnsafeImageEditor() { @Override public void edit(AbstractImgCache cache) { ScaleableCache scaleable = (ScaleableCache) cache; scaleable.move((int) Math.round(bm[2]), (int) Math.round(bm[5])); } }, true); } else { // Update zoom Log.d(TAG, "We need to scale"); Matrix m = new Matrix(); prefsMatrix.invert(m); final float[] matrix = new float[9]; m.getValues(matrix); taskFragment.modifyImage(new UnsafeImageEditor() { @Override public void edit(AbstractImgCache cache) { ScaleableCache scaleable = (ScaleableCache) cache; scaleable.newRelativeScale(matrix); } }, true); } }
From source file:com.android.gallery3d.filtershow.imageshow.ImageShow.java
private void drawHighresImage(Canvas canvas, Bitmap fullHighres) { Matrix originalToScreen = MasterImage.getImage().originalImageToScreen(); if (fullHighres != null && originalToScreen != null) { Matrix screenToOriginal = new Matrix(); originalToScreen.invert(screenToOriginal); Rect rBounds = new Rect(); rBounds.set(MasterImage.getImage().getPartialBounds()); if (fullHighres != null) { originalToScreen.preTranslate(rBounds.left, rBounds.top); canvas.clipRect(mImageBounds); canvas.drawBitmap(fullHighres, originalToScreen, mPaint); }//from w w w . j a va 2s . c om } }
From source file:com.ezartech.ezar.videooverlay.ezAR.java
private void updateMatrix() { Matrix workMatrix = new Matrix(); Size sz = getWebViewSize();//from w w w .j a va 2 s . c o m Util.prepareMatrix(workMatrix, isMirror(), getDisplayOrientation(), sz.width, sz.height); // In face detection, the matrix converts the driver coordinates to UI // coordinates. In tap focus, the inverted matrix converts the UI // coordinates to driver coordinates. workMatrix.invert(matrix); }
From source file:com.pdftron.pdf.tools.Tool.java
public void onDraw(Canvas canvas, android.graphics.Matrix tfm) { // Draw page number if (mShowPageNum && mPageNumberIndicatorVisible) { int width = mPDFView.getWidth(); int height = mPDFView.getHeight(); int page_num = mPDFView.getCurrentPage(); boolean restore = false; float yOffset = 0; try {/*from w w w . ja v a 2s . c o m*/ // During page sliding, PDFViewCtrl might apply extra transformation // matrix to Canvas for animation. However, page number should not // move; hence applying the inverse to offset it. if (!tfm.isIdentity()) { canvas.save(); restore = true; tfm.invert(mTempMtx1); canvas.getMatrix(mTempMtx2); mTempMtx2.postConcat(mTempMtx1); canvas.setMatrix(mTempMtx2); // Workaround for bug found in Android > ICS with hardware acceleration turned // ON. See http://code.google.com/p/android/issues/detail?id=24517 for more info if (Build.VERSION.SDK_INT >= 14 /*Build.VERSION_CODES.ICE_CREAM_SANDWICH*/ && mPDFView.isHardwareAccelerated()) { Rect rectangle = new Rect(); ((android.app.Activity) mPDFView.getContext()).getWindow().getDecorView() .getWindowVisibleDisplayFrame(rectangle); yOffset = rectangle.top; } } int page_count = mPDFView.getDoc().getPageCount(); String str = String.format(getStringFromResId(R.string.tools_misc_pagerange), page_num, page_count); Rect r = new Rect(); mPaint4PageNum.getTextBounds(str, 0, str.length(), r); float str_width = r.width(); float str_height = r.height(); float margin = str_height / 1.5f; float left = width - str_width * 1.5f - margin + mPDFView.getScrollX(); float top = mPDFView.getScrollY() + height - mPageNumPosAdjust - str_height * 3.0f + yOffset; float right = left + str_width + margin * 2; float bottom = top + str_height + margin * 2; mTempPageDrawingRectF.set(left, top, right, bottom); mPaint4PageNum.setColor( mPDFView.getContext().getResources().getColor(R.color.tools_pageindicator_background)); canvas.drawRoundRect(mTempPageDrawingRectF, margin, margin, mPaint4PageNum); mPaint4PageNum .setColor(mPDFView.getContext().getResources().getColor(R.color.tools_pageindicator_text)); left += margin; top += str_height / 2 + margin + mPaint4PageNum.descent(); canvas.drawText(str, left, top - 0.5f, mPaint4PageNum); } catch (Exception e) { } finally { if (restore) { canvas.restore(); } } } }