Guest User

Untitled

a guest
May 7th, 2018
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.62 KB | None | 0 0
  1. private void renderDrawableToBitmap(Drawable d, Bitmap bitmap, int x, int y, int w, int h,
  2.             float scale, int multiplyColor) {
  3.         if (bitmap != null) {
  4.             Canvas c = new Canvas(bitmap);
  5.             c.scale(scale, scale);
  6.             Rect oldBounds = d.copyBounds();
  7.             d.setBounds(x, y, x + w, y + h);
  8.             d.draw(c);
  9.             d.setBounds(oldBounds); // Restore the bounds
  10.             if (multiplyColor != 0xFFFFFFFF) {
  11.                 c.drawColor(mDragViewMultiplyColor, PorterDuff.Mode.MULTIPLY);
  12.             }
  13.             c.setBitmap(null);
  14.             c = null;
  15.         }
  16.     }
Add Comment
Please, Sign In to add comment