Generally to do a positive round picture, can only be achieved on the basis of the square, otherwise it becomes an ellipse, the following said how to make a picture of the rectangle is a circle picture
Don't say much nonsense, no picture no truth, First:
Original:
After turning into a circle:
The following code:
public static Bitmap Makeroundcorner (Bitmap Bitmap) {int width = bitmap.getwidth (); int height = bitmap.getheight (); int left = 0, top = 0, right = width, bottom = height; float roundpx = HEIGHT/2; if (width > height) {left = (width-height)/2; top = 0; right = left + height; bottom = height; } else if (height > width) {left = 0; top = (height-width)/2; right = width; Bottom = top + width; ROUNDPX = WIDTH/2; } zlog.i (TAG, "PS:" + Left + "," + Top + "," + Right + "," + Bottom "); Bitmap output = bitmap.createbitmap (width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new canvas (output); int color = 0xff424242; Paint paint = new paint (); Rect rect = new Rect (left, top, right, bottom); RECTF RECTF = new RECTF (rect); Paint.setantialias (TRUE); Canvas.drawargb (0, 0, 0, 0); Paint.setcolor (color); Canvas.drawroundrect (RECTF, ROUNDPX, ROUNDPX, paint); Paint.setxfermode (New Porterduffxfermode (PorterDuff.Mode.SRC_IN)); Canvas.drawbitmap (Bitmap, rect, rect, paint); return output; }
explained below:
Because the picture is a rectangle, so the width of the picture, the height will certainly have one side to be smaller than the other side, to create a square has the smallest side as the benchmark, and then to cut the other side of the display range
As for the radius of the fillet is half the width of the square, using the CSS will know that the circle is convenient border-radius set to 50% can be, are a reason
Android UI is too cumbersome
The rectangle draws a rounded corner of the code:  
public static Bitmap Makeroundcorner (Bitmap Bitmap, int px) { int width = bitmap.getwidth (); int height = bitmap.getheight (); Bitmap output = bitmap.createbitmap (width, height, Bitmap.Config.ARGB_8888); Canvas canvas = new canvas (output); int color = 0xff424242; Paint paint = new paint (); Rect rect = new Rect (0, 0, width, height); RECTF RECTF = new RECTF (rect); Paint.setantialias (true); Canvas.drawargb (0, 0, 0, 0); Paint.setcolor (color); Canvas.drawroundrect (RECTF, px, px, paint); Paint.setxfermode (New Porterduffxfermode (PorterDuff.Mode.SRC_IN)); Canvas.drawbitmap (Bitmap, rect, rect, paint); return output; }
The Android rectangle picture generates a circle, and a rectangular picture creates a rounded corner