This example describes the Android generation of bitmap pictures with rounded corners. Share to everyone for your reference. Specifically as follows:
Sometimes when we're developing Android apps, we run into fillet images, so how do we use code in Android to generate fillet bitmap pictures? The following code may be able to help you.
This method mainly uses the Drawroundrect to draw the rounded rectangle, then draws the picture through the Drawbitmap.
Generate fillet picture public
static Bitmap Getroundedcornerbitmap (Bitmap Bitmap) {
try {
Bitmap output = Bitmap.createbitmap (Bitmap.getwidth (),
bitmap.getheight (), config.argb_8888);
Canvas Canvas = new Canvas (output);
Final Paint Paint = new Paint ();
Final Rect Rect = new Rect (0, 0, bitmap.getwidth (),
bitmap.getheight ());
Final RECTF RECTF = new RECTF (new Rect (0, 0, bitmap.getwidth (),
bitmap.getheight ()));
Final float roundpx =;
Paint.setantialias (true);
Canvas.drawargb (0, 0, 0, 0);
Paint.setcolor (color.black);
Canvas.drawroundrect (RECTF, ROUNDPX, ROUNDPX, paint);
Paint.setxfermode (New Porterduffxfermode (mode.src_in));
Final Rect src = new Rect (0, 0, bitmap.getwidth (),
bitmap.getheight ());
Canvas.drawbitmap (bitmap, SRC, rect, paint);
return output;
} catch (Exception e) {return
bitmap
}}
I hope this article will help you with your Android program.