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 zoomBitmap(Bitmap bitmap, int width, int height) {
    int w = bitmap.getWidth();
    int h = bitmap.getHeight();
    Matrix matrix = new Matrix();
    matrix.postScale((float) width / w, (float) height / h);
    return Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true);
}

From source file:Main.java

public static Bitmap zoomBMP(Bitmap bitmap, int height, int width) {
    int w = bitmap.getWidth();
    int h = bitmap.getHeight() - 1;
    Matrix matrix = new Matrix();
    float scaleHeight = ((float) height / h);
    matrix.postScale(scaleHeight, scaleHeight);
    return Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true);
}

From source file:Main.java

public static Bitmap zoomBitmap(Bitmap bitmap, float scale) {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    Matrix matrix = new Matrix();
    matrix.postScale(scale, scale);//w  ww . j av a2s .co m
    Bitmap newbmp = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
    return newbmp;
}

From source file:Main.java

/**
 *
 * @param source/*from   www . j  av  a  2  s  .com*/
 * @param angle
 * @return
 */
private static Bitmap rotateImage(Bitmap source, float angle) {
    Matrix matrix = new Matrix();
    matrix.postRotate(angle);
    return Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
}

From source file:Main.java

/**
 * @param b//  w w w  .j a  va  2s . c  o  m
 * @param rotateDegree
 * @return
 */
public static Bitmap getRotateBitmap(Bitmap b, float rotateDegree) {
    Matrix matrix = new Matrix();
    matrix.postRotate(rotateDegree);
    int width = b.getWidth();
    int height = b.getHeight();
    return Bitmap.createBitmap(b, 0, 0, width, height, matrix, false);
}

From source file:Main.java

public static Bitmap PicZoom(Bitmap bmp, int width, int height) {
    int bmpWidth = bmp.getWidth();
    int bmpHeght = bmp.getHeight();
    Matrix matrix = new Matrix();
    matrix.postScale((float) width / bmpWidth, (float) height / bmpHeght);
    return Bitmap.createBitmap(bmp, 0, 0, bmpWidth, bmpHeght, matrix, true);
}

From source file:Main.java

public static Bitmap zoomBitmap(Bitmap bitmap, int width, int height) {
    int w = bitmap.getWidth();
    int h = bitmap.getHeight();
    Matrix matrix = new Matrix();
    float scaleWidht = (float) width / w;
    float scaleHeight = (float) height / h;
    matrix.postScale(scaleWidht, scaleHeight);
    return Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
}

From source file:Main.java

public static Bitmap zoomBitmap(Bitmap source, float w, float h) {
    int height = source.getHeight();
    int width = source.getWidth();
    Matrix matrix = new Matrix();
    matrix.postScale(w / width, h / height);
    Bitmap bitmap = Bitmap.createBitmap(source, 0, 0, source.getWidth(), source.getHeight(), matrix, true);
    return bitmap;
}

From source file:Main.java

public static Bitmap rotateBitmapDegrees(Bitmap bitmap, int orientation) {
    if (orientation == 0) {
        return bitmap;
    }//from w w w  . ja v a 2s.c o m

    Matrix matrix = new Matrix();
    matrix.setRotate(orientation);
    Bitmap bmRotated = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
    bitmap.recycle();
    return bmRotated;
}

From source file:Main.java

public static Bitmap zoomBitmap(Bitmap bitmap, int width, int height) {
    int w = bitmap.getWidth();
    int h = bitmap.getHeight();
    Matrix matrix = new Matrix();
    float scaleWidth = ((float) width / w);
    float scaleHeight = ((float) height / h);
    matrix.postScale(scaleWidth, scaleHeight);
    return Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true);
}