Here you can find the source of stretchImage(Bitmap image, int xsize, int ysize)
Parameter | Description |
---|---|
image | a parameter |
xsize | a parameter |
ysize | a parameter |
public static Bitmap stretchImage(Bitmap image, int xsize, int ysize)
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Rect; public class Main { /**/*from w ww. j a v a2s .co m*/ * 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; } }