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 rotateBitmap(Bitmap srcBitmap, int rotate) {
    Bitmap rotateBitmap = null;//www. j a v  a2 s.  com
    Matrix matrix = new Matrix();
    matrix.postRotate(rotate);
    rotateBitmap = Bitmap.createBitmap(srcBitmap, 0, 0, srcBitmap.getWidth(), srcBitmap.getHeight(), matrix,
            true);
    return rotateBitmap;
}

From source file:Main.java

public static Bitmap rotaingBitmap(int angle, Bitmap bitmap) {
    Matrix matrix = new Matrix();
    matrix.postRotate(angle);//from w  w  w . j av a 2  s .com
    Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix,
            true);
    return resizedBitmap;
}

From source file:Main.java

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

    Bitmap bitmap = null;/*from   w  ww . j  a  va  2  s  . com*/
    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 rotateBitmap(Bitmap bitmap, int rotation) {
    Matrix matrix = new Matrix();
    matrix.postRotate(rotation);/*from   w w w .jav a  2  s  . c o m*/
    Bitmap rotatedbitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix,
            true);
    return rotatedbitmap;
}

From source file:Main.java

public static Bitmap compressBitmap(Bitmap bitmap, int compressFactor) {
    Matrix matrix = new Matrix();
    matrix.postScale(1.0f / compressFactor, 1.0f / compressFactor);
    bitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
    return bitmap;
}

From source file:Main.java

public static Bitmap mirrorImage(@NonNull Bitmap resultBitmap) {
    Matrix matrix = new Matrix();
    matrix.preScale(-1.0f, 1.0f);//  w  w w . j a v  a  2  s.  co m

    Bitmap returnBitmap = Bitmap.createBitmap(resultBitmap, 0, 0, resultBitmap.getWidth(),
            resultBitmap.getHeight(), matrix, false);

    resultBitmap.recycle();

    return returnBitmap;
}

From source file:Main.java

public static Bitmap rotate(Bitmap b, int degrees) {
    if (degrees != 0 && b != null) {
        Matrix m = new Matrix();
        m.setRotate(degrees, (float) b.getWidth() / 2, (float) b.getHeight() / 2);
        try {//  www.j  av  a 2 s.c  o  m
            Bitmap b2 = Bitmap.createBitmap(b, 0, 0, b.getWidth(), b.getHeight(), m, true);
            if (b != b2) {
                return b2;
            } else {
                return b;
            }
        } catch (OutOfMemoryError ex) {
            return b;
        }
    }
    return null;
}

From source file:Main.java

private static Bitmap getScaleLogo(Bitmap logo, int w, int h) {
    if (logo == null)
        return null;
    Matrix matrix = new Matrix();
    float scaleFactor = Math.min(w * 1.0f / 5 / logo.getWidth(), h * 1.0f / 5 / logo.getHeight());
    matrix.postScale(scaleFactor, scaleFactor);
    Bitmap result = Bitmap.createBitmap(logo, 0, 0, logo.getWidth(), logo.getHeight(), matrix, true);
    return result;
}

From source file:Main.java

public static Bitmap scale(Bitmap src, float scale) {
    if (src == null) {
        return null;
    }//from ww  w . j a  va2 s  . c  o m

    Matrix m = new Matrix();
    m.setScale(scale, scale);
    return Bitmap.createBitmap(src, 0, 0, src.getWidth(), src.getHeight(), m, true);
}

From source file:Main.java

public static Bitmap rotateBmp(Bitmap bmp, int degree) {
    int w = bmp.getWidth();
    int h = bmp.getHeight();
    Matrix mtx = new Matrix();
    mtx.postRotate(degree);//from ww  w  . j  a  v a2 s .c  om
    Bitmap rotatedBMP = Bitmap.createBitmap(bmp, 0, 0, w, h, mtx, true);
    return rotatedBMP;
}