mirror of
https://github.com/apache/cordova-plugin-camera.git
synced 2025-02-22 22:12:54 +08:00
add try ... catch for getting image orientation
There's bug in Windows Phone 8.1 causing Seek on a DssPhotoStream not working properly. https://connect.microsoft.com/VisualStudio/feedback/details/783252 But a mis-oriented file is better than nothing, so try and catch.
This commit is contained in:
parent
80b0048384
commit
d7e708db09
@ -271,21 +271,27 @@ namespace WPCordovaClassLib.Cordova.Commands
|
|||||||
Picture pict = library.SavePicture(e.OriginalFileName, e.ChosenPhoto); // to save to photo-roll ...
|
Picture pict = library.SavePicture(e.OriginalFileName, e.ChosenPhoto); // to save to photo-roll ...
|
||||||
}
|
}
|
||||||
|
|
||||||
int orient = ImageExifHelper.getImageOrientationFromStream(e.ChosenPhoto);
|
|
||||||
int newAngle = 0;
|
int newAngle = 0;
|
||||||
switch (orient)
|
// There's bug in Windows Phone 8.1 causing Seek on a DssPhotoStream not working properly.
|
||||||
{
|
// https://connect.microsoft.com/VisualStudio/feedback/details/783252
|
||||||
case ImageExifOrientation.LandscapeLeft:
|
// But a mis-oriented file is better than nothing, so try and catch.
|
||||||
newAngle = 90;
|
try {
|
||||||
break;
|
int orient = ImageExifHelper.getImageOrientationFromStream(e.ChosenPhoto);
|
||||||
case ImageExifOrientation.PortraitUpsideDown:
|
switch (orient) {
|
||||||
newAngle = 180;
|
case ImageExifOrientation.LandscapeLeft:
|
||||||
break;
|
newAngle = 90;
|
||||||
case ImageExifOrientation.LandscapeRight:
|
break;
|
||||||
newAngle = 270;
|
case ImageExifOrientation.PortraitUpsideDown:
|
||||||
break;
|
newAngle = 180;
|
||||||
case ImageExifOrientation.Portrait:
|
break;
|
||||||
default: break; // 0 default already set
|
case ImageExifOrientation.LandscapeRight:
|
||||||
|
newAngle = 270;
|
||||||
|
break;
|
||||||
|
case ImageExifOrientation.Portrait:
|
||||||
|
default: break; // 0 default already set
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
Debug.WriteLine("Error fetching orientation from Exif");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (newAngle != 0)
|
if (newAngle != 0)
|
||||||
|
Loading…
Reference in New Issue
Block a user