mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-22 16:07:30 +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.");
|
||||
}
|
||||
|
||||
if (imageWidth > maxWidth || imageHeight > maxHeight) {
|
||||
Log.w("BitmapUtil", "Scaling to max width and height: " + maxWidth + "," + maxHeight);
|
||||
Bitmap scaledThumbnail = Bitmap.createScaledBitmap(roughThumbnail, maxWidth, maxHeight, true);
|
||||
if (roughThumbnail.getWidth() > maxWidth || roughThumbnail.getHeight() > maxHeight) {
|
||||
float aspectWidth, aspectHeight;
|
||||
|
||||
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();
|
||||
return scaledThumbnail;
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user