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 scaleWithXY(Bitmap src, float scaleX, float scaleY) {
    Matrix matrix = new Matrix();
    matrix.postScale(scaleX, scaleY);/*from  w w  w.  j a va2 s  .  c  om*/
    return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
}

From source file:Main.java

public static Bitmap rotate(final Bitmap bitmap, final float winkel) {
    final Matrix matrix = new Matrix();
    matrix.postRotate(winkel);// w  ww .j  av a 2s.  c om
    final Bitmap rotated = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix,
            true);
    return rotated;
}

From source file:Main.java

public static Bitmap zoomBitmap(Bitmap src, float scaleX, float scaleY) {
    Matrix matrix = new Matrix();
    matrix.setScale(scaleX, scaleY);//from  w  ww .jav a2  s .co  m
    Bitmap t_bitmap = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
    return t_bitmap;
}

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  www  .ja v a2  s.com*/
    if (b != null && !b.isRecycled()) {
        b.recycle();
        b = null;
    }
    return rotaBitmap;
}

From source file:Main.java

public static Bitmap flipBitmap(Bitmap src) {
    Matrix m = new Matrix();
    m.preScale(-1, 1);/*w  ww.j  av  a2s. com*/
    Bitmap dst = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), m, false);
    dst.setDensity(DisplayMetrics.DENSITY_DEFAULT);
    return dst;
}

From source file:Main.java

public static Bitmap zoom(Bitmap source, float width, float height) {

    Matrix matrix = new Matrix();

    float scaleW = width / source.getWidth();
    float scaleH = height / source.getHeight();

    matrix.postScale(scaleW, scaleH);/*w  w  w  . ja v  a 2  s.  c o m*/

    Bitmap bm = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);

    return bm;
}

From source file:Main.java

public static Bitmap scaleBitmap(Bitmap bitmap, float widthRatio, float heightRatio) {
    Matrix matrix = new Matrix();
    matrix.postScale(widthRatio, heightRatio);
    return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}

From source file:Main.java

public static Matrix createMatrix(float m00, float m01, float m10, float m11, float m02, float m12) {
    Matrix result = new Matrix();
    setMatValues(result, m00, m01, m10, m11, m02, m12);
    return result;
}

From source file:Main.java

public static Bitmap rotateImage(Bitmap src, float degree) {
    // create new matrix
    Matrix matrix = new Matrix();
    // setup rotation degree
    matrix.postRotate(degree);/*from   w  w w .j a v a  2 s. c om*/
    Bitmap bmp = Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), matrix, true);
    return bmp;
}

From source file:Main.java

public static Bitmap rotateOrientation(Bitmap bmp, int rotation) {
    try {/*w  w w. jav a  2 s  . co  m*/
        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;
}