2013/01/16

Java 實心圓







import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;

public class Cycle {

    public static void main(String[] args) throws IOException {
        BufferedImage buffImg = new BufferedImage(300, 300,
                BufferedImage.TYPE_INT_RGB);
        Graphics2D g = buffImg.createGraphics();
        g.setColor(Color.WHITE);
        g.fillRect(0, 0, 300, 300);
        g.setColor(Color.BLACK);
        g.fillOval(50, 50, 200, 200);
        g.dispose();
        g.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
                RenderingHints.VALUE_ANTIALIAS_ON);
        ImageIO.write(buffImg, "jpg", new File("test.jpg"));

    }
}


參考資料:
http://bbs.csdn.net/topics/60361356