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 Bitmap getResizedBitmap(Bitmap bm, int newHeight, int newWidth) {
    int width = bm.getWidth();
    int height = bm.getHeight();
    float scaleWidth = ((float) newWidth) / width;
    float scaleHeight = ((float) newHeight) / height;
    Matrix matrix = new Matrix();
    matrix.postScale(scaleWidth, scaleHeight);
    Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
    return resizedBitmap;
}

From source file:Main.java

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

From source file:Main.java

public static Bitmap getResizedBitmap(Bitmap bitmap, int i, int j) {
    int k = bitmap.getWidth();
    int l = bitmap.getHeight();
    float f = (float) i / (float) k;
    float f1 = (float) j / (float) l;
    Matrix matrix = new Matrix();
    matrix.postScale(f, f1);
    return Bitmap.createBitmap(bitmap, 0, 0, k, l, matrix, false);
}

From source file:Main.java

public static Bitmap scaleExistingBitmap(Bitmap bm, float scaleWidth, float scaleHeight) {

    int width = bm.getWidth();
    int height = bm.getHeight();

    Matrix matrix = new Matrix();
    matrix.postScale(scaleWidth, scaleHeight);

    Bitmap resizedBitmap = Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
    return resizedBitmap;
}

From source file:Main.java

public static Bitmap resizeBitmap(Bitmap bitmap, int maxLength) {
    if (null == bitmap)
        return null;
    int w = bitmap.getWidth();
    int h = bitmap.getHeight();
    float scale = (float) maxLength / h;
    Matrix matrix = new Matrix();
    matrix.postScale(scale, scale);
    Bitmap zoomedBitmap = Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true);
    return zoomedBitmap;
}

From source file:Main.java

public static Bitmap getResizedBitmap(Bitmap bm, float newWidth, float newHeight) {
    int width = bm.getWidth();
    int height = bm.getHeight();
    float scaleWidth = newWidth / width;
    float scaleHeight = newHeight / height;

    Matrix matrix = new Matrix();
    matrix.postScale(scaleWidth, scaleHeight);

    return Bitmap.createBitmap(bm, 0, 0, width, height, matrix, false);
}

From source file:Main.java

public static Bitmap zoomBitmapSize(Bitmap bitmap, float width, float height) {
    if (width <= 0 || height <= 0) {
        return bitmap;
    }/*w  ww .  jav a 2  s . c o m*/
    if (bitmap == null) {
        return null;
    }
    Matrix matrix = new Matrix();
    matrix.postScale(width / bitmap.getWidth(), height / bitmap.getHeight());
    return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}

From source file:Main.java

public static Bitmap zoomBitmapScale(Bitmap bitmap, float sx, float sy) {
    if (sx <= 0 || sy <= 0) {
        return bitmap;
    }//from  w  ww.  j av  a2 s  .  c om
    if (bitmap == null) {
        return null;
    }
    Matrix matrix = new Matrix();
    matrix.postScale(sx, sx);
    return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
}

From source file:Main.java

public static Bitmap resizeImageByWidth(Bitmap defaultBitmap, int targetWidth) {
    int rawWidth = defaultBitmap.getWidth();
    int rawHeight = defaultBitmap.getHeight();
    float targetHeight = targetWidth * (float) rawHeight / (float) rawWidth;
    float scaleWidth = targetWidth / (float) rawWidth;
    float scaleHeight = targetHeight / (float) rawHeight;
    Matrix localMatrix = new Matrix();
    localMatrix.postScale(scaleHeight, scaleWidth);
    return Bitmap.createBitmap(defaultBitmap, 0, 0, rawWidth, rawHeight, localMatrix, true);
}

From source file:Main.java

public static Bitmap big(Bitmap bitmap, float scale) {
    if (bitmap == null) {
        return null;
    }/*from  ww  w .j av a2s.c o m*/
    Matrix matrix = new Matrix();
    matrix.postScale(scale, scale);
    Bitmap resizeBmp = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true);
    if (!bitmap.isRecycled()) {
        bitmap.recycle();
    }
    return resizeBmp;
}