title: How do I erase (make transparent) one custom region in a Android's canvas?
body: <p>I'm overriding Android's ImageView in order to make the corners of my image transparent. I can accomplish that clipping the canvas in my onDraw(Canvas canvas):</p>
  
  <pre><code>@Override
  protected void onDraw(Canvas canvas) {
      Path clipPath = new Path();
      int w = this.getWidth();
      int h = this.getHeight();
      clipPath.addRoundRect(new RectF(0,0,w,h), 10.0f, 10.0f, Path.Direction.CW);
      canvas.clipPath(clipPath);
      super.onDraw(canvas);
  }
  </code></pre>
  
  <p>Unfortunately, it's not possible to antialias this round rectangle, and the result are ugly corners like this:</p>
  
  <p><img src="https://i.stack.imgur.com/vQ936.png" alt="enter image description here"></p>
  
  <p>I know I can clear parts of my canvas with antialiasing using <code>Paint</code> and <code>PorterDuff.Mode.CLEAR</code>, what I don't know is to specify the round corners as the region to be erased. I'm looking for something like this:</p>
  
  <pre><code>@Override
  protected void onDraw(Canvas canvas) {
      //superclass will draw the bitmap accordingly 
      super.onDraw(canvas);
  
      final Paint paint = new Paint();
      paint.setAntiAlias(true);
      paint.setXfermode(new PorterDuffXfermode(PorterDuff.Mode.CLEAR));
  
      //this will erase a round rectangle, I need the exact inverse
      canvas.drawRoundRect(rect, rx, ry, paint);
  }
  </code></pre>
  
  <p>Is there any way to "erase" not the round rectangle, but it's inverse, ie, the round corners? And what if I just want to erase one of the corners?</p>