Don't try to rescale when no bitmap in RemoteControlClient

If a RemoteControlClient has a null artwork, do no attempt to
 rescale the bitmap, it's ok to send a null bitmap to the
 IRemoteControlDisplay.

Change-Id: I8332ccfcf18107ea0b41d4e7fa232d7f68798efc
This commit is contained in:
Jean-Michel Trivi
2011-08-26 11:57:42 -07:00
parent 2daf331e68
commit 6e679d5a53

View File

@@ -722,20 +722,22 @@ public class RemoteControlClient
*/
private Bitmap scaleBitmapIfTooBig(Bitmap bitmap, int maxWidth, int maxHeight) {
final int width = bitmap.getWidth();
final int height = bitmap.getHeight();
if (width > maxWidth || height > maxHeight) {
float scale = Math.min((float) maxWidth / width, (float) maxHeight / height);
int newWidth = Math.round(scale * width);
int newHeight = Math.round(scale * height);
Bitmap outBitmap = Bitmap.createBitmap(newWidth, newHeight, bitmap.getConfig());
Canvas canvas = new Canvas(outBitmap);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setFilterBitmap(true);
canvas.drawBitmap(bitmap, null,
new RectF(0, 0, outBitmap.getWidth(), outBitmap.getHeight()), paint);
bitmap = outBitmap;
if (bitmap != null) {
final int width = bitmap.getWidth();
final int height = bitmap.getHeight();
if (width > maxWidth || height > maxHeight) {
float scale = Math.min((float) maxWidth / width, (float) maxHeight / height);
int newWidth = Math.round(scale * width);
int newHeight = Math.round(scale * height);
Bitmap outBitmap = Bitmap.createBitmap(newWidth, newHeight, bitmap.getConfig());
Canvas canvas = new Canvas(outBitmap);
Paint paint = new Paint();
paint.setAntiAlias(true);
paint.setFilterBitmap(true);
canvas.drawBitmap(bitmap, null,
new RectF(0, 0, outBitmap.getWidth(), outBitmap.getHeight()), paint);
bitmap = outBitmap;
}
}
return bitmap;