首页 > 其他分享 >Graphics2D.drawRenderedImage

Graphics2D.drawRenderedImage

时间:2024-03-04 13:55:19浏览次数:25  
标签:Graphics2D java drawRenderedImage image g2d null

import java.awt.Graphics2D; //导入方法依赖的package包/类
public static void renderTest(Graphics2D g2d, int w, int h) {
    g2d.setColor(Color.yellow);
    g2d.fillRect(0, 0, w, h);

    BufferedImage image = getTestImage();
    // draw original image
    g2d.drawRenderedImage(image, null);

    // draw image with custom composite
    g2d.translate(175, 25);
    Composite currentComposite = g2d.getComposite();
    g2d.setComposite(new TestComposite());
    g2d.drawRenderedImage(image, null);
    g2d.setComposite(currentComposite);

    // draw image with XOR
    g2d.translate(175, 25);
    g2d.setXORMode(Color.red);
    g2d.drawRenderedImage(image, null);


    System.out.println("Painting is done...");
}
 

参考:https://vimsky.com/examples/detail/java-method-java.awt.Graphics2D.drawRenderedImage.html

标签:Graphics2D,java,drawRenderedImage,image,g2d,null
From: https://www.cnblogs.com/2008nmj/p/18051666

相关文章