Example usage for android.graphics Matrix Matrix

List of usage examples for android.graphics Matrix Matrix

Introduction

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

Prototype

public Matrix() 

Source Link

Document

Create an identity matrix

Usage

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);
    return rotaBitmap;
}

From source file:Main.java

public static Bitmap rotate(int rotateDegree, Bitmap originalBitmap) {
    Matrix matrix = new Matrix();
    matrix.postRotate(rotateDegree);/*from  ww  w  .  j av  a 2s.  c om*/
    Bitmap rotateBitmap = Bitmap.createBitmap(originalBitmap, 0, 0, originalBitmap.getWidth(),
            originalBitmap.getHeight(), matrix, true);
    return rotateBitmap;
}

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);/*ww  w  .  j  a  v  a2s  .  c om*/
    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

private static Bitmap rotaingImageView(Bitmap bitmap, int angle) {
    Matrix matrix = new Matrix();
    ;/*  w w  w .  j av  a  2s. co  m*/
    matrix.postRotate(angle);
    Bitmap rotateBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix,
            true);
    return rotateBitmap;
}

From source file:Main.java

public static Bitmap rotaingImageView(int angle, Bitmap bitmap) {
    Matrix matrix = new Matrix();
    matrix.postRotate(angle);//from   w  w  w . ja va2s .com
    System.out.println("angle2=" + angle);
    Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix,
            true);
    bitmap.recycle();
    return resizedBitmap;
}

From source file:Main.java

public static Bitmap rotateBitmap(Bitmap source, int degree) {
    Matrix matrix = new Matrix();
    matrix.postRotate(degree);/*from w  w w.ja  v  a 2 s. c om*/
    Bitmap temp = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
    if (null != source && !source.isRecycled()) {
        source.recycle();
        source = null;
    }
    return temp;
}

From source file:Main.java

public static Bitmap resizeBitmap(Bitmap bm, float scale) {
    Matrix matrix = new Matrix();
    matrix.postScale(scale, scale);//from w  w w . j  a  v a2s . c  o m
    return Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true);
}

From source file:Main.java

public static Bitmap zoom(Bitmap source, float width, float height) {
    Matrix matrix = new Matrix();
    float scaleX = width / source.getWidth();
    float scaleY = height / source.getHeight();
    matrix.postScale(scaleX, scaleY);// w  w  w . j  a  v a  2 s  .  c o m

    Bitmap bitmap = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
    return bitmap;
}

From source file:Main.java

public static Bitmap create180RotatedBitmap(Bitmap srcbmp, Bitmap.Config config) {
    Matrix m = new Matrix();
    m.postRotate(180.0F);//from w  w w .  j  a  va2s .  c o m
    Bitmap newBmp = Bitmap.createBitmap(srcbmp, 0, 0, srcbmp.getWidth(), srcbmp.getHeight(), m, true);
    return newBmp;
}

From source file:Main.java

public static Matrix getRotateMatrix(Bitmap bitmap, int rotation) {
    Matrix matrix = new Matrix();
    if (bitmap != null && rotation != 0) {
        int cx = bitmap.getWidth() / 2;
        int cy = bitmap.getHeight() / 2;
        matrix.preTranslate(-cx, -cy);/*from ww w . j a  va2s. c  om*/
        matrix.postRotate(rotation);
        matrix.postTranslate(cx, cy);
    }
    return matrix;
}