Skip to content

Instantly share code, notes, and snippets.

@weitsai
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weitsai/80b1dd8050cac64a1b64 to your computer and use it in GitHub Desktop.
Save weitsai/80b1dd8050cac64a1b64 to your computer and use it in GitHub Desktop.
Bitmap bitmap = Media.getBitmap(mContext.getContentResolver(), data.getData());
Matrix vMatrix = new Matrix();
int newWidth = 200;
float scaleWidth = newWidth / bitmap.getWidth();
int newHeight = 200;
float scaleHeight = newHeight / bitmap.getHeight();
vMatrix.postScale(scaleWidth, scaleHeight);
Bitmap newBitmap = Bitmap.createBitmap(bitmap, 0, 0, bitmap.getWidth(), bitmap.getHeight(), vMatrix, true);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment