Android Question CameraExClass, Image orientation problem

johnerikson

Active Member
Licensed User
Longtime User
I use CameraExClass to save the images on Mobiles Galaxy 3 and 4
When mobile phone is turned so that the.GetField ("orientation") is 180 degrees (landscape up and down), the image appears upright in preview mode in the screen. But the image taken is however, sideways (Up and down).
The following code in CameraExClass does not affect the result
r. RunMethod2 ("setDisplayOrientation", previewResult, "java.lang.int")
r. RunMethod2 ("setRotation", result, "java.lang.int") ' no response

The next problem is that the image is impossible to rotate, all functions I try results in "out of memory"!
The mobile are mounted and can’t change orientation!
How do I resolve the presentation of the image in an upright position in the Mobile?
/Johneriksson
 

Sub7

Active Member
Licensed User
Longtime User
I think you need to read the image metadata to better understand what's going on.

Dim exif As ExifData
exif.Initialize(Dir,Camerafilename)
exif.getAttribute(xxxx)
 
Upvote 0

Sub7

Active Member
Licensed User
Longtime User
I had same problem with my galaxy 9300, Android gallery on galaxy (at least on mine) rotates the images so you can see them correctly, but if you pick them and put on a imageview they are rotated, so for that i needed to read the metadata and rotate them when needed.
 
Upvote 0

johnerikson

Active Member
Licensed User
Longtime User
Are you testing the example that comes with CameraEx class? It should show the preview in the correct orientation.
It is based on Google code. If it doesn't work then there is most probably a problem on your device.

It show the preview in the correct orientation but after taken the picture and saved it on file and Initialized the file to a bitmap and add on an ImageView the Image displayed Up and down.
If I use Microsoft Office Picture Manager to show the Picture, it's still up and down. But...........
If I use PaintShop Pro the picture shows upright without using a function. In that program I can read image metadata, but I don't see any suspects in this data!
/Johneriksson
 
Upvote 0

Sub7

Active Member
Licensed User
Longtime User
It show the preview in the correct orientation but after taken the picture and saved it on file and Initialized the file to a bitmap and add on an ImageView the Image displayed Up and down.
If I use Microsoft Office Picture Manager to show the Picture, it's still up and down. But...........
If I use PaintShop Pro the picture shows upright without using a function. In that program I can read image metadata, but I don't see any suspects in this data!
/Johneriksson

Is what i told you, i had the same issue few weeks ago, from what you have said the issue looked like you had a problem with the preview, and not loading an image into an imageview.


I resolved by writing this code:

B4X:
exif.Initialize(Dir,Camerafilename)

    If exif.getAttribute(exif.TAG_ORIENTATION) = 6 Then
        image = imageProcessor.rotate(ToGrayScale2,90)


    Else If exif.getAttribute(exif.TAG_ORIENTATION) = 8 Then
        image= imageProcessor.rotate(ToGrayScale2,-90)
    End If

But i suggest you to wait for @Erel as this code is not in production and i dont know if it works on all devices (works on galaxy)
 
Last edited:
Upvote 0

johnerikson

Active Member
Licensed User
Longtime User
It seams to me I had better try to change The Metadata Attribute, if it possibly, rather than rotate the bitmap.
That because I have problems to rotate this big picture - files which causes Out Of Memory Error.
I know how to read Attributes but not how to update the header so...
If someone have knowledge about that tell me please!
I go on searching if it already it reported!
 
Upvote 0

johnerikson

Active Member
Licensed User
Longtime User
Information from myself...
I discovered that it isn't possible to got any affect of rotating displaying pictures throw changes metadata!
So from now I had to understand why the out of memory appear when I try to rotate the bitmap!
Or if I can send a command to the internal camera to understand the real orientation and scan the image as I see it in the screen!
Perhaps it somebody who knows, you are welcome!
 
Upvote 0

TheFalcon

Active Member
Licensed User
Longtime User
Hi, sorry for my English. I have the same problem loading the image into a Imageview. If I make the picture with the phone in the normal position, my daleada presented in imageview. If I make photo with me Movil in Horizontal presents the image in imageview Good. always want this straight but I can not find that modify the library cameraexclass
 
Upvote 0

TheFalcon

Active Member
Licensed User
Longtime User
Thanks, i was trying that solution but the JPGUTILS aparde the library to library need not to recognize me
B4X:
 imageProcessor.rotate(ToGrayScale2,90)
 
Upvote 0

Sub7

Active Member
Licensed User
Longtime User
Thanks, i was trying that solution but the JPGUTILS aparde the library to library need not to recognize me
B4X:
 imageProcessor.rotate(ToGrayScale2,90)

You don't need to use tograyscale, it was just for my task.
What's the mean of this phrase: aparde the library to library need not to recognize me, i don't get it sorry.
 
Upvote 0

TheFalcon

Active Member
Licensed User
Longtime User
I'm sorry that my English is not very good.
That line of code I get in red B4 did not detect the line

imageProcessor.rotate
 
Upvote 0

imbault

Well-Known Member
Licensed User
Longtime User
Is what i told you, i had the same issue few weeks ago, from what you have said the issue looked like you had a problem with the preview, and not loading an image into an imageview.


I resolved by writing this code:

B4X:
exif.Initialize(Dir,Camerafilename)

    If exif.getAttribute(exif.TAG_ORIENTATION) = 6 Then
        image = imageProcessor.rotate(ToGrayScale2,90)


    Else If exif.getAttribute(exif.TAG_ORIENTATION) = 8 Then
        image= imageProcessor.rotate(ToGrayScale2,-90)
    End If

But i suggest you to wait for @Erel as this code is not in production and i dont know if it works on all devices (works on galaxy)
@Sub7, can you provide help about that code, I'm having the same issue on Galaxy S4, S5, xCover3...

Many thanks

Patrick
 
Upvote 0
Top