Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 713
Levimatt Avatar asked Jan 25 '26 18:01

Levimatt


1 Answers

            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?

like image 51
jack Avatar answered Jan 28 '26 06:01

jack



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!