[導讀] 01 /** 02 * Returns a circular cropped version of the bitmap passed in.
02 |
* Returns a circular cropped version of the bitmap passed in. |
04 |
public static Bitmap getCroppedBitmap(Bitmap bitmap) { |
05 |
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), |
08 |
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight()); |
10 |
Canvas canvas = new Canvas(output); |
12 |
final Paint paint = new Paint(); |
13 |
paint.setAntiAlias(true); |
15 |
int halfWidth = bitmap.getWidth() / 2; |
16 |
int halfHeight = bitmap.getHeight() / 2; |
18 |
canvas.drawCircle(halfWidth, halfHeight, Math.max(halfWidth, halfHeight), paint); |
20 |
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN)); |
22 |
canvas.drawBitmap(bitmap, rect, rect, paint); |
本站聲明: 本文章由作者或相關機構授權發(fā)布,目的在于傳遞更多信息,并不代表本站贊同其觀點,本站亦不保證或承諾內(nèi)容真實性等。需要轉載請聯(lián)系該專欄作者,如若文章內(nèi)容侵犯您的權益,請及時聯(lián)系本站刪除( 郵箱:macysun@21ic.com )。