H heldenssjoerd Member Feb 19, 2024 #1 I've a similar issue like this post however I can't figure it out. CameraExClass Saved Image orientation different then Preview image Hi guys, I have a problem with image orientation taking with CameraEx Class. Here are the problems : 1) on camera preview, image orientation is portrait 2) when picture taken and save to file with these codes Sub Camera_PictureTaken (Data() As Byte) Private filename As String = "1.jpg"... www.b4x.com Our app is completly portrait. However a user can take a picture in every modus, it's a phone so landscape or portrait are options. Using the code below results in allways an portrait preview and imagefile. Even if the picture is taken landscape. B4X: Expand Collapse Copy camEx.SavePictureToFile(DataFoto, File.DirInternal, psFotoFilename) oImageView.Gravity = Gravity.FILL oImageView.Bitmap = camEx.LoadbitmapSample2(File.DirInternal,psFotoFilename,oImageView.Width,oImageView.Height,True) When checking the exif data from the picture, the result i allways 90. Wheter we're holding the phone landscape or portrait B4X: Expand Collapse Copy Dim retValue As Int = 0 Dim filepath As String Dim exif As ExifData filepath = dir & "/" & Filename exif.Initialize("", filepath) ' // Get orientation Dim w As Int = exif.getAttributeInt (exif.TAG_ORIENTATION, 0) If w = exif.ORIENTATION_NORMAL Then retValue = 0 If w = exif.ORIENTATION_ROTATE_90 Then retValue = 90 If w = exif.ORIENTATION_ROTATE_180 Then retValue = 180 If w = exif.ORIENTATION_ROTATE_270 Then retValue = 270 Log(retValue) Return retValue Really need some help with this. Does the portrait mode has something to do with it?
I've a similar issue like this post however I can't figure it out. CameraExClass Saved Image orientation different then Preview image Hi guys, I have a problem with image orientation taking with CameraEx Class. Here are the problems : 1) on camera preview, image orientation is portrait 2) when picture taken and save to file with these codes Sub Camera_PictureTaken (Data() As Byte) Private filename As String = "1.jpg"... www.b4x.com Our app is completly portrait. However a user can take a picture in every modus, it's a phone so landscape or portrait are options. Using the code below results in allways an portrait preview and imagefile. Even if the picture is taken landscape. B4X: Expand Collapse Copy camEx.SavePictureToFile(DataFoto, File.DirInternal, psFotoFilename) oImageView.Gravity = Gravity.FILL oImageView.Bitmap = camEx.LoadbitmapSample2(File.DirInternal,psFotoFilename,oImageView.Width,oImageView.Height,True) When checking the exif data from the picture, the result i allways 90. Wheter we're holding the phone landscape or portrait B4X: Expand Collapse Copy Dim retValue As Int = 0 Dim filepath As String Dim exif As ExifData filepath = dir & "/" & Filename exif.Initialize("", filepath) ' // Get orientation Dim w As Int = exif.getAttributeInt (exif.TAG_ORIENTATION, 0) If w = exif.ORIENTATION_NORMAL Then retValue = 0 If w = exif.ORIENTATION_ROTATE_90 Then retValue = 90 If w = exif.ORIENTATION_ROTATE_180 Then retValue = 180 If w = exif.ORIENTATION_ROTATE_270 Then retValue = 270 Log(retValue) Return retValue Really need some help with this. Does the portrait mode has something to do with it?
Erel B4X founder Staff member Licensed User Longtime User Feb 20, 2024 #2 heldenssjoerd said: Our app is completly portrait. However a user can take a picture in every modus, it's a phone so landscape or portrait are options. Click to expand... The app is locked in portrait mode and the user takes the picture in landscape mode? Upvote 0
heldenssjoerd said: Our app is completly portrait. However a user can take a picture in every modus, it's a phone so landscape or portrait are options. Click to expand... The app is locked in portrait mode and the user takes the picture in landscape mode?
H heldenssjoerd Member Feb 20, 2024 #3 Erel said: The app is locked in portrait mode and the user takes the picture in landscape mode? Click to expand... Correct. The app is portrait. But the user can ofcourse flip the phone and take a picture. Upvote 0
Erel said: The app is locked in portrait mode and the user takes the picture in landscape mode? Click to expand... Correct. The app is portrait. But the user can ofcourse flip the phone and take a picture.
Erel B4X founder Staff member Licensed User Longtime User Feb 20, 2024 #4 I think that your best (most reliable) option is to let the user rotate the image. It should be simple to implement with B4XBitmap.Rotate Upvote 0
I think that your best (most reliable) option is to let the user rotate the image. It should be simple to implement with B4XBitmap.Rotate
H heldenssjoerd Member Feb 20, 2024 #5 Is there no other possibility? Like setting just this view to not portrait? The app is not build with/for b4xpages Upvote 0
Is there no other possibility? Like setting just this view to not portrait? The app is not build with/for b4xpages
DonManfred Expert Licensed User Longtime User Feb 20, 2024 #6 heldenssjoerd said: Like setting just this view to not portrait? Click to expand... no such thing available Upvote 0
heldenssjoerd said: Like setting just this view to not portrait? Click to expand... no such thing available
H heldenssjoerd Member Feb 20, 2024 #7 I think I've found a workaround. In Main we set the B4X: Expand Collapse Copy #SupportedOrientations: unspecified 'used to be portrait In every view/activity that should not rotate we set, in the create, the following B4X: Expand Collapse Copy Dim phone As Phone phone.SetScreenOrientation(1) Then there is no rotation possible. All other activities and views need to be checked and tested. Upvote 0
I think I've found a workaround. In Main we set the B4X: Expand Collapse Copy #SupportedOrientations: unspecified 'used to be portrait In every view/activity that should not rotate we set, in the create, the following B4X: Expand Collapse Copy Dim phone As Phone phone.SetScreenOrientation(1) Then there is no rotation possible. All other activities and views need to be checked and tested.
S Surreal Member Licensed User Longtime User Apr 8, 2025 #8 Good morning Why if phone.SetScreenOrientation(0) the preview image is distorted? Is there a way to prevent this from happening? Thanks Upvote 0
Good morning Why if phone.SetScreenOrientation(0) the preview image is distorted? Is there a way to prevent this from happening? Thanks