/** * 缩放处理 * @param scaling 缩放比例 * @return 缩放后的图片 */ public Bitmap scale(float scaling) { Matrix matrix = new Matrix(); matrix.postScale(scaling, scaling); return Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), matrix, true); } /** * 缩放处理 * @param newWidth 新的宽度 * @return Bitmap */ public Bitmap scaleByWidth(int newWidth) { return scale((float) newWidth / bitmap.getWidth()); } /** * 缩放处理 * @param newHeight 新的高度 * @return Bitmap */ public Bitmap scaleByHeight(int newHeight) { return scale((float) newHeight / bitmap.getHeight()); }
图片的缩放
最新推荐文章于 2023-01-16 11:49:49 发布