Skip to content

Instantly share code, notes, and snippets.

@ollien
Last active August 29, 2015 14:12
Show Gist options
  • Save ollien/e2cff6d47b8c18b8ef4e to your computer and use it in GitHub Desktop.
Save ollien/e2cff6d47b8c18b8ef4e to your computer and use it in GitHub Desktop.
Draw Circular Bitmap
Bitmap profileBitmap = BitmapFactory.decodeStream(connection.getInputStream());
Bitmap finalBitmap = Bitmap.createBitmap(profileBitmap.getWidth(),profileBitmap.getHeight(),Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(finalBitmap);
Path p = new Path();
p.addCircle(profileBitmap.getHeight()/2,profileBitmap.getHeight()/2,profileBitmap.getWidth()/2,Path.Direction.CCW);
canvas.clipPath(p);;
canvas.drawBitmap(profileBitmap,new Rect(0,0,profileBitmap.getHeight(),profileBitmap.getWidth()),new Rect(0,0,profileBitmap.getHeight(),profileBitmap.getWidth()),null);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment