Package xiaosi. roundconcer; import android. app. activity; import android. graphics. bitmap; import android. graphics. bitmap. config; import android. graphics. bitmapfactory; import android. graphics. canvas; import android. graphics. paint; import android. graphics. porterduff. mode; import android. graphics. porterduxfermode; import android. graphics. rect; import android. graphics. rectf; import android. OS. bundle; import android. widget. imageview; public class roundconceractivity extends activity {/** called when the activity is first created. */private imageview roundimage = NULL; @ overridepublic void oncreate (bundle savedinstancestate) {super. oncreate (savedinstancestate); setcontentview (R. layout. main); roundimage = (imageview) findviewbyid (R. id. roundconcer); Bitmap bitmap = bitmapfactory. decoderesource (getresources (), R. drawable. a); roundimage. setimagebitmap (getroundcornerimage (bitmap, 50);} public static bitmap getroundcornerimage (Bitmap bitmap, int roundpixels) {// create a bitmap roundconcerimage = bitmap, which is the same as the original image. createbitmap (bitmap. getwidth (), bitmap. getheight (), config. argb_8888); // create a canvas with a bitmap roundconcerimage = new canvas (roundconcerimage); // create a paint brush paint = new paint (); // create a rectangle rect = new rect (0, 0, bitmap. getwidth (), bitmap. getheight (); rectf = new rectf (rect); // de-sawtooth paint. setantialias (true); // draw a rectangle canvas of the same size as the original image. drawroundrect (rectf, roundpixels, roundpixels, paint); // you can specify the Intersection Mode paint. setxfermode (New porterduduxfermode (mode. src_in); // draw the image to the rectangle to canvas. drawbitmap (bitmap, null, rect, paint); Return roundconcerimage ;}}