-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix Image Scaling/Rotating #14501
Fix Image Scaling/Rotating #14501
Conversation
app/src/main/java/com/owncloud/android/ui/preview/PreviewImageFragment.kt
Outdated
Show resolved
Hide resolved
81b0169
to
bb2846e
Compare
bb2846e
to
6af4c0f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested various images with different sizes, including both landscape and portrait orientations. Throughout the testing process, I did not encounter any issues.
Thank you for the PR 💯
6af4c0f
to
f027cdc
Compare
@alexknop Could you fix the spotlessKotlinCheck?
Thank you. |
@alperozturk96 Done, I believe. Thanks. |
Signed-off-by: Alex Knop <[email protected]>
Signed-off-by: Alex Knop <[email protected]>
4618e65
to
ffedbd3
Compare
/backport to stable-3.31 |
Problem:
Application is opening some images incorrectly. The image is being rotated incorrectly and the wrong heights/widths are being used for scaling.
For example, this image with a Width of 4096 pixels and Height of 3072 pixels and an orientation of upper-right was showing like this:
![image](https://private-user-images.githubusercontent.com/11878115/410172865-fc1cd8c5-99cc-4bd8-be04-8a7996e34c06.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MzkzOTU0NjIsIm5iZiI6MTczOTM5NTE2MiwicGF0aCI6Ii8xMTg3ODExNS80MTAxNzI4NjUtZmMxY2Q4YzUtOTljYy00YmQ4LWJlMDQtOGE3OTk2ZTM0YzA2LnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNTAyMTIlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjUwMjEyVDIxMTkyMlomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPWEwYjVkZTNkY2NkOGQxNzkxZGRmNDRkNTFkMmY2MDhkOGYzNzNjMTVlODM3MTJlMzdlZDRiNTViOGRiNTQwOTEmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0In0.2Y34SE0wsBmPnZaG6cnIsHpsR0Yawfyy6ohQY6xRqSk)
My screen size is 1080x2460
It appears after BitmapUtils.decodeSampledBitmapFromFile() is run, that the orientation is changed successfully.
The problem then was the height/width used. When originally using my screen size, the scaling was affected by stretching the image to fit the height of my screen. It needs to maintain the original aspect ratio of the image.
The image was then being rotated again, thus resulting in the image above.
Solution:
Take original heights and widths of file.
Determine if this image is to be rotated 90 or 270 degrees. If so, the height and width needs to accommodate for that.
Now, decode the bitmap using the original image's height/width.
Next, scale the image based on your screen size.