日期:2014-05-20 浏览次数:20811 次
public class One {
public static void main(String[] args) throws IOException {
One one = new One();
one.createImage();
}
public void createImage() throws IOException{
File file = new File("C:/1.jpg");
int width = 200 ;
int height= 200 ;
BufferedImage bi = new BufferedImage(width,height,BufferedImage.TYPE_INT_BGR);
Graphics2D g2 = (Graphics2D)bi.getGraphics();
/*问题位置*/g2.setBackground(Color.red);
/*问题位置*/g2.clearRect(0, 0, width, height);
Rectangle2D rect = new Rectangle2D.Double(0, 0, width, height);
Ellipse2D raduis = new Ellipse2D.Double();
raduis.setFrameFromCenter(width/2, height/2, 0, 0);
g2.draw(raduis);
g2.draw(rect);
ImageIO.write(bi, "jpg", file);
}
}
Graphics2D g2 = bi.createGraphics();
g2.setPainter(Color.WIHTE);
g2.fillRect(0, 0, width, height);
g2.setPainter(Color.RED);
Rectangle2D rect = new Rectangle2D.Double(0, 0, width, height);
Ellipse2D raduis = new Ellipse2D.Double();
raduis.setFrameFromCenter(width/2, height/2, 0, 0);
g2.draw(raduis);
g2.draw(rect);
g2.dispose();