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:
VILIC VANE 2015-01-29 01:31:21 +08:00
parent 80b0048384
commit d7e708db09

View File

@ -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)