Example usage for android.graphics Matrix postConcat

List of usage examples for android.graphics Matrix postConcat

Introduction

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

Prototype

public boolean postConcat(Matrix other) 

Source Link

Document

Postconcats the matrix with the specified matrix.

Usage

From source file:Main.java

/**
 * Calculates the transformation matrix according to M(transformation) * M(source) = M(target).
 *
 * @param source source matrix/*  www .  j  a  va2s  . co 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:Main.java

public static Bitmap fixRotateMirrorImage(Bitmap src) {
    Matrix rotateRight = new Matrix();
    float[] mirrorY = { -1, 0, 0, 0, 1, 0, 0, 0, 1 };
    Matrix matrixMirrorY = new Matrix();
    matrixMirrorY.setValues(mirrorY);/*from  www  .j a  va 2  s .c o m*/
    rotateRight.postConcat(matrixMirrorY);
    rotateRight.preRotate(270);
    final Bitmap rotMirrorImg = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), rotateRight,
            true);
    src.recycle();

    return rotMirrorImg;
}

From source file:Main.java

/**
 * @return matrix with correct configuration for the front camera.
 * Function to set correct height orientation and rotation for saving the image
 * in sd card.//from  w ww .  j  a va  2 s. c  o m
 */
public static Matrix setOrientationForFrontCamera() {
    Matrix matrix = new Matrix();
    matrix.postRotate(-90);
    //for mirror images
    float[] mirrorY = { -1, 0, 0, 0, 1, 0, 0, 0, 1 };
    Matrix matrixMirrorY = new Matrix();
    matrixMirrorY.setValues(mirrorY);
    matrix.postConcat(matrixMirrorY);
    return matrix;
}

From source file:Main.java

public static Bitmap makeSquare(File file, int cameraID) {
    int width;/* w w w.  j av  a  2 s .co m*/
    int height;
    Matrix matrix = new Matrix();
    Camera.CameraInfo info = new Camera.CameraInfo();
    Camera.getCameraInfo(cameraID, info);
    // Convert ByteArray to Bitmap

    Bitmap bitPic = decodeSampledBitmapFromFile(destinationFile.getAbsolutePath(), 800, 800);//BitmapFactory.decodeByteArray(data, 0, data.length);
    width = bitPic.getWidth();
    height = bitPic.getHeight();

    // Perform matrix rotations/mirrors depending on camera that took the photo
    if (info.facing == Camera.CameraInfo.CAMERA_FACING_FRONT) {
        float[] mirrorY = { -1, 0, 0, 0, 1, 0, 0, 0, 1 };
        Matrix matrixMirrorY = new Matrix();
        matrixMirrorY.setValues(mirrorY);

        matrix.postConcat(matrixMirrorY);
    }

    matrix.postRotate(90);

    // Create new Bitmap out of the old one
    Bitmap bitPicFinal = Bitmap.createBitmap(bitPic, 0, 0, width, height, matrix, true);
    bitPic.recycle();
    int desWidth;
    int desHeight;
    desWidth = bitPicFinal.getWidth();
    desHeight = desWidth;
    Bitmap croppedBitmap = Bitmap.createBitmap(bitPicFinal, 0,
            bitPicFinal.getHeight() / 2 - bitPicFinal.getWidth() / 2, desWidth, desHeight);
    croppedBitmap = Bitmap.createScaledBitmap(croppedBitmap, 528, 528, true);
    return croppedBitmap;
}

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 ww w  .  j  a va  2 s.  c  o m*/
    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:im.ene.lab.design.widget.coverflow.FeatureCoverFlow.java

private void addChildRotation(View v, Matrix m) {
    mCamera.save();//www.j a v  a2 s  .  c  o m

    final int c = getChildsCenter(v);
    mCamera.rotateY(getRotationAngle(c) - getAngleOnCircle(c));

    mCamera.getMatrix(mTemp);
    m.postConcat(mTemp);

    mCamera.restore();
}

From source file:im.ene.lab.design.widget.coverflow.FeatureCoverFlow.java

private void addChildCircularPathZOffset(View child, Matrix m) {
    mCamera.save();//from  w  w  w. ja v a 2s  .c  om

    final float v = getOffsetOnCircle(getChildsCenter(child));
    final float z = mRadiusInMatrixSpace * v;

    mCamera.translate(0.0f, 0.0f, z);

    mCamera.getMatrix(mTemp);
    m.postConcat(mTemp);

    mCamera.restore();
}