Example usage for android.graphics Bitmap createScaledBitmap

List of usage examples for android.graphics Bitmap createScaledBitmap

Introduction

In this page you can find the example usage for android.graphics Bitmap createScaledBitmap.

Prototype

public static Bitmap createScaledBitmap(@NonNull Bitmap src, int dstWidth, int dstHeight, boolean filter) 

Source Link

Document

Creates a new bitmap, scaled from an existing bitmap, when possible.

Usage

From source file:Main.java

public static Bitmap getResizeBitmap(Bitmap bitmap, int width, int height) {
    return bitmap != null ? bitmap.createScaledBitmap(bitmap, width, height, true) : null;
}

From source file:Main.java

public static Bitmap scaleToFitWidth(Bitmap bitmap, int i) {
    return Bitmap.createScaledBitmap(bitmap, i,
            (int) (((float) i / (float) bitmap.getWidth()) * (float) bitmap.getHeight()), false);
}

From source file:Main.java

public static Bitmap scaleToFitHeight(Bitmap bitmap, int i) {
    return Bitmap.createScaledBitmap(bitmap,
            (int) (((float) i / (float) bitmap.getHeight()) * (float) bitmap.getWidth()), i, false);
}

From source file:Main.java

public static Bitmap scaleBitmap(Bitmap bitmap, float pct) {
    return Bitmap.createScaledBitmap(bitmap, Math.round(bitmap.getWidth() * pct),
            Math.round(bitmap.getHeight() * pct), true);
}

From source file:Main.java

public static int getDominantColor(Bitmap bitmap) {
    Bitmap newBitmap = Bitmap.createScaledBitmap(bitmap, 1, 1, true);
    final int color = newBitmap.getPixel(0, 0);
    newBitmap.recycle();/*from w w  w.  j av a  2 s  . com*/
    return color;
}

From source file:Main.java

public static Bitmap zoomBitmap(Bitmap bitmap, int width, int height) {
    return Bitmap.createScaledBitmap(bitmap, width, height, false);
}

From source file:Main.java

public static Bitmap resizeBitmapSize(Bitmap src, int width, int height) {
    return Bitmap.createScaledBitmap(src, width, height, true);
}

From source file:Main.java

public static Bitmap getScaleBitmap(Bitmap source, int width, int height) {
    return Bitmap.createScaledBitmap(source, width, height, false);
}

From source file:Main.java

public static Bitmap scale(Bitmap bm, double widthScale, double heightScale) {
    return Bitmap.createScaledBitmap(bm, (int) (bm.getWidth() * widthScale),
            (int) (bm.getHeight() * heightScale), false);
}

From source file:Main.java

public static Bitmap createBitmapBySize(Bitmap bitmap, int width, int height) {
    return Bitmap.createScaledBitmap(bitmap, width, height, true);
}