Java rotate an image in the center
center, image, java, rotation
Solution
You should give two more arguments in your rotate() call:
affineTransform.rotate(Math.toRadians(angle), m_imageWidth/2, m_imageHeight/2);
Problem
How do i rotate an image in the center if itself? this code works, but it rotates the image in the top-left corner of the screen: ``` AffineTransform oldtrans = new AffineTransform(); AffineTransform trans = new AffineTransform(); trans.setToIdentity(); trans.rotate(Math.toRadians(angle)); trans.translate(_x-(width/2), _y-(height/2)); g.setTransform(trans); g.drawImage(this.getImage(), (int)_x, (int)_y, (int)width, (int)height, null); trans.setToIdentity(); g.setTransform(oldtrans); ``` Please help!!!