Example usage for android.graphics Matrix MSCALE_X

List of usage examples for android.graphics Matrix MSCALE_X

Introduction

In this page you can find the example usage for android.graphics Matrix MSCALE_X.

Prototype

int MSCALE_X

To view the source code for android.graphics Matrix MSCALE_X.

Click Source Link

Usage

From source file:Main.java

public static void print(Matrix matrix) {
    float scale = getValue(matrix, Matrix.MSCALE_X);

    float moveX = getValue(matrix, Matrix.MTRANS_X);
    float moveY = getValue(matrix, Matrix.MTRANS_Y);

    Log.e("[MatrixUtils]", "matrix: { moveX: " + moveX + ", moveY: " + moveY + ", scale: " + scale + " }");
}

From source file:Main.java

public static float getCurrentScaleFromMatrix(Matrix matrix) {
    float[] values = new float[9];
    matrix.getValues(values);/*from  w  ww . j a  v  a 2s  .  co  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 w  w  . j  a  v  a 2  s  .  com
}

From source file:Main.java

@SuppressWarnings("unused")
public static int getMatrixRotateDegrees(Matrix matrix) {
    synchronized (MATRIX_VALUES) {
        matrix.getValues(MATRIX_VALUES);
        final float skewX = MATRIX_VALUES[Matrix.MSKEW_X];
        final float scaleX = MATRIX_VALUES[Matrix.MSCALE_X];
        //noinspection SuspiciousNameCombination
        final int degrees = (int) Math.round(Math.atan2(skewX, scaleX) * (180 / Math.PI));
        if (degrees < 0) {
            return Math.abs(degrees);
        } else if (degrees > 0) {
            return 360 - degrees;
        } else {//from w ww .  j a  v  a 2s.c om
            return 0;
        }
    }
}

From source file:com.apptentive.android.sdk.util.image.PreviewImageView.java

/**
 * Get current scale factor (x/y universal scaling)
 *
 * @return//w ww  .  ja  v a2s  .co  m
 */
public final float getScale() {
    scaleMatrix.getValues(matrixValues);
    return matrixValues[Matrix.MSCALE_X];
}

From source file:com.example.PagerCoverFlow.PagerContainer.java

private void transformImageBitmap(ImageView child, Matrix imageMatrix, int rotationAngle) {
    mCamera.save();/*from w w w  .ja va 2 s  . c  o  m*/
    //        final Matrix imageMatrix = t.getMatrix();;
    final int imageHeight = child.getLayoutParams().height;
    final int imageWidth = child.getLayoutParams().width;
    final int rotation = Math.abs(rotationAngle);

    //      mCamera.translate(0.0f, 0.0f, 100.0f);
    Log.i("Select", "imageWidth:" + imageWidth + " " + "imageHeight:" + imageHeight);
    //As the angle of the view gets less, zoom in
    //      if ( rotation < mMaxRotationAngle )
    {
        float zoomAmount = (float) (mMaxZoom + (rotation * 1.5));
        Log.i("Select", "rotation:" + rotation + " zoomAmount:" + zoomAmount);
        mCamera.translate(0.0f, 0.0f, zoomAmount);
    }

    //Alpha
    int alphaVal = 255 - rotation * 3;
    //      child.setAlpha(alphaVal); //[0,255]
    child.getDrawable().setAlpha(alphaVal);
    //      mCamera.rotateY(rotationAngle);
    mCamera.getMatrix(imageMatrix);
    imageMatrix.preTranslate(-(imageWidth / 2), -(imageHeight / 2));
    imageMatrix.postTranslate((imageWidth / 2), (imageHeight / 2));
    mCamera.restore();

    float[] values = new float[9];
    imageMatrix.getValues(values);
    float globalX = values[Matrix.MTRANS_X];
    float globalY = values[Matrix.MTRANS_Y];
    //      float width = values[Matrix.MSCALE_X]*CommonValue.menuWidth ;
    //      float height = values[Matrix.MSCALE_Y]*CommonValue.menuWidth;
    values[Matrix.MSCALE_X] = 2;
    values[Matrix.MSCALE_Y] = 2;
    imageMatrix.setValues(values);
}

From source file:android.support.graphics.drawable.VectorDrawableCompat.java

@Override
public void draw(Canvas canvas) {
    if (mDelegateDrawable != null) {
        mDelegateDrawable.draw(canvas);/*from w  ww.ja  v  a  2  s.c om*/
        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:it.configure.imageloader.zoom.PhotoViewAttacher.java

@Override
public final float getScale() {
    return getValue(mSuppMatrix, Matrix.MSCALE_X);
}

From source file:org.witness.informacam.app.editors.image.ImageRegion.java

public void updateMatrix() {
    float[] mValues = new float[9];
    mMatrix.getValues(mValues);/* ww w  .  j a v  a 2  s. c  om*/
    mMatrix.invert(iMatrix);
    scaleX = mValues[Matrix.MSCALE_X];
    scaleY = mValues[Matrix.MSCALE_Y];

    leftOffset = mValues[Matrix.MTRANS_X];
    topOffset = mValues[Matrix.MTRANS_Y];

}

From source file:com.jsibbold.zoomage.ZoomageView.java

/**
 * Update the bounds of the displayed image based on the current matrix.
 *
 * @param values the image's current matrix values.
 *//*from w  w w.  j a  va2 s.c  om*/
private void updateBounds(final float[] values) {
    if (getDrawable() != null) {
        bounds.set(values[Matrix.MTRANS_X], values[Matrix.MTRANS_Y],
                getDrawable().getIntrinsicWidth() * values[Matrix.MSCALE_X] + values[Matrix.MTRANS_X],
                getDrawable().getIntrinsicHeight() * values[Matrix.MSCALE_Y] + values[Matrix.MTRANS_Y]);
    }
}