Example usage for android.graphics Matrix postScale

List of usage examples for android.graphics Matrix postScale

Introduction

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

Prototype

public boolean postScale(float sx, float sy) 

Source Link

Document

Postconcats the matrix with the specified scale.

Usage

From source file:Main.java

public static Matrix getScaleMatrix(float toWidth, int fromWidth, float toHeight, int fromHeight) {
    Matrix matrix = new Matrix();
    matrix.postScale(toWidth / fromWidth, toHeight / fromHeight);
    return matrix;
}

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 Bitmap doScale(Bitmap b, float scale) {
    Matrix matrix = new Matrix();
    matrix.postScale(scale, scale);
    b = Bitmap.createBitmap(b, 0, 0, b.getWidth(), b.getHeight(), matrix, true);
    return b;/*w  ww . j  a va 2 s . com*/
}

From source file:Main.java

public static Bitmap zoomBitmap(float scale, Bitmap bitmap) {
    Matrix matrix = new Matrix();
    matrix.postScale(scale, scale);
    Bitmap newBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
    return newBitmap;
}

From source file:Main.java

private static Bitmap small(Bitmap bitmap) {
    Matrix matrix = new Matrix();
    matrix.postScale(0.8f, 0.8f);
    Bitmap resizeBmp = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
    return resizeBmp;
}

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

From source file:Main.java

public static Bitmap resize(Bitmap bmp, int width, int height) {
    float sx = (width * 1.0f) / bmp.getWidth();
    float sy = (height * 1.0f) / bmp.getHeight();
    Matrix matrix = new Matrix();
    matrix.postScale(sx, sy);
    return Bitmap.createBitmap(bmp, 0, 0, bmp.getWidth(), bmp.getHeight(), matrix, true);
}

From source file:Main.java

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