Java 图片切圆角,消除锯齿

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

 

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。