From 0965a3244b4c3009d08db2e084cdcb681ef66d26 Mon Sep 17 00:00:00 2001 From: Romain Guy Date: Mon, 1 Aug 2011 17:39:21 -0700 Subject: Allow Canvas.setBitmap() to receive a null Bitmap. Change-Id: I6096f0b44866e532ccd96a29c816bf34d48c1dc2 --- graphics/java/android/graphics/Canvas.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'graphics') diff --git a/graphics/java/android/graphics/Canvas.java b/graphics/java/android/graphics/Canvas.java index 35ed4d2..6ae8c9b 100644 --- a/graphics/java/android/graphics/Canvas.java +++ b/graphics/java/android/graphics/Canvas.java @@ -178,17 +178,22 @@ public class Canvas { * @see #getDensity() */ public void setBitmap(Bitmap bitmap) { - if (!bitmap.isMutable()) { - throw new IllegalStateException(); - } if (isHardwareAccelerated()) { throw new RuntimeException("Can't set a bitmap device on a GL canvas"); } - throwIfRecycled(bitmap); - native_setBitmap(mNativeCanvas, bitmap.ni()); + int pointer = 0; + if (bitmap != null) { + if (!bitmap.isMutable()) { + throw new IllegalStateException(); + } + throwIfRecycled(bitmap); + mDensity = bitmap.mDensity; + pointer = bitmap.ni(); + } + + native_setBitmap(mNativeCanvas, pointer); mBitmap = bitmap; - mDensity = bitmap.mDensity; } /** -- cgit v1.1