Android Question LoadBitmapResize, LoadBitmap are rotating images

MrKim

Well-Known Member
Licensed User
Longtime User
What am I missing??

Here is my code

B4X:
                II.SetLayout(0, 0, PH, PW)
                II.Gravity = Gravity.FILL
                II.Bitmap = LoadBitmapResize(Dir, FileName, PW, PH, True)
                P.AddView(II, 0, 0, PW, PH)

This is how it looks when viewed with Photos.



And this is how it looks when loaded into an image view. Notice I have reversed Height and width on some of these.


I have tried changing the gravity and reversing the height and width in any number of combinations to no avail.

here are the specs on the picture.


It appears that the issue is with all pictures taken in portrait mode. Pictures taken in landscape mode load ok.
 

Attachments

  • upload_2019-11-23_7-20-41.png
    95.1 KB · Views: 326
  • upload_2019-11-23_7-21-21.png
    104.1 KB · Views: 335

sorex

Expert
Licensed User
Longtime User
I believe that android's default image handling doesn't take the rotation info into account that is sometimes added to the image header (by cameras?).
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
You would think that the first number would be x and the second y (or vice versa)? I mean ContnetChooser knows which way the picture is oriented. Where does it get its information?
 
Upvote 0

agraham

Expert
Licensed User
Longtime User
From ContentChooser documentation https://www.b4x.com/android/help/phone.html#contentchooser
The ContentChooser object allows the user to select a specific type of content using other installed applications.
For example the user can use the internal Gallery application to select an image.
ContentChooser doesn't know, it is the application you choose that does.

In my experience cameras always save the image in the same orientation relative to the camera. The camera software then uses the device rotation sensor to tag the orientation as landscape or portrait in the EXIF data of the image. This lets the image decoder software orient the image correctly for display.
 
Upvote 0

MrKim

Well-Known Member
Licensed User
Longtime User
I'm just trying to understand here. If ContentChooser doesn't know then why are images always displayed correctly? Some have X>y and some have y>x but content chooser always displays them oriented correctly. And in a view that is sized correctly? This just doesn't make sense to me.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…