3

I'm using this code to get a thumbnail from a full size image path:

imagenThumbnail = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(pathImagen), 320, 320);

The problem is that when i use an imageview to display the thumbnail it is displayed the thumbnail rotated 90 degrees to the right. The image has been taken in vertical mode but i don't know why it is displayed rotated.

Any suggestion will be welcome.

Thank you in advanced.

Levimatt
  • 453
  • 1
  • 11
  • 28

1 Answers1

2
            ImageView iv;
            iv = (ImageView)findViewById(R.id.imageView);
            int THUMBSIZE = 64;

            // rotate bmpThumbImage
            Bitmap bmpThumbImage = ThumbnailUtils.extractThumbnail(BitmapFactory.decodeFile(fileUri.getPath()), THUMBSIZE, THUMBSIZE);
            iv.setScaleType(ImageView.ScaleType.CENTER_CROP);
            Matrix matrix = new Matrix();
            matrix.postRotate(90);
            bmpThumbImage = Bitmap.createBitmap(bmpThumbImage, 0, 0, bmpThumbImage.getWidth(),
                    bmpThumbImage.getHeight(), matrix, true);
            iv.setImageBitmap(bmpThumbImage);

How display thumbnail of video the same view of camera?

Community
  • 1
  • 1
jack
  • 21
  • 3
  • 5
    what if you don't know the initial orientation of the image? – njzk2 Feb 13 '15 at 18:59
  • I am not facing this issue on every Android device. How do I know when I have to rotate bitmap by 90? Happening to selected devices. – Perry Feb 17 '20 at 07:03