Java - 旋转后将图像移动到旧坐标

时间:2015-03-15 15:09:59

标签: java rotation coordinates

在我看到这个网站here之后,我尽力使用它。我想将图像旋转90度并将其放在与旋转前相同的位置。我试过这样的话:

            int xold = charX;
            int yold = charY;
            charX = 0;
            charY = 0;
            //g.drawImage(man, charX, charY, man.getWidth(), Man.getHeight(), null); -> I have tried it with and without this line.
            g.rotate(Math.toRadians(90)); //After I moved the picture to (0, 0) I rotate it by 90°.
            charX = xold; //After this I move the (rotated) picture to the old place
            charY = yold;
            g.drawImage(man, charX, charY, man.getWidth(), man.getHeight(), null); //And finally I print int using my Graphics2D object

一定有些错误。如果我现在执行此代码,图片就会消失,最后返回旧状态。

有人弄错了吗?

0 个答案:

没有答案