简体   繁体   中英

Adobe AIR CameraUI photo orientation

Im having some issues some Android devices when trying to take a photo using CameraUI class.

My AIR app is portrait only autoOrients = false, but for some reason, when taking a photo in portrait orientation, the image will return as rotated 90 degrees to the right.

This happens only on Samsung S6, but doesnt for example on HTC M8.

Is there a fix to this problem or is this just one of the eternal bugs in Adobe bugbase?

Is using ANE my best bet to fix this problem?

While this is annoying, it is actually intended functionality. I used the ExifReader class described here to determine the orientation and then rotate it the correct direction before saving the file to disk.

Androids camera images has built in information like GPS location, Orientation and more information named Exchangeable Image File (Exif) . When you capture an image, it will save with those information in the jpg file but the image may save in an unexpected orientation on drive.

So, this the solution:

1- Add an Exif encoder library to your project like this one: https://github.com/cantrell/ExifExample 2- Use something like this function to control the Image orientation after loading the image bytes :

       /**1: normal<br>
        3 rotated 180 degrees (upside down)<br>
        6: rotated 90 degrees CW<br>
        8: rotated 90 degrees CCW<br>
        9: unknown<br>
        */
    public static function getOrientation(ImageBytes:ByteArray):uint
    {
        var exif:ExifInfo = new ExifInfo(ImageBytes);
        if(exif.ifds != null)
        {
            var ifd:IFD = exif.ifds.primary ;
            var str:String = "";
            for (var entry:String in ifd) {
                if(entry == "Orientation"){
                    str = ifd[entry];
                    break;
                }
            }
            return uint(str);
        }
        else
        {
            return 9 ;
        }
    }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM