将bitmap生成圆角
来源:互联网 发布:网络与系统攻击技术 编辑:程序博客网 时间:2024/04/30 18:12
// 生成圆角图片
public static Bitmap GetRoundedCornerBitmap(Bitmap bitmap) {
try {
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());
final RectF rectF = new RectF(new Rect(0, 0, bitmap.getWidth(),
bitmap.getHeight()));
final float roundPx = 65;
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(Color.BLACK);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
final Rect src = new Rect(0, 0, bitmap.getWidth(),
bitmap.getHeight());
canvas.drawBitmap(bitmap, src, rect, paint);
return output;
} catch (Exception e) {
return bitmap;
}
}
public static Bitmap GetRoundedCornerBitmap(Bitmap bitmap) {
try {
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());
final RectF rectF = new RectF(new Rect(0, 0, bitmap.getWidth(),
bitmap.getHeight()));
final float roundPx = 65;
paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(Color.BLACK);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);
paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
final Rect src = new Rect(0, 0, bitmap.getWidth(),
bitmap.getHeight());
canvas.drawBitmap(bitmap, src, rect, paint);
return output;
} catch (Exception e) {
return bitmap;
}
}
0 0
- 将bitmap生成圆角
- 生成圆角的Bitmap
- Android中Bitmap和Drawable Bitmap → byte[] byte[] → Bitmap Bitmap缩放 将Drawable转化为Bitmap 获得圆角图片
- 生成二维码并将Bitmap保存成图片
- android 如何用代码生成圆角Bitmap图片
- drawable与bitmap的转换,以及如何将一个view生成一个bitmap
- 将Drawable转为Bitmap
- 将bitmap保存本地
- 根据view生成Bitmap
- 根据View生成Bitmap
- linux c 生成 bitmap
- View生成Bitmap
- view 生成 bitmap
- View 生成bitmap方法
- 将两个Bitmap资源合成一张bitmap
- 将两个bitmap整合成一个bitmap
- WPF 将bitmap转成Image
- 如何将Bitmap序列化
- 有关minSdkVersion和targetSdkVersion
- 通过JDBC获取数据库连接
- KK版本手机没有外置T卡卡座,如何去掉外置T卡
- subversion edge
- 十四章上机练习4
- 将bitmap生成圆角
- Makefile学习(三)[第二版]
- android Dagger2依赖注入框架总结
- 医电园——开启医疗器械在线交易新模式
- maven 编译报错 java: -source 1.5 中不支持switch 中存在字符串
- 自定义View实现进度条
- Github pages is pretty cool
- 【bzoj3246】 Ioi2013—Dreaming
- SpringMvc 中RedirectAttributes对象重定向传参