Android Question Photo taken correctly, imageview shows it rotated

jaraiza

Active Member
Licensed User
Longtime User
Hi,

I'm sure this has been asked before, but I haven't found an answer without using lots of rotation code.

I took a photo (640x480) using CameraEX and I'm getting weird results with the photo.

If I load it in DirectoryOpus or Photoshop the image loads ok (just as taken) but if I load it in Fireworks or B4A (ImageViews) it loads rotated.

This is an example:

xhvDqIU.jpg


I'm including the photo just as it was taken with the device.

Is there anyway to load it the way it's meant to be inside B4A?

Thanks a lot!
 

Attachments

  • foto.zip
    40.6 KB · Views: 212

jaraiza

Active Member
Licensed User
Longtime User
I think I've found the difference... It's the EXIF data, if I clear EXIF the image will always load rotated (Now Photoshop and DOpus also load it like B4A).

Is there anyway ImageViews take EXIF data in consideration so it loads correctly?

Thanks!
 
Upvote 0

jaraiza

Active Member
Licensed User
Longtime User
Well... Now I have a related problem.

The photo loads inside ImageView ok, but I have to upload it to a website. The problem is when I download the photo it's rotated again. I used a WebService and the uploaded file still has Exif data.

First, I used (after httputils2):
B4X:
Dim BMFoto As Bitmap
BMFoto.Initialize3(Job.GetBitmap)
imgPhoto.Bitmap = BMFoto ' imgPhoto is my ImageView

This worked but the image is rotated. Since ExifData can only be initializated through a saved bitmap, I tried to save the bitmap contained in BMFoto:
B4X:
Dim out As OutputStream
Dim dir As String = File.DirRootExternal
Dim fname As String = "rotate.jpg"
out = File.OpenOutput(dir,fname,False)
BMFoto.WriteToStream(out,100,"JPEG")

The problem is, the new file named "rotate.jpg" has lost all Exif data :(

Any idea how can I fix this?

Thanks again!
 
Upvote 0
Top