Rotating Buffered Image distorts image

SOLVED: Changed the program to save a copy of the original, unrotated image at the beginning of execution. Then I made each rotation an absolute rotation from 0 degrees instead of incremental 1 degree rotations. (So if the player hits the key five times, on the fifth rotation the sprite is shifting from the original position 5 degrees instead of rotating five times by one degree a piece.) The sprite stays intact.

I have a perfectly square PNG image that I am trying to rotate with keyboard input for a simple game.

This is what I'm doing:

Upon the key press:

Java Code:

player.rotate(player.getImage(), 5);

This fetches the BufferedImage from the player object and passes it to my generic rotate method:

Firstly, when you create a graphics context, you need to dispose of it when you're done by calling g.dispose(). Also, you have an extraneous "= dimg" on the 4th line. That's not you're problem though. It's possible that your drawImage command is causing the problem. You are using the drawImage that expects a BufferedImageOp as the 2nd parameter, and you are passing null. The API does not define what happens if you pass null. I'm guessing you meant to use

Java Code:

g.drawImage(img, 0, 0, null);

If that isn't it, then it may be that you're failing to clear the clip rectangle associated with the sprite before redrawing it, and so you're seeing several sprites at different angles all drawn on top of eachother.