summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Wei <markwei@google.com>2013-11-01 15:55:17 -0700
committerMark Wei <markwei@google.com>2013-11-04 11:34:27 -0800
commit0c9aacac20202f4a41e98d8a34a6ee2c152ae2de (patch)
treeaab83be3ed9c09d87a595546aa97e7122b97df91
parent5030ae34cd5978a8ab8a06f6c3b69b8645873122 (diff)
downloadbitmap-0c9aacac20202f4a41e98d8a34a6ee2c152ae2de.tar.gz
Allow subclasses to customize drawing of bitmap (using shaders, etc).
Change-Id: I22294a19e6dd2247cc9679470b7b69089ba17228
-rw-r--r--src/com/android/bitmap/drawable/BasicBitmapDrawable.java10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/com/android/bitmap/drawable/BasicBitmapDrawable.java b/src/com/android/bitmap/drawable/BasicBitmapDrawable.java
index 53ab38d..f9d39a3 100644
--- a/src/com/android/bitmap/drawable/BasicBitmapDrawable.java
+++ b/src/com/android/bitmap/drawable/BasicBitmapDrawable.java
@@ -281,11 +281,19 @@ public class BasicBitmapDrawable extends Drawable implements DecodeCallback,
// Rotate the canvas.
canvas.save();
canvas.rotate(orientation, bounds.centerX(), bounds.centerY());
- canvas.drawBitmap(mBitmap.bmp, sRect, rotatedBounds, mPaint);
+ drawBitmap(canvas, rotatedBounds);
canvas.restore();
}
}
+ /**
+ * Override this method to customize how to draw the bitmap to the canvas for the given bounds.
+ * The bitmap to be drawn can be found at {@link #getBitmap()}.
+ */
+ protected void drawBitmap(final Canvas canvas, final Rect bounds) {
+ canvas.drawBitmap(mBitmap.bmp, sRect, bounds, mPaint);
+ }
+
@Override
public void setAlpha(int alpha) {
final int old = mPaint.getAlpha();