bitmap = ((BitmapDrawable)imageView1.getDrawable()).getBitmap();
bitmap = getRoundedCornerBitmap(bitmap);
imageView1.setImageBitmap(bitmap);

public static Bitmap getRoundedCornerBitmap(Bitmap bitmap) {
Bitmap output = Bitmap.createBitmap(bitmap.getWidth(),
bitmap.getHeight(), Config.ARGB_8888);
Canvas canvas = new Canvas(output);

final int color = 0xff424242;
final Paint paint = new Paint();
final Rect rect = new Rect(0, 0, bitmap.getWidth(), bitmap.getHeight());
final RectF rectF = new RectF(rect);
final float roundPx = bitmap.getWidth() / 2;

paint.setAntiAlias(true);
canvas.drawARGB(0, 0, 0, 0);
paint.setColor(color);
canvas.drawRoundRect(rectF, roundPx, roundPx, paint);

paint.setXfermode(new PorterDuffXfermode(Mode.SRC_IN));
canvas.drawBitmap(bitmap, rect, rect, paint);
return output;
}

更多相关文章

  1. 代码中设置drawableleft
  2. android 3.0 隐藏 系统标题栏
  3. Android开发中activity切换动画的实现
  4. Android(安卓)学习 笔记_05. 文件下载
  5. Android中直播视频技术探究之—摄像头Camera视频源数据采集解析
  6. 技术博客汇总
  7. android 2.3 wifi (一)
  8. AndRoid Notification的清空和修改
  9. Android中的Chronometer

随机推荐

  1. android 传统蓝牙开发 (附示例源码)
  2. Android SDK源码提取Python脚本(4.0SDK源
  3. Cocos2dx 2.0.2版本Android环境出错:Canno
  4. Android问题集锦之四十:Android(安卓)NDK:
  5. Android 实现滚动数字的TextView
  6. android intent 最大传送内容 1m
  7. 关于ANDROID NATIVE 的No implementation
  8. 获取Android状态栏的高度
  9. 简单总结RectF、Rect 和Matrix ,还有Pain
  10. Android 的系统属性(SystemProperties)设