Skip to content

Commit 0c01222

Browse files
jackpalAndroid (Google) Code Review
authored andcommitted
Merge "Don't crash when scaling Bitmaps with private Bitmap.Configs" into jb-dev
2 parents bbdf46d + 05c66cc commit 0c01222

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

media/java/android/media/RemoteControlClient.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -854,7 +854,11 @@ private Bitmap scaleBitmapIfTooBig(Bitmap bitmap, int maxWidth, int maxHeight) {
854854
float scale = Math.min((float) maxWidth / width, (float) maxHeight / height);
855855
int newWidth = Math.round(scale * width);
856856
int newHeight = Math.round(scale * height);
857-
Bitmap outBitmap = Bitmap.createBitmap(newWidth, newHeight, bitmap.getConfig());
857+
Bitmap.Config newConfig = bitmap.getConfig();
858+
if (newConfig == null) {
859+
newConfig = Bitmap.Config.ARGB_8888;
860+
}
861+
Bitmap outBitmap = Bitmap.createBitmap(newWidth, newHeight, newConfig);
858862
Canvas canvas = new Canvas(outBitmap);
859863
Paint paint = new Paint();
860864
paint.setAntiAlias(true);

0 commit comments

Comments
 (0)