mirror of
https://github.com/oxen-io/session-android.git
synced 2024-12-17 21:47:28 +00:00
Merge pull request #2227 from mcginty/circle-crop-oom
memory-friendly resize for circle cropping
This commit is contained in:
commit
f1572774f2
@ -54,6 +54,7 @@ import org.thoughtcrime.securesms.recipients.RecipientFactory;
|
|||||||
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
|
import org.thoughtcrime.securesms.recipients.RecipientFormattingException;
|
||||||
import org.thoughtcrime.securesms.recipients.Recipients;
|
import org.thoughtcrime.securesms.recipients.Recipients;
|
||||||
import org.thoughtcrime.securesms.sms.MessageSender;
|
import org.thoughtcrime.securesms.sms.MessageSender;
|
||||||
|
import org.thoughtcrime.securesms.util.BitmapDecodingException;
|
||||||
import org.thoughtcrime.securesms.util.BitmapUtil;
|
import org.thoughtcrime.securesms.util.BitmapUtil;
|
||||||
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
import org.thoughtcrime.securesms.util.DynamicLanguage;
|
||||||
import org.thoughtcrime.securesms.util.DynamicTheme;
|
import org.thoughtcrime.securesms.util.DynamicTheme;
|
||||||
@ -511,8 +512,8 @@ public class GroupCreateActivity extends PassphraseRequiredActionBarActivity {
|
|||||||
protected Bitmap doInBackground(Void... voids) {
|
protected Bitmap doInBackground(Void... voids) {
|
||||||
if (avatarUri != null) {
|
if (avatarUri != null) {
|
||||||
try {
|
try {
|
||||||
avatarBmp = BitmapUtil.getScaledCircleCroppedBitmap(getApplicationContext(), avatarUri, AVATAR_SIZE);
|
avatarBmp = BitmapUtil.getScaledCircleCroppedBitmap(GroupCreateActivity.this, masterSecret, avatarUri, AVATAR_SIZE);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException | BitmapDecodingException e) {
|
||||||
Log.w(TAG, e);
|
Log.w(TAG, e);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -202,10 +202,11 @@ public class BitmapUtil {
|
|||||||
return getScaledCircleCroppedBitmap(bitmap, srcSize);
|
return getScaledCircleCroppedBitmap(bitmap, srcSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bitmap getScaledCircleCroppedBitmap(Context context, Uri uri, int destSize) throws FileNotFoundException {
|
public static Bitmap getScaledCircleCroppedBitmap(Context context, MasterSecret masterSecret, Uri uri, int destSize)
|
||||||
InputStream dataStream = context.getContentResolver().openInputStream(uri);
|
throws FileNotFoundException, BitmapDecodingException
|
||||||
InputStream orientationStream = context.getContentResolver().openInputStream(uri);
|
{
|
||||||
Bitmap bitmap = BitmapFactory.decodeStream(dataStream);
|
InputStream orientationStream = PartAuthority.getPartStream(context, masterSecret, uri);
|
||||||
|
Bitmap bitmap = createScaledBitmap(context, masterSecret, uri, destSize, destSize);
|
||||||
|
|
||||||
return getScaledCircleCroppedBitmap(fixOrientation(bitmap, orientationStream), destSize);
|
return getScaledCircleCroppedBitmap(fixOrientation(bitmap, orientationStream), destSize);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user