android图片转,圆形和圆角矩形
android 图片转 圆形和圆角矩形,比较高效的方法
圆角矩形:
int w = getWidth();
int h = getHeight();
Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint(1);
paint.setColor(0xff000000);
RectF rectf = new RectF(0F, 0F, w, h);
canvas.drawRoundRect(rectf, cornerRadius, cornerRadius, paint);
return bitmap;
圆形:
int w = getWidth();
int h = getHeight();
Bitmap bitmap = Bitmap.createBitmap(w, h, Bitmap.Config.ARGB_8888);
Canvas canvas = new Canvas(bitmap);
Paint paint = new Paint(1);
paint.setColor(0xff000000);
RectF rectf = new RectF(0F, 0F, w, h);
canvas.drawOval(rectf, paint);
return bitmap;
摘自 刘群博客
补充:移动开发 , Android ,