首页 > 代码库 > 给图片切圆角
给图片切圆角
/** * 给bitmap画圆角 * * @param bitmap * bitmap对象 * @param roundPX * 圆角的角度 * @return 画好圆角后的bitmap对象 */ public static Bitmap roundBitmap(Bitmap bitmap, float roundPX) { try { final int width = bitmap.getWidth(); final int height = bitmap.getHeight(); Bitmap outputBitmap = Bitmap.createBitmap(bitmap.getWidth(), bitmap.getHeight(), Config.ARGB_8888); Canvas canvas = new Canvas(outputBitmap); final Paint paint = new Paint(); final Rect rect = new Rect(0, 0, width, height); final RectF rectF = new RectF(rect); paint.setAntiAlias(true); paint.setFilterBitmap(true); canvas.drawARGB(0, 0, 0, 0); paint.setColor(Color.WHITE); canvas.drawRoundRect(rectF, roundPX, roundPX, paint); final PorterDuffXfermode pdx = new PorterDuffXfermode( PorterDuff.Mode.SRC_IN); paint.setXfermode(pdx); canvas.drawBitmap(bitmap, rect, rect, paint); bitmap.recycle(); return outputBitmap; } catch (Exception e) { return bitmap; } }
给图片切圆角
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。