Levimatt
Levimatt

Reputation: 453

Issue when displaying a thumbnail using Thumbnailutils

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.

Upvotes: 3

Views: 1122

Answers (1)

jack
jack

Reputation: 21

            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?

Upvotes: 2

Related Questions