I picked an image from gallery and decoded it. Now I just want to resize that bitmap to standard 72x72 size in order to use as an profile photo.
I searched a lot but nothing worked, some of them rotated my image for no reason, some of them makes image very low quality. Is it that hard?
Check scaled 72x72 and original one:
72x72 (As you see, rotated and very bad quality) http://imgim.com/9958incic3494599.png
original: http://imgim.com/3847incix7666386.png
Code:
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent imageReturnedIntent)
{
super.onActivityResult(requestCode, resultCode, imageReturnedIntent);
switch(requestCode)
{
case 100: // SELECT_PHOTO
if(resultCode == RESULT_OK)
{
Uri selectedImage = imageReturnedIntent.getData();
InputStream imageStream;
try
{
imageStream = getContentResolver().openInputStream(selectedImage);
}catch (Exception e){ return; }
Bitmap bm = BitmapFactory.decodeStream(imageStream);
bm = Bitmap.createScaledBitmap(bm, 72, 72, true);
UpdateAvatar(bm);
}
break;
}
}