mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-27 06:58:30 +00:00
parent
6db3f249c6
commit
c5014f9471
@ -76,6 +76,8 @@ public class BitmapUtil {
|
|||||||
throw new BitmapDecodingException("Unable to decode image");
|
throw new BitmapDecodingException("Unable to decode image");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Log.i(TAG, "Initial scaled bitmap has size of " + scaledBitmap.getByteCount() + " bytes.");
|
||||||
|
|
||||||
try {
|
try {
|
||||||
do {
|
do {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
@ -92,9 +94,15 @@ public class BitmapUtil {
|
|||||||
quality = Math.max(nextQuality, MIN_COMPRESSION_QUALITY);
|
quality = Math.max(nextQuality, MIN_COMPRESSION_QUALITY);
|
||||||
}
|
}
|
||||||
while (bytes.length > maxImageSize && attempts++ < MAX_COMPRESSION_ATTEMPTS);
|
while (bytes.length > maxImageSize && attempts++ < MAX_COMPRESSION_ATTEMPTS);
|
||||||
|
|
||||||
if (bytes.length > maxImageSize) {
|
if (bytes.length > maxImageSize) {
|
||||||
throw new BitmapDecodingException("Unable to scale image below: " + bytes.length);
|
throw new BitmapDecodingException("Unable to scale image below: " + bytes.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (bytes.length <= 0) {
|
||||||
|
throw new BitmapDecodingException("Decoding failed. Bitmap has a length of " + bytes.length + " bytes.");
|
||||||
|
}
|
||||||
|
|
||||||
Log.w(TAG, "createScaledBytes(" + model.toString() + ") -> quality " + Math.min(quality, MAX_COMPRESSION_QUALITY) + ", " + attempts + " attempt(s)");
|
Log.w(TAG, "createScaledBytes(" + model.toString() + ") -> quality " + Math.min(quality, MAX_COMPRESSION_QUALITY) + ", " + attempts + " attempt(s)");
|
||||||
return new ScaleResult(bytes, scaledBitmap.getWidth(), scaledBitmap.getHeight());
|
return new ScaleResult(bytes, scaledBitmap.getWidth(), scaledBitmap.getHeight());
|
||||||
} finally {
|
} finally {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user