aboutsummaryrefslogtreecommitdiffstats
path: root/src/eu/siacs
diff options
context:
space:
mode:
authoriNPUTmice <daniel@gultsch.de>2014-09-02 11:19:05 +0200
committeriNPUTmice <daniel@gultsch.de>2014-09-02 11:19:05 +0200
commitf888b167c6c1568baffb33be17d230acac1dc63d (patch)
tree6e1140e23c89ca46fab5e25a1f956c34b0331a6a /src/eu/siacs
parent6045bcc2ebef10ef58d905d3a3e0add8b8b20ffc (diff)
rotate avatars
Diffstat (limited to 'src/eu/siacs')
-rw-r--r--src/eu/siacs/conversations/persistance/FileBackend.java25
1 files changed, 16 insertions, 9 deletions
diff --git a/src/eu/siacs/conversations/persistance/FileBackend.java b/src/eu/siacs/conversations/persistance/FileBackend.java
index 0af9c6e2..2b2aa86e 100644
--- a/src/eu/siacs/conversations/persistance/FileBackend.java
+++ b/src/eu/siacs/conversations/persistance/FileBackend.java
@@ -201,17 +201,20 @@ public class FileBackend {
private int getRotation(Uri image) {
if ("content".equals(image.getScheme())) {
- Cursor cursor = context
- .getContentResolver()
- .query(image,
- new String[] { MediaStore.Images.ImageColumns.ORIENTATION },
- null, null, null);
-
- if (cursor.getCount() != 1) {
+ try {
+ Cursor cursor = context
+ .getContentResolver()
+ .query(image,
+ new String[] { MediaStore.Images.ImageColumns.ORIENTATION },
+ null, null, null);
+ if (cursor.getCount() != 1) {
+ return -1;
+ }
+ cursor.moveToFirst();
+ return cursor.getInt(0);
+ } catch (IllegalArgumentException e) {
return -1;
}
- cursor.moveToFirst();
- return cursor.getInt(0);
} else {
ExifInterface exif;
try {
@@ -376,6 +379,10 @@ public class FileBackend {
if (input == null) {
return null;
} else {
+ int rotation = getRotation(image);
+ if (rotation > 0) {
+ input = rotate(input, rotation);
+ }
return cropCenterSquare(input, size);
}
} catch (FileNotFoundException e) {