Last active
August 29, 2015 13:57
-
-
Save sungitly/9502704 to your computer and use it in GitHub Desktop.
Resize bitmap in Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Bitmap origBitmapOrig = BitmapFactory.decodeFile(imageFilePath); | |
//Resize the image | |
double width = origBitmapOrig.getWidth(); | |
double height = origBitmapOrig.getHeight(); | |
int newWidth = 1600 | |
int newHeight = (int)((newWidth/width)*height); | |
Bitmap newBitmap = Bitmap.createScaledBitmap(origBitmapOrig, newWidth, newHeight, true); | |
ByteArrayOutputStream bos = new ByteArrayOutputStream(); | |
newBitmap.compress(Bitmap.CompressFormat.JPEG, 95, bos); | |
InputStream is = new ByteArrayInputStream(bos.toByteArray()); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment