mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-25 01:07:47 +00:00
decode bitmaps as RGB565
cuts decoding memory in half Closes #3350 // FREEBIE
This commit is contained in:
parent
155cbf686d
commit
e420861151
@ -3,6 +3,7 @@ package org.thoughtcrime.securesms.util;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.graphics.Bitmap;
|
import android.graphics.Bitmap;
|
||||||
import android.graphics.Bitmap.CompressFormat;
|
import android.graphics.Bitmap.CompressFormat;
|
||||||
|
import android.graphics.Bitmap.Config;
|
||||||
import android.graphics.BitmapFactory;
|
import android.graphics.BitmapFactory;
|
||||||
import android.graphics.Canvas;
|
import android.graphics.Canvas;
|
||||||
import android.graphics.Color;
|
import android.graphics.Color;
|
||||||
@ -135,6 +136,7 @@ public class BitmapUtil {
|
|||||||
|
|
||||||
options.inSampleSize = getScaleFactor(imageWidth, imageHeight, maxWidth, maxHeight, constrainedMemory);
|
options.inSampleSize = getScaleFactor(imageWidth, imageHeight, maxWidth, maxHeight, constrainedMemory);
|
||||||
options.inJustDecodeBounds = false;
|
options.inJustDecodeBounds = false;
|
||||||
|
options.inPreferredConfig = constrainedMemory ? Config.RGB_565 : Config.ARGB_8888;
|
||||||
|
|
||||||
InputStream is = new BufferedInputStream(data);
|
InputStream is = new BufferedInputStream(data);
|
||||||
Bitmap roughThumbnail = BitmapFactory.decodeStream(is, null, options);
|
Bitmap roughThumbnail = BitmapFactory.decodeStream(is, null, options);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user