public static BufferedImage setBorderRadius(BufferedImage srcImage, int radius){
    int width = srcImage.getWidth();
    int height = srcImage.getHeight();
    BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
    Graphics2D g2d = image.createGraphics();
    g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
    g2d.fillRoundRect(0, 0, width, height, radius, radius);
    g2d.setComposite(AlphaComposite.SrcIn);
    g2d.drawImage(srcImage, 0, 0, width, height, null);
    return image;
}

 

相关文章:

  • 2021-08-01
  • 2021-12-31
  • 2021-07-28
  • 2021-09-20
  • 2022-12-23
  • 2022-12-23
  • 2021-06-04
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-01-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-06-26
  • 2021-06-14
相关资源
相似解决方案