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

private static Bitmap createScaledBitmap(Bitmap bitmap, float scale, int width, int height) {
    if (bitmap == null) {
        return null;
    }//from   www .  j av a 2  s. co m

    Matrix matrix = new Matrix();
    matrix.postScale(scale, scale);

    Bitmap scaledBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);

    return scaledBitmap;
}

From source file:Main.java

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

From source file:Main.java

public static Bitmap resizeImage(Bitmap bitmap, int newWidth, int newHeight) {
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();

    float scaleWidth = ((float) newWidth) / width;
    float scaleHeight = ((float) newHeight) / height;

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

    Bitmap resizedBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
    return resizedBitmap;
}

From source file:Main.java

public static Bitmap scale(@NonNull Bitmap in, float wRadius, float yRadius) {
    Matrix matrix = new Matrix();
    matrix.postScale(wRadius, yRadius);
    return Bitmap.createBitmap(in, 0, 0, in.getWidth(), in.getHeight(), matrix, true);
}

From source file:Main.java

/**
 * scale image/*ww  w. j  a  v  a  2 s . c  om*/
 *
 * @param org
 * @param scaleWidth  sacle of width
 * @param scaleHeight scale of height
 * @return
 */
public static Bitmap scaleImage(Bitmap org, float scaleWidth, float scaleHeight) {
    if (org == null) {
        return null;
    }
    Matrix matrix = new Matrix();
    matrix.postScale(scaleWidth, scaleHeight);
    return Bitmap.createBitmap(org, 0, 0, org.getWidth(), org.getHeight(), matrix, true);
}

From source file:Main.java

public static Bitmap scaleBitmap(Bitmap srcBitmap, int newSize) {
    int w = srcBitmap.getWidth();
    int h = srcBitmap.getHeight();

    // Determine the scaling required to get desired result.
    float scaleW = newSize / (float) w;
    float scaleH = newSize / (float) h;

    Matrix matrix = new Matrix();
    matrix.postScale(scaleW, scaleH);

    return Bitmap.createBitmap(srcBitmap, 0, 0, w, h, matrix, false);
}

From source file:Main.java

public static Bitmap bigImage(Bitmap bmp, float big) {
    int bmpWidth = bmp.getWidth();
    int bmpHeight = bmp.getHeight();
    Matrix matrix = new Matrix();
    matrix.postScale(big, big);
    return Bitmap.createBitmap(bmp, 0, 0, bmpWidth, bmpHeight, matrix, true);
}

From source file:Main.java

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

From source file:Main.java

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

From source file:Main.java

public static Bitmap scaleImage(Bitmap bitmap, int destW, int destH) {
    if (bitmap == null) {
        return null;
    }//from  w ww. java2 s .c  o  m
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();

    float scaleWidth = ((float) destW) / width;
    float scaleHeight = ((float) destH) / height;

    Matrix matrix = new Matrix();
    matrix.postScale(scaleWidth, scaleHeight);
    Bitmap scaledBitmap = Bitmap.createBitmap(bitmap, 0, 0, width, height, matrix, true);
    return scaledBitmap;
}