springboot项目 在做图片处理的时候做过圆形处理 用的 Ellipse2D.Double
现在想请问一下有没有什么方法可以实现同等类似的功能 不过是处理正正六边形 而不是圆形
public void updateForm(String url) throws IOException {
BufferedImage bi1 = ImageIO.read(new File(url));
// 根据需要是否使用 BufferedImage.TYPE_INT_ARGB
BufferedImage bi2 = new BufferedImage(bi1.getWidth(), bi1.getHeight(),
BufferedImage.TYPE_INT_RGB);
Ellipse2D.Double shape = new Ellipse2D.Double(0, 0, bi1.getWidth(), bi1
.getHeight());
Graphics2D g2 = bi2.createGraphics();
g2.setBackground(Color.WHITE);
g2.fill(new Rectangle(bi2.getWidth(), bi2.getHeight()));
g2.setClip(shape);
// 使用 setRenderingHint 设置抗锯齿
g2.drawImage(bi1, 0, 0, null);
g2.dispose();
try {
ImageIO.write(bi2, "jpg", new File(url));
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
上面是圆形处理 Ellipse2D.Double这里想换成处理成正六边形的 请教一下各位大佬