Hi Kerim,

> Hi, I�m trying to rotate an image.
> The procedure I had in mind was:
> 1) Graphics2D g= (Graphics2D)myClass.getImage().getGraphics();
> 2) g.rotate(myValue);

The method "Image.getGraphics()" returns a graphics object that allows
you to draw into that image.  That Graphics object has no effect on how
that image is drawn into other destinations.

Since images are drawn relative to the coordinate system in effect when
they are drawn, you need to perform the rotate() method on the Graphics
on which you execute the drawImage() call to draw that image, not on
the Graphics you get from that image.  For instance:

        public void paint(Graphics g) {
            Graphics2D g2d = (Graphics2D) g;
            g2d.rotate(myValue);  // You may need to adjust the origin here...
            g2d.drawImage(myClass.getImage(), x, y, <observer>);
        }

If you have the image in a BufferedImage object, you can use a Filter
to rotate the image itself, rather than to draw it rotated.  Currently
the way to read images out of a file is to use some form of getImage()
or createImage(filename/URL) method which returns an Image that is not
a BufferedImage (it is a private internal subclass of Image) so you
can't use those images with the AffineTransformOp.  The ImageIO
framework which is currently working its way through the Community
Process should provide a facility for loading images from files or
URLs directly into a BufferedImage.

Until then, you can create a BufferedImage of the appropriate size and
format and then draw your sprite imate into the BufferedImage and then
use an AffineTransformOp on the BufferedImage copy of it as a workaround.

                                ...jim

===========================================================================
To unsubscribe, send email to [EMAIL PROTECTED] and include in the body
of the message "signoff JAVA2D-INTEREST".  For general help, send email to
[EMAIL PROTECTED] and include in the body of the message "help".

Reply via email to