JAva点画不規則に従って図形を閉じる
詳細
public void sketch(List pointList) throws FileNotFoundException , IOException{
BufferedImage bi = new BufferedImage //
(512,512,BufferedImage.TYPE_INT_RGB);//INT ,RGB , 512, 512
Graphics2D g2 = (Graphics2D) bi.getGraphics();// ( )
g2.setColor(Color.BLACK); //
g2.fillRect(0, 0, bi.getWidth(), bi.getHeight()); //
GeneralPath gp=new GeneralPath(); //shape ,
Point p1=pointList.remove(0);
Point p2=pointList.remove(0);
gp.append(new Line2D.Double(p1.x,p1.y,p2.x,p2.y),true); //
for(Point point: pointList){ //
gp.lineTo(point.x,point.y);
}
gp.closePath(); //
g2.setColor(Color.WHITE); //
g2.fill(gp); //
ImageIO.write(bi,"JPEG",new FileOutputStream("G:\\a.jpg"));// JPEG
}