It is very common for Android to treat a piece of bitmap as a circle, and the common occasion is to use the canvas to assist with this function, as shown in the following code
1 Public StaticBitmap Toroundcorner (Bitmap Bitmap,intpixels) {2Bitmap output =Bitmap.createbitmap (Bitmap.getwidth (), Bitmap.getheight (), config.argb_8888);3Canvas Canvas =NewCanvas (output);4 Final intcolor = 0xff424242;5 FinalPaint paint =NewPaint ();6 FinalRect rect =NewRect (0, 0, Bitmap.getwidth (), Bitmap.getheight ());7 FinalRECTF RECTF =NewRECTF (rect);8 Final floatROUNDPX =pixels;9Paint.setantialias (true);TenCanvas.drawargb (0, 0, 0, 0); One paint.setcolor (color); A Canvas.drawroundrect (RECTF, ROUNDPX, ROUNDPX, paint); -Paint.setxfermode (NewPorterduffxfermode (mode.src_in)); - canvas.drawbitmap (Bitmap, rect, rect, paint); the returnoutput; -}
Pixels is the radius of the image
(Android) processing picture into a circle