12 Bitmap缩放
1 public Bitmap zoomImage(Bitmap bgimage, double newWidth, 2 double newHeight) { 3 // 获取这个图片的宽和高 4 float width = bgimage.getWidth(); 5 float height = bgimage.getHeight(); 6 // 创建操作图片用的matrix对象 7 Matrix matrix = new Matrix(); 8 // 计算宽高缩放率 9 float scaleWidth = ((float) newWidth) / width; 10 float scaleHeight = ((float) newHeight) / height; 11 // 缩放图片动作 12 matrix.postScale(scaleWidth, scaleHeight); 13 Bitmap bitmap = Bitmap.createBitmap(bgimage, 0, 0, (int) width, 14 (int) height, matrix, true); 15 return bitmap; 16 }