Here you can find the source of cutStretchImage(Bitmap image, int xsize, int ysize)
Parameter | Description |
---|---|
image | a parameter |
xsize | a parameter |
ysize | a parameter |
public static Bitmap cutStretchImage(Bitmap image, int xsize, int ysize)
//package com.java2s; import android.graphics.Bitmap; import android.graphics.Canvas; import android.graphics.Rect; public class Main { /**//w w w .j a v a 2 s . c o m * cuts the {@link Bitmap} into four corners and stretches the space between them. * * @param image * @param xsize * @param ysize * @return */ public static Bitmap cutStretchImage(Bitmap image, int xsize, int ysize) { Bitmap data = Bitmap.createBitmap((int) (xsize), (int) (ysize), image.getConfig()); Canvas canvas = new Canvas(data); canvas.drawBitmap( image, new Rect(0, 0, image.getWidth() / 2, image.getHeight() / 2), new Rect(0, 0, (int) (image.getWidth() / 2), (int) (image .getHeight() / 2)), null); canvas.drawBitmap( image, new Rect(image.getWidth() / 2, 0, image.getWidth(), image .getHeight() / 2), new Rect(xsize - (image.getWidth() / 2), 0, xsize, (int) (image.getHeight() / 2)), null); canvas.drawBitmap( image, new Rect(0, image.getHeight() / 2, image.getWidth() / 2, image.getHeight()), new Rect(0, ysize - (image.getHeight() / 2), (int) (image .getWidth() / 2), ysize), null); canvas.drawBitmap( image, new Rect(image.getWidth() / 2, image.getHeight() / 2, image .getWidth(), image.getHeight()), new Rect(xsize - (image.getWidth() / 2), ysize - (image.getHeight() / 2), xsize, ysize), null); return data; } }