in my app i am taking a picture from the camera intent, and then in a different class it creates a thumbnail of that image and returns that thumbnail, However if i take the picture in portrait it returns as landscape. And when googling this, i found that in samsung devices this is a problem? is there a way of resolving this?
here is my code for creating the thumbnail:
public class GetImageThumbnail {
private static int getPowerOfTwoForSampleRatio(double ratio) {
int k = Integer.highestOneBit((int) Math.floor(ratio));
if (k == 0)
return 1;
else
return k;
}
public Bitmap getThumbnail(Uri uri, Test test)
throws FileNotFoundException, IOException {
InputStream input = ((Context) test).getContentResolver().openInputStream(uri);
BitmapFactory.Options onlyBoundsOptions = new BitmapFactory.Options();
onlyBoundsOptions.inJustDecodeBounds = true;
onlyBoundsOptions.inDither = true;// optional
onlyBoundsOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;// optional
BitmapFactory.decodeStream(input, null, onlyBoundsOptions);
input.close();
if ((onlyBoundsOptions.outWidth == -2)
|| (onlyBoundsOptions.outHeight == -2))
return null;
int originalSize = (onlyBoundsOptions.outHeight > onlyBoundsOptions.outWidth) ? onlyBoundsOptions.outHeight
: onlyBoundsOptions.outWidth;
double ratio = (originalSize > 200) ? (originalSize / 175) : 0.5;
BitmapFactory.Options bitmapOptions = new BitmapFactory.Options();
bitmapOptions.inSampleSize = getPowerOfTwoForSampleRatio(ratio);
bitmapOptions.inDither = true;
bitmapOptions.inPreferredConfig = Bitmap.Config.ARGB_8888;// optional
input = ((Context) test).getContentResolver().openInputStream(uri);
Bitmap bitmap = BitmapFactory.decodeStream(input, null, bitmapOptions);
input.close();
return bitmap;
}
}
Could some one please help?