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

public static Bitmap getRotateBitmap(Bitmap bitmap, int rotation) {
    if (null == bitmap || bitmap.isRecycled()) {
        return null;
    }/*w w  w  .  j  a  va  2 s . c  o  m*/

    Matrix matrix = new Matrix();
    matrix.postRotate(rotation);
    Bitmap cropBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, false);
    return cropBitmap;
}

From source file:Main.java

public static Bitmap rotateBitmap(Bitmap source, int degree) {
    Matrix matrix = new Matrix();
    matrix.postRotate(degree);
    Bitmap temp = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
    if (null != source && !source.isRecycled()) {
        source.recycle();/*w w  w  .  j  ava  2 s.co m*/
        source = null;
    }
    return temp;
}

From source file:Main.java

public static Bitmap getRotatedBitmap(Bitmap mBitmap, float degrees) {
    int width = mBitmap.getWidth();
    int height = mBitmap.getHeight();

    Matrix matrix = new Matrix();
    matrix.postRotate(degrees);
    Bitmap mRotateBitmap = Bitmap.createBitmap(mBitmap, 0, 0, width, height, matrix, true);

    return mRotateBitmap;
}

From source file:Main.java

public static Bitmap rotateBitmap(Bitmap bmp, float rotation) {
    if (rotation == 0) {
        return bmp;
    }/*w  w  w  .  j av a2  s .c  o  m*/

    Matrix matrix = new Matrix();
    matrix.postRotate(rotation);

    return Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);
}

From source file:Main.java

private static Bitmap rotateBitmap(Bitmap bitmap, int rotate) {
    if (bitmap == null)
        return null;

    int w = bitmap.getWidth();
    int h = bitmap.getHeight();

    // Setting post rotate to 90  
    Matrix mtx = new Matrix();
    mtx.postRotate(rotate);
    return Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, true);
}

From source file:Main.java

public static Bitmap rotateImageView(int angle, Bitmap bitmap) {
    if (bitmap == null) {
        return null;
    }// w w w.ja va2s . c  om
    Matrix matrix = new Matrix();
    matrix.postRotate(angle);
    Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix,
            true);
    return resizedBitmap;
}

From source file:Main.java

public static Bitmap rotateBitmap(Bitmap bitmap, int rotate) {
    if (bitmap == null)
        return null;

    int w = bitmap.getWidth();
    int h = bitmap.getHeight();

    // Setting post rotate to 90
    Matrix mtx = new Matrix();
    mtx.postRotate(rotate);
    return Bitmap.createBitmap(bitmap, 0, 0, w, h, mtx, true);
}

From source file:Main.java

/**
 * Rotate the image/* w  w  w . jav a  2  s.  c  om*/
 * @param bm source bitmap
 * @param rotation degree of rotation
 * @return return the rotated bitmap
 */
public static Bitmap rotateImage(Bitmap bm, int rotation) {
    Matrix matrix = new Matrix();
    matrix.postRotate(rotation);
    return Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true);
}

From source file:Main.java

public static Bitmap rotateBitmap(Bitmap bmp, int degrees) {
    if (degrees != 0) {
        Matrix matrix = new Matrix();
        matrix.postRotate(degrees % 360);
        return Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);
    }/*w  ww  . j a  v  a 2s . c  o m*/
    return bmp;
}

From source file:Main.java

public static Bitmap rotateImage(Bitmap input, int rotation) {
    // rotate Image
    Matrix rotateMatrix = new Matrix();
    rotateMatrix.postRotate(rotation);
    Bitmap rotatedBitmap = Bitmap.createBitmap(input, 0, 0, input.getWidth(), input.getHeight(), rotateMatrix,
            false);/*  w w w . j a  v a2 s  .  com*/
    return rotatedBitmap;
}