AffineTransform & BufferedImage graphics

Document document = ..// Document extends

BufferedImage bufferedImage = (BufferedImage) document.createImage(document

.getWidth(), document.getHeight());

Now if I want to draw on bufferedImage

Graphics2D graphics2Ddoc = (Graphics2D) document.getGraphics();

Graphics2D graphics2D = (Graphics2D) bufferedImage.createGraphics();

// Draw the objects using graphics2D ......

graphics2Ddoc .drawImage(bufferedImage, 0, 0, document.getWidth(), document

.getHeight(),null);

If I would have applied some transformation before creating buffered image then will the buffered image graphics objectgraphics2D hold the same transformation?

I loose the antialiasing effect when I use double buffered approch as above.

[876 byte] By [mk2004a] at [2007-11-27 11:25:21]
# 1

Looks like your Document class must extend Component or JComponent.

Java has an interface named Document which is located in the javax.swing.text package. It is

generally not a good idea to use class names that exist in Java.

If I would have applied some transformation before creating buffered image then will the

buffered image graphics object graphics2D hold the same transformation?

No. The component graphics context is different than the one created for your BufferedImage.

You will need to set the transforms up for the BufferedImage graphics context just as you

did for the component.

I loose the antialiasing effect when I use double buffered approch as above.

Yes, the contexts are different. Set the RenderingHints again in the image graphics context.

crwooda at 2007-7-29 16:03:56 > top of Java-index,Security,Cryptography...