Java2D 기본 사용

1370 단어 Java2D
Java2D 기본 사용 간단한 나열


 :
public void CreateImage(OutputStream out,int width,int height) throws Exception
{
    BufferedImage readImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_BGR);
		
    try
    {
        Graphics2D g = readImage.createGraphics();
        //...
        ImageIO.write(readImage, "png", out);
    }
    catch(Exception ex)
    {
        throw ex;
    }
}

 :
g.setFont(new Font("MS Gothic", Font.BOLD, 13));

 :
g.setColor(Color.BLACK);

 :
Stroke s = new BasicStroke(0.2f,BasicStroke.CAP_SQUARE, BasicStroke.JOIN_MITER, 1.0f, new float[]{3.0f, 3.0f}, 0f );
		g.setStroke(s);

 :
AffineTransform ct = AffineTransform.getRotateInstance(-Math.PI/50);
g.transform(ct);

 ( ):
BufferedImage bi2 = new BufferedImage(10, 10,
BufferedImage.TYPE_INT_RGB);
Graphics2D big2 = bi2.createGraphics();
big2.setColor(Color.WHITE);
big2.fillRect(0, 0, 10, 10);
		
big2.setColor(Color.RED);
big2.drawLine(10, 0, 0, 10);
big2.drawLine(0, 0, 4, 4);
		
Rectangle2D r2 = new Rectangle(0,0,10,10);
TexturePaint tp2 = new TexturePaint(bi2,r2);

g.setPaint(tp2);


좋은 웹페이지 즐겨찾기