public static Bitmap makeRoundUserPicture(Bitmap bitmap){
  if (bitmap == null)   return null;
  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());
  canvas.drawARGB(0,0,0,0);
  paint.setAntiAlias(true);
  paint.setColor(0xFFFFFFFF);
  canvas.drawCircle(bitmap.getWidth() * 0.5f,bitmap.getHeight() * 0.5f,bitmap.getWidth() * 0.5f,paint);
  paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.SRC_IN));
  canvas.drawBitmap(bitmap,rect,rect,paint);
  return output;
}

public static Bitmap makeRoundUserPicture ( Bitmap bitmap ) { if ( bitmap == null ) return null ; 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 ( ) ) ; canvas . drawARGB ( 0 , 0 , 0 , 0 ) ; paint . setAntiAlias ( true ) ; paint . setColor ( 0xFFFFFFFF ) ; canvas . drawCircle ( bitmap . getWidth ( ) * 0.5f , bitmap . getHeight ( ) * 0.5f , bitmap . getWidth ( ) * 0.5f , paint ) ; paint . setXfermode ( new PorterDuffXfermode ( PorterDuff . Mode . SRC_IN ) ) ; canvas . drawBitmap ( bitmap , rect , rect , paint ) ; return output ; }
converts a square user picture to a round user picture .
