Android 图片压缩二:

来源:互联网 发布:国内家具品牌知乎 编辑:程序博客网 时间:2024/04/29 17:23
public Bitmap zoomBitmap(Bitmap bitmap, int width, int height) {int w = bitmap.getWidth();int h = bitmap.getHeight();Matrix matrix = new Matrix();float scaleWidth = ((float) width / w);float scaleHeight = ((float) height / h);matrix.postScale(scaleWidth, scaleHeight);// 利用矩阵进行缩放不会造成内存溢出Bitmap newbmp = Bitmap.createBitmap(bitmap, 0, 0, w, h, matrix, true);return newbmp;}


 

原创粉丝点击