Advertisement
Guest User

Clip Circle from rectangle

a guest
Sep 6th, 2014
315
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. private Bitmap getCircleImageBitmap() {
  2.  
  3.         Display display = getWindow().getWindowManager().getDefaultDisplay();
  4.         Bitmap output = Bitmap.createBitmap(display.getWidth(), display.getHeight(), Config.ARGB_8888);
  5.         Canvas canvas = new Canvas(output);
  6.  
  7.         final int color = 0x99000000;
  8.         final Paint paint = new Paint();
  9.         final Rect rect = new Rect(0, 0, display.getWidth(), display.getHeight());
  10.  
  11.         paint.setAntiAlias(true);
  12.         canvas.drawARGB(0, 0, 0, 0);
  13.         paint.setColor(color);
  14.         paint.setStyle(Style.FILL);
  15.         canvas.drawCircle(display.getWidth() / 2, display.getHeight() / 2, (display.getWidth() / 2) - 30, paint);
  16.         paint.setXfermode(new PorterDuffXfermode(Mode.SRC_OUT));
  17.         canvas.drawBitmap(bitmapimg, rect, rect, paint);
  18.         return output;
  19.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement