Here you can find the source of scaleImage(Bitmap image, float scale)
Parameter | Description |
---|---|
image | to scale |
scale | amount |
public static Bitmap scaleImage(Bitmap image, float scale)
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Rect; public class Main { /**//w ww .j av a2s. co m * scales {@link Bitmap} to a decimal * * @param image * to scale * @param scale * amount * @return scaled image */ public static Bitmap scaleImage(Bitmap image, float scale) { Bitmap data = Bitmap.createBitmap((int) (image.getWidth() * scale), (int) (image.getHeight() * scale), image.getConfig()); Canvas canvas = new Canvas(data); canvas.drawBitmap(image, new Rect(0, 0, image.getWidth(), image.getHeight()), new Rect(0, 0, (int) (image.getWidth() * scale), (int) (image.getHeight() * scale)), null); return data; } }