aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/java/de/pixart/messenger/persistance
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/de/pixart/messenger/persistance')
-rw-r--r--src/main/java/de/pixart/messenger/persistance/FileBackend.java21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/main/java/de/pixart/messenger/persistance/FileBackend.java b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
index e893ea129..3bb1e5c4e 100644
--- a/src/main/java/de/pixart/messenger/persistance/FileBackend.java
+++ b/src/main/java/de/pixart/messenger/persistance/FileBackend.java
@@ -614,6 +614,14 @@ public class FileBackend {
}
public Avatar getPepAvatar(Uri image, int size, Bitmap.CompressFormat format) {
+ final Avatar uncompressAvatar = getUncompressedAvatar(image);
+ if (uncompressAvatar != null && uncompressAvatar.image.length() <= Config.AVATAR_CHAR_LIMIT) {
+ return uncompressAvatar;
+ }
+ if (uncompressAvatar != null) {
+ Log.d(Config.LOGTAG, "uncompressed avatar exceeded char limit by " + (uncompressAvatar.image.length() - Config.AVATAR_CHAR_LIMIT));
+ }
+
Bitmap bm = cropCenterSquare(image, size);
if (bm == null) {
return null;
@@ -627,6 +635,19 @@ public class FileBackend {
return getPepAvatar(bm, format, 100);
}
+ private Avatar getUncompressedAvatar(Uri uri) {
+ Bitmap bitmap = null;
+ try {
+ bitmap = BitmapFactory.decodeStream(mXmppConnectionService.getContentResolver().openInputStream(uri));
+ return getPepAvatar(bitmap, Bitmap.CompressFormat.PNG, 100);
+ } catch (Exception e) {
+ if (bitmap != null) {
+ bitmap.recycle();
+ }
+ }
+ return null;
+ }
+
private Avatar getPepAvatar(Bitmap bitmap, Bitmap.CompressFormat format, int quality) {
try {
ByteArrayOutputStream mByteArrayOutputStream = new ByteArrayOutputStream();