2

I have the following method:

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);
    }

Using this I am trying to create a cropped area of some bitmap in a circle shape.

I also want to blur the edges of that circle area. For example: 5px from the edge towards the centre of the shape will be blurred. How can I implement this?

Ollie
  • 544
  • 4
  • 22
Nikita
  • 1,811
  • 1
  • 20
  • 41

1 Answers1

1

I think you would have to apply a BlurMaskFilter when drawing the image:

m_Paint = new Paint(0);
m_Paint.setColor(0xffffffff);
m_Paint.setMaskFilter(new BlurMaskFilter(8, BlurMaskFilter.Blur.NORMAL));
Thomas Denney
  • 1,578
  • 2
  • 15
  • 25
  • In order to use the blurmaskfilter, you need to set `android:hardwareAccelerated="false"` in `AndroidManifest.xml` – Simon Oct 29 '17 at 15:34