Here you can find the source of stretchImage(Bitmap image, float xscale, float yscale)
Parameter | Description |
---|---|
image | a parameter |
xscale | a parameter |
yscale | a parameter |
public static Bitmap stretchImage(Bitmap image, float xscale, float yscale)
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Rect; public class Main { /**/* w w w . java 2 s . c om*/ * Stretches {@link Bitmap} to a scale in each direction. * * @param image * @param xscale * @param yscale * @return */ public static Bitmap stretchImage(Bitmap image, float xscale, float yscale) { Bitmap data = Bitmap.createBitmap( (int) (image.getWidth() * xscale), (int) (image.getHeight() * yscale), 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() * xscale), (int) (image.getHeight() * yscale)), null); return data; } /** * Stretches {@link Bitmap} to a scale in each direction. * * @param image * @param xsize * @param ysize * @return */ public static Bitmap stretchImage(Bitmap image, int xsize, int ysize) { Bitmap data = Bitmap.createBitmap(xsize, ysize, image.getConfig()); Canvas canvas = new Canvas(data); canvas.drawBitmap(image, new Rect(0, 0, image.getWidth(), image.getHeight()), new Rect(0, 0, xsize, ysize), null); return data; } }