我有以下方法:
protected void onDraw(Canvas i_Canvas) {
int x = (int) m_X;
int y = (int) m_Y;
Path path = new Path();
path.addCircle(
m_Cx,
m_Cy,
m_Radius,
Path.Direction.CCW);
i_Canvas.clipPath(path);
Rect rect = new Rect(x, y, x + 240, y + 240);
i_Canvas.drawBitmap(m_FullImageBitmap, rect, rect, m_Paint);
}
使用这个我试图以圆形形状创建一些位图的裁剪区域。
我还想模糊那个圆圈区域的边缘。例如:从边缘朝向形状中心的5px将模糊。我该如何实现呢?
答案 0 :(得分:1)
我认为在绘制图像时你必须应用BlurMaskFilter:
m_Paint = new Paint(0);
m_Paint.setColor(0xffffffff);
m_Paint.setMaskFilter(new BlurMaskFilter(8, BlurMaskFilter.Blur.NORMAL));