how to circular a bitmap android

Solutions on MaxInterview for how to circular a bitmap android by the best coders in the world

showing results for - "how to circular a bitmap android"
Maximilien
25 Jan 2019
1public Bitmap getCroppedBitmap(Bitmap bitmap) {
2    Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
3            bitmap.getHeight(), Config.ARGB_8888);
4    Canvas canvas = new Canvas(output);
5
6    final int color = 0xff424242;
7    final Paint paint = new Paint();
8    final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
9
10    paint.setAntiAlias(true);
11    canvas.drawARGB(0, 0, 0, 0);
12    paint.setColor(color);
13    // canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
14    canvas.drawCircle(bitmap.getWidth() / 2, bitmap.getHeight() / 2,
15            bitmap.getWidth() / 2, paint);
16    paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
17    canvas.drawBitmap(bitmap, rect, rect, paint);
18    //Bitmap _bmp = Bitmap.createScaledBitmap(output, 60, 60, false);
19    //return _bmp;
20    return output;
21}