mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-23 00:17:34 +00:00
Correctly preserve MMS image aspect ratios.
This commit is contained in:
parent
f23fc9b3dd
commit
99e3e596bb
@ -67,9 +67,22 @@ public class BitmapUtil {
|
|||||||
throw new BitmapDecodingException("Decoded stream was null.");
|
throw new BitmapDecodingException("Decoded stream was null.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (imageWidth > maxWidth || imageHeight > maxHeight) {
|
if (roughThumbnail.getWidth() > maxWidth || roughThumbnail.getHeight() > maxHeight) {
|
||||||
Log.w("BitmapUtil", "Scaling to max width and height: " + maxWidth + "," + maxHeight);
|
float aspectWidth, aspectHeight;
|
||||||
Bitmap scaledThumbnail = Bitmap.createScaledBitmap(roughThumbnail, maxWidth, maxHeight, true);
|
|
||||||
|
if (imageWidth == 0 || imageHeight == 0) {
|
||||||
|
aspectWidth = maxWidth;
|
||||||
|
aspectHeight = maxHeight;
|
||||||
|
} else if (options.outWidth >= options.outHeight) {
|
||||||
|
aspectWidth = maxWidth;
|
||||||
|
aspectHeight = (aspectWidth / options.outWidth) * options.outHeight;
|
||||||
|
} else {
|
||||||
|
aspectHeight = maxHeight;
|
||||||
|
aspectWidth = (aspectHeight / options.outHeight) * options.outWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
Log.w("BitmapUtil", "Scaling to max width and height: " + aspectWidth + "," + aspectHeight);
|
||||||
|
Bitmap scaledThumbnail = Bitmap.createScaledBitmap(roughThumbnail, (int)aspectWidth, (int)aspectHeight, true);
|
||||||
roughThumbnail.recycle();
|
roughThumbnail.recycle();
|
||||||
return scaledThumbnail;
|
return scaledThumbnail;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user