Reputation: 1771
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?
Upvotes: 1
Views: 378
Reputation: 778
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 ;
}
}
Upvotes: 1