Android 使用图片铺满某个区域
/** * 使用图片铺满某个区域,返回整个铺满的图片 * @param src 原图片 * @param rect 要铺满的区域大小 */ public static Bitmap getTile(Bitmap src, Size rect){ int w = src.getWidth() ; int h = src.getHeight() ; int column = (int) Math.ceil( ((float)rect.width)/w ) ; int row = (int) Math.ceil( ((float)rect.height)/h ) ; Bitmap nb = Bitmap.createBitmap(rect.width, rect.height, src.getConfig()) ; Canvas canvas = new Canvas(nb) ; Paint paint = new Paint() ; paint.setColor(0xff000000); for (int i = 0; i < row; i++) { for (int j = 0; j < column; j++) { canvas.drawBitmap(src, j*w, i*h, paint); } } return nb ; }