public ImageData maskAlphaAsRoundedrectangle(ImageData imageData,Dimension corner,int alphaValue){
  byte[] alphaData=imageData.alphaData;
  int width=imageData.width;
  int height=imageData.height;
  int r=corner.width / 2;
  double r_square=r * r;
  byte[] alphaPixel=new byte[r];
  Arrays.fill(alphaPixel,(byte)alphaValue);
  r=Math.min(r,Math.min(imageData.height,imageData.width) / 2);
  for (int i=0; i < r; i++) {
    int p=r - (int)Math.sqrt(r_square - (double)((i) * (i)));
    if (p > 0) {
      System.arraycopy(alphaPixel,0,alphaData,(r - (i + 1)) * width,p);
      System.arraycopy(alphaPixel,0,alphaData,(r - (i + 1)) * width + (width - p),p);
      System.arraycopy(alphaPixel,0,alphaData,((height - (r - (i)))) * width,p);
      System.arraycopy(alphaPixel,0,alphaData,((height - (r - (i)))) * width + (width - p),p);
    }
  }
  return imageData;
}

public ImageData maskAlphaAsRoundedrectangle ( ImageData imageData , Dimension corner , int alphaValue ) { byte [ ] alphaData = imageData . alphaData ; int width = imageData . width ; int height = imageData . height ; int r = corner . width / 2 ; double r_square = r * r ; byte [ ] alphaPixel = new byte [ r ] ; Arrays . fill ( alphaPixel , ( byte ) alphaValue ) ; r = Math . min ( r , Math . min ( imageData . height , imageData . width ) / 2 ) ; for ( int i = 0 ; i < r ; i ++ ) { int p = r - ( int ) Math . sqrt ( r_square - ( double ) ( ( i ) * ( i ) ) ) ; if ( p > 0 ) { System . arraycopy ( alphaPixel , 0 , alphaData , ( r - ( i + 1 ) ) * width , p ) ; System . arraycopy ( alphaPixel , 0 , alphaData , ( r - ( i + 1 ) ) * width + ( width - p ) , p ) ; System . arraycopy ( alphaPixel , 0 , alphaData , ( ( height - ( r - ( i ) ) ) ) * width , p ) ; System . arraycopy ( alphaPixel , 0 , alphaData , ( ( height - ( r - ( i ) ) ) ) * width + ( width - p ) , p ) ; } } return imageData ; }
masks the corners of a rounded rectangle with a specified alpha value .
