public static Bitmap getResizeBitmap (Bitmap img, int newWidth, int newHeight) {
double ratio = newWidth / img.getWidth();
ratio = (newHeight / img.getHeight()) < ratio ? (newHeight / img.getHeight()) : ratio;
Bitmap b2 = Bitmap.createScaledBitmap(img, (int) (img.getWidth() * ratio), (int) (img.getHeight() * ratio), true);
return b2;
}
No comments:
Post a Comment