Fix crash when taking picture to send with chat on some devices/android

This commit is contained in:
Sylvain Berfini 2012-12-17 15:51:08 +01:00
parent 7000bc4b3d
commit 9788e09ff8

View file

@ -748,17 +748,19 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
// Rotate the bitmap if possible/needed, using EXIF data // Rotate the bitmap if possible/needed, using EXIF data
try { try {
ExifInterface exif = new ExifInterface(filePath); if (filePath != null) {
int pictureOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0); ExifInterface exif = new ExifInterface(filePath);
Matrix matrix = new Matrix(); int pictureOrientation = exif.getAttributeInt(ExifInterface.TAG_ORIENTATION, 0);
if (pictureOrientation == 6) { Matrix matrix = new Matrix();
matrix.postRotate(90); if (pictureOrientation == 6) {
} else if (pictureOrientation == 3) { matrix.postRotate(90);
matrix.postRotate(180); } else if (pictureOrientation == 3) {
} else if (pictureOrientation == 8) { matrix.postRotate(180);
matrix.postRotate(270); } else if (pictureOrientation == 8) {
matrix.postRotate(270);
}
bm = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true);
} }
bm = Bitmap.createBitmap(bm, 0, 0, bm.getWidth(), bm.getHeight(), matrix, true);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }