public static void main(String[] args) throws IOException {
BufferedImage bi1 = ImageIO.read(new File("C:\\Users\\dell\\Desktop\\img\\b5.jpeg"));
// 根据需要是否使用 BufferedImage.TYPE_INT_ARGB(透明)
BufferedImage bi2 = new BufferedImage(bi1.getWidth(), bi1.getHeight(),
BufferedImage.TYPE_INT_ARGB);
Ellipse2D.Double shape = new Ellipse2D.Double(0, 0, bi1.getWidth(), bi1
.getHeight());
Graphics2D g2 = bi2.createGraphics();
g2.setClip(shape);
// 使用 setRenderingHint 设置抗锯齿
g2.drawImage(bi1, 0, 0, null);
g2.dispose();
try {
ImageIO.write(bi2, "png", new File("C:\\Users\\dell\\Desktop\\img\\aa.png"));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}