Example usage for android.graphics Matrix getValues

List of usage examples for android.graphics Matrix getValues

Introduction

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

Prototype

public void getValues(float[] values) 

Source Link

Document

Copy 9 values from the matrix into the array.

Usage

From source file:Main.java

public static float getValues(Matrix matrix, int offset) {
    matrix.getValues(mMatrixValues);
    return mMatrixValues[offset];
}

From source file:Main.java

public static void getValuesFromMatrix(Matrix matrix, float[] values) {
    matrix.getValues(values);
}

From source file:Main.java

public static float[] getValues(Matrix m) {
    float[] values = new float[9];
    m.getValues(values);
    return values;
}

From source file:Main.java

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

From source file:Main.java

public static float getValue(Matrix matrix, int whichValue) {
    float[] mMatrixValues = new float[9];
    matrix.getValues(mMatrixValues);
    return mMatrixValues[whichValue];
}

From source file:Main.java

@SuppressWarnings("unused")
public static float getMatrixValue(Matrix matrix, int whichValue) {
    synchronized (MATRIX_VALUES) {
        matrix.getValues(MATRIX_VALUES);
        return MATRIX_VALUES[whichValue];
    }/*  ww w  .  j  a  v  a 2  s. com*/
}

From source file:Main.java

@SuppressWarnings("unused")
public static void getMatrixTranslation(Matrix matrix, PointF point) {
    synchronized (MATRIX_VALUES) {
        matrix.getValues(MATRIX_VALUES);
        point.x = MATRIX_VALUES[Matrix.MTRANS_X];
        point.y = MATRIX_VALUES[Matrix.MTRANS_Y];
    }/*  ww  w .j  a  v a2 s  . c  o  m*/
}

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 w w  . j a va  2 s. c  o  m*/
            return 0;
        }
    }
}

From source file:Main.java

public static void getMatrix3DValues(final Matrix matrix2D, final float[] matrix3D) {
    matrix2D.getValues(matrix3D);
    // Log.e("long", matrix2D.toShortString());
    final float v0 = matrix3D[0];
    final float v1 = matrix3D[1];
    final float v2 = matrix3D[2];
    final float v3 = matrix3D[3];
    final float v4 = matrix3D[4];
    final float v5 = matrix3D[5];
    final float v6 = matrix3D[6];
    final float v7 = matrix3D[7];
    final float v8 = matrix3D[8];

    matrix3D[0] = v0;//w w w .j a  v a  2  s .co  m
    matrix3D[4] = v1;
    matrix3D[8] = v2;

    matrix3D[1] = v3;
    matrix3D[5] = v4;
    matrix3D[9] = v5;

    matrix3D[2] = v6;
    matrix3D[6] = v7;
    matrix3D[10] = v8;

    matrix3D[3] = matrix3D[7] = matrix3D[11] = 0;

    matrix3D[12] = matrix3D[13] = matrix3D[14] = 0;
    matrix3D[15] = 1;
}