List of usage examples for android.graphics Matrix MSKEW_Y
int MSKEW_Y
To view the source code for android.graphics Matrix MSKEW_Y.
Click Source Link
From source file:Main.java
public static float getCurrentScaleFromMatrix(Matrix matrix) { float[] values = new float[9]; matrix.getValues(values);/*from w w w . j av a 2 s .c o m*/ float scalex = values[Matrix.MSCALE_X]; float skewy = values[Matrix.MSKEW_Y]; return (float) Math.sqrt(scalex * scalex + skewy * skewy); }
From source file:Main.java
public static float getMatrixScale(Matrix matrix) { synchronized (MATRIX_VALUES) { matrix.getValues(MATRIX_VALUES); final float scaleX = MATRIX_VALUES[Matrix.MSCALE_X]; final float skewY = MATRIX_VALUES[Matrix.MSKEW_Y]; //noinspection SuspiciousNameCombination return (float) Math.sqrt((float) Math.pow(scaleX, 2) + (float) Math.pow(skewY, 2)); }/* w ww .j ava2 s . c o m*/ }
From source file:android.support.graphics.drawable.VectorDrawableCompat.java
@Override public void draw(Canvas canvas) { if (mDelegateDrawable != null) { mDelegateDrawable.draw(canvas);/* ww w. j a va 2 s.c o m*/ return; } // We will offset the bounds for drawBitmap, so copyBounds() here instead // of getBounds(). copyBounds(mTmpBounds); if (mTmpBounds.width() <= 0 || mTmpBounds.height() <= 0) { // Nothing to draw return; } // Color filters always override tint filters. final ColorFilter colorFilter = (mColorFilter == null ? mTintFilter : mColorFilter); // The imageView can scale the canvas in different ways, in order to // avoid blurry scaling, we have to draw into a bitmap with exact pixel // size first. This bitmap size is determined by the bounds and the // canvas scale. canvas.getMatrix(mTmpMatrix); mTmpMatrix.getValues(mTmpFloats); float canvasScaleX = Math.abs(mTmpFloats[Matrix.MSCALE_X]); float canvasScaleY = Math.abs(mTmpFloats[Matrix.MSCALE_Y]); float canvasSkewX = Math.abs(mTmpFloats[Matrix.MSKEW_X]); float canvasSkewY = Math.abs(mTmpFloats[Matrix.MSKEW_Y]); // When there is any rotation / skew, then the scale value is not valid. if (canvasSkewX != 0 || canvasSkewY != 0) { canvasScaleX = 1.0f; canvasScaleY = 1.0f; } int scaledWidth = (int) (mTmpBounds.width() * canvasScaleX); int scaledHeight = (int) (mTmpBounds.height() * canvasScaleY); scaledWidth = Math.min(MAX_CACHED_BITMAP_SIZE, scaledWidth); scaledHeight = Math.min(MAX_CACHED_BITMAP_SIZE, scaledHeight); if (scaledWidth <= 0 || scaledHeight <= 0) { return; } final int saveCount = canvas.save(); canvas.translate(mTmpBounds.left, mTmpBounds.top); // Handle RTL mirroring. final boolean needMirroring = needMirroring(); if (needMirroring) { canvas.translate(mTmpBounds.width(), 0); canvas.scale(-1.0f, 1.0f); } // At this point, canvas has been translated to the right position. // And we use this bound for the destination rect for the drawBitmap, so // we offset to (0, 0); mTmpBounds.offsetTo(0, 0); mVectorState.createCachedBitmapIfNeeded(scaledWidth, scaledHeight); if (!mAllowCaching) { mVectorState.updateCachedBitmap(scaledWidth, scaledHeight); } else { if (!mVectorState.canReuseCache()) { mVectorState.updateCachedBitmap(scaledWidth, scaledHeight); mVectorState.updateCacheStates(); } } mVectorState.drawCachedBitmapWithRootAlpha(canvas, colorFilter, mTmpBounds); canvas.restoreToCount(saveCount); }
From source file:com.frank.protean.photoview.PhotoViewAttacher.java
public float getScale() { return (float) Math.sqrt((float) Math.pow(getValue(mSuppMatrix, Matrix.MSCALE_X), 2) + (float) Math.pow(getValue(mSuppMatrix, Matrix.MSKEW_Y), 2)); }
From source file:baizhuan.hangzhou.com.gankcopy.view.customview.photoview.PhotoViewAttacher.java
@Override public float getScale() { return (float) Math.sqrt((float) Math.pow(getValue(mSuppMatrix, Matrix.MSCALE_X), 2) + (float) Math.pow(getValue(mSuppMatrix, Matrix.MSKEW_Y), 2)); }
From source file:it.mb.whatshare.Utils.java
/** * Applies the transformations stored in the array of float values to the * argument list of points.//from www . ja v a 2 s. c om * * <p> * The float array can be obtained starting from a {@link Matrix} object by * calling <blockquote> * * <pre> * Matrix myMatrix; * float[] matrixValues = new float[9]; * myMatrix.getValues(matrixValues); * </pre> * * </blockquote> * * @param matrixValues * the values to apply to all points in the list * @param points * a list of points to which the transformations in the array * will be applied */ public static void applyMatrix(float[] matrixValues, List<PointF> points) { // variable names are the same used by Skia library final float tx = matrixValues[Matrix.MTRANS_X]; final float ty = matrixValues[Matrix.MTRANS_Y]; final float mx = matrixValues[Matrix.MSCALE_X]; final float my = matrixValues[Matrix.MSCALE_Y]; final float kx = matrixValues[Matrix.MSKEW_X]; final float ky = matrixValues[Matrix.MSKEW_Y]; /* * if rotation: skia messes up with the matrix, so sx and sy actually * store cosV, rx and ry store -sinV and sinV */ for (PointF point : points) { final float originalY = point.y; point.y = point.x * ky + (point.y * my) + ty; point.x = point.x * mx + (originalY * kx) + tx; } }
From source file:com.android.volley.ui.PhotoView.java
/** * Returns the currently applied scale factor for the image. * <p>//www .j av a 2 s . c om * NOTE: This method overwrites any values stored in {@link #mValues}. */ private float getScale() { return (float) Math.sqrt((float) Math.pow(getValue(mMatrix, Matrix.MSCALE_X), 2) + (float) Math.pow(getValue(mMatrix, Matrix.MSKEW_Y), 2)); }
From source file:com.androidex.volley.ui.PhotoView.java
/** * Returns the currently applied scale factor for the image. * <p>/* ww w . j a v a 2 s . com*/ * NOTE: This method overwrites any values stored in {@link #mValues}. */ private float getScale() { return FloatMath.sqrt((float) Math.pow(getValue(mMatrix, Matrix.MSCALE_X), 2) + (float) Math.pow(getValue(mMatrix, Matrix.MSKEW_Y), 2)); }