Skip to content

Commit fedd53b

Browse files
jmtriviAndroid (Google) Code Review
authored andcommitted
Merge "Don't try to rescale when no bitmap in RemoteControlClient"
2 parents 31c272a + 6e679d5 commit fedd53b

File tree

1 file changed

+16
-14
lines changed

1 file changed

+16
-14
lines changed

media/java/android/media/RemoteControlClient.java

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -722,20 +722,22 @@ private void onUnplugDisplay(IRemoteControlDisplay rcd) {
722722
*/
723723

724724
private Bitmap scaleBitmapIfTooBig(Bitmap bitmap, int maxWidth, int maxHeight) {
725-
final int width = bitmap.getWidth();
726-
final int height = bitmap.getHeight();
727-
if (width > maxWidth || height > maxHeight) {
728-
float scale = Math.min((float) maxWidth / width, (float) maxHeight / height);
729-
int newWidth = Math.round(scale * width);
730-
int newHeight = Math.round(scale * height);
731-
Bitmap outBitmap = Bitmap.createBitmap(newWidth, newHeight, bitmap.getConfig());
732-
Canvas canvas = new Canvas(outBitmap);
733-
Paint paint = new Paint();
734-
paint.setAntiAlias(true);
735-
paint.setFilterBitmap(true);
736-
canvas.drawBitmap(bitmap, null,
737-
new RectF(0, 0, outBitmap.getWidth(), outBitmap.getHeight()), paint);
738-
bitmap = outBitmap;
725+
if (bitmap != null) {
726+
final int width = bitmap.getWidth();
727+
final int height = bitmap.getHeight();
728+
if (width > maxWidth || height > maxHeight) {
729+
float scale = Math.min((float) maxWidth / width, (float) maxHeight / height);
730+
int newWidth = Math.round(scale * width);
731+
int newHeight = Math.round(scale * height);
732+
Bitmap outBitmap = Bitmap.createBitmap(newWidth, newHeight, bitmap.getConfig());
733+
Canvas canvas = new Canvas(outBitmap);
734+
Paint paint = new Paint();
735+
paint.setAntiAlias(true);
736+
paint.setFilterBitmap(true);
737+
canvas.drawBitmap(bitmap, null,
738+
new RectF(0, 0, outBitmap.getWidth(), outBitmap.getHeight()), paint);
739+
bitmap = outBitmap;
740+
}
739741
}
740742
return bitmap;
741743

0 commit comments

Comments
 (0)