mirror of
https://github.com/signalapp/Signal-Android.git
synced 2026-04-24 02:39:55 +01:00
Wallpaper image selection and cropping.
This commit is contained in:
committed by
Greyson Parrelli
parent
b5712f4bd1
commit
a8ad1e718e
@@ -10,6 +10,7 @@ import android.graphics.Rect;
|
||||
import android.graphics.YuvImage;
|
||||
import android.graphics.drawable.BitmapDrawable;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.os.Build;
|
||||
import android.util.Pair;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
@@ -267,6 +268,17 @@ public class BitmapUtil {
|
||||
return stream.toByteArray();
|
||||
}
|
||||
|
||||
public static @Nullable byte[] toWebPByteArray(@Nullable Bitmap bitmap) {
|
||||
if (bitmap == null) return null;
|
||||
ByteArrayOutputStream stream = new ByteArrayOutputStream();
|
||||
if (Build.VERSION.SDK_INT >= 30) {
|
||||
bitmap.compress(CompressFormat.WEBP_LOSSLESS, 100, stream);
|
||||
} else {
|
||||
bitmap.compress(CompressFormat.WEBP, 100, stream);
|
||||
}
|
||||
return stream.toByteArray();
|
||||
}
|
||||
|
||||
public static @Nullable Bitmap fromByteArray(@Nullable byte[] bytes) {
|
||||
if (bytes == null) return null;
|
||||
return BitmapFactory.decodeByteArray(bytes, 0, bytes.length);
|
||||
|
||||
Reference in New Issue
Block a user