Example usage for android.graphics Matrix postRotate

List of usage examples for android.graphics Matrix postRotate

Introduction

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

Prototype

public boolean postRotate(float degrees) 

Source Link

Document

Postconcats the matrix with the specified rotation.

Usage

From source file:Main.java

private static Bitmap rotate(Bitmap bm, int rotation) {
    if (rotation != 0) {
        Matrix matrix = new Matrix();
        matrix.postRotate(rotation);
        Bitmap bmOut = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true);
        return bmOut;
    }/*from w  ww.  j av  a  2 s.c  om*/
    return bm;
}

From source file:Main.java

public static Bitmap getRotateBitmap(Bitmap b, float rotateDegree) {
    Matrix matrix = new Matrix();
    matrix.postRotate((float) rotateDegree);
    Bitmap rotaBitmap = Bitmap.createBitmap(b, 0, 0, b.getWidth(), b.getHeight(), matrix, false);
    //add//from  w ww  .j  a  v  a 2  s .co  m
    if (b != null && !b.isRecycled()) {
        b.recycle();
        b = null;
    }
    return rotaBitmap;
}

From source file:Main.java

private static Bitmap rotateImage(Bitmap source, float angle) {

    Bitmap bitmap = null;/*from   w  w  w .java  2s .  c om*/
    Matrix matrix = new Matrix();
    matrix.postRotate(angle);
    try {
        bitmap = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
    } catch (OutOfMemoryError err) {
        err.printStackTrace();
    }
    return bitmap;
}

From source file:Main.java

public static Bitmap rotation90(Bitmap bitmap) {
    if (bitmap == null)
        return null;
    if (bitmap.isRecycled())
        return null;
    Bitmap bmp = null;//from  w w w.j ava2 s  .c  o m
    Matrix matrix = new Matrix();
    matrix.postRotate(90);
    bmp = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false);
    bitmap.recycle();
    return bmp;
}

From source file:Main.java

public static Bitmap rotate(Bitmap bitmap, int degrees) {
    Matrix matrix = new Matrix();
    matrix.postRotate(degrees);
    return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}

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./*  w  w  w .jav  a  2s .co  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 rotateImage(Bitmap bitmap, int rotate) {
    if (rotate != 0) {
        // rotate
        Matrix m = new Matrix();
        m.postRotate(rotate);
        Bitmap rotImage = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), m, true);
        bitmap.recycle();/* w  w w.  j a va2s  .  c  o m*/
        System.gc();

        return rotImage;
    }
    return bitmap;
}

From source file:Main.java

public static Bitmap rotate(Bitmap bitmap, int angle) {
    Matrix matrix = new Matrix();
    matrix.postRotate(angle);
    return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}

From source file:Main.java

public static Bitmap rotateOrientation(Bitmap bmp, int rotation) {
    try {/*from   ww w  .j ava 2  s  . c om*/
        Matrix matrix = new Matrix();
        matrix.postRotate(rotation);
        return Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);

    } catch (Exception e) {
        e.printStackTrace();
    }
    return null;
}

From source file:Main.java

private static Bitmap rotaingImageView(Bitmap bitmap, int angle) {
    Matrix matrix = new Matrix();
    ;//from  w w  w .ja  v  a2s.  c  o m
    matrix.postRotate(angle);
    Bitmap rotateBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix,
            true);
    return rotateBitmap;
}