Android中按照固定长宽缩放图片

来源:互联网 发布:华为大数据是干什么的 编辑:程序博客网 时间:2024/06/05 06:26
private Bitmap getMetadataBitmap(Bitmap bm){        int width = bm.getWidth();      int height = bm.getHeight();      //固定的长宽      int newWidth = 90;      int newHeight = 130;      float scaleWidth = ((float) newWidth) / width;      float scaleHeight = ((float) newHeight) / height;      Matrix matrix = new Matrix();      matrix.postScale(scaleWidth, scaleHeight);      Bitmap newbm = Bitmap.createBitmap(bm, 0, 0, width, height, matrix,        true);      return newbm;  }


 

0 0