Android图片缩放
/** * 图片缩放,返回缩放后的图片 * @param src 原图 * @param scale 缩放倍数 */ public static Bitmap scaleImage(Bitmap src, float scale){ int w = src.getWidth() ; int h = src.getHeight() ; int nw = (int) (w * scale) ; int nh = (int) (h * scale) ; Bitmap nb = Bitmap.createBitmap(nw, nh, src.getConfig()) ; Canvas canvas = new Canvas(nb) ; Rect srcRect = new Rect(0, 0, w, h) ; Rect dstRect = new Rect(0, 0, nw, nh) ; Paint paint = new Paint() ; paint.setColor(0xff000000); canvas.drawBitmap(src, srcRect, dstRect, paint); return nb ; }