Skip to content

Instantly share code, notes, and snippets.

@SpiritOfDarkDragon
Created August 1, 2014 14:03
Show Gist options
  • Save SpiritOfDarkDragon/5814cd4c3f15c4633e11 to your computer and use it in GitHub Desktop.
Save SpiritOfDarkDragon/5814cd4c3f15c4633e11 to your computer and use it in GitHub Desktop.
public static Bitmap resizeImage(Bitmap inputBitmap, int newHeight, int newWidth) {
int width = inputBitmap.getWidth();
int height = inputBitmap.getHeight();
float scaleWidth = ((float) newWidth) / width;
float scaleHeight = ((float) newHeight) / height;
Matrix matrix = new Matrix();
matrix.postScale(scaleWidth, scaleHeight);
return Bitmap.createBitmap(inputBitmap, 0, 0, width, height, matrix, false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment