I have drawn a bitmap image using GDI+ in C# on a windows form and would like to rotate the image while the up arrow key is pressed.
The effect I would like to get is to see the image move in a circular motion while it rotates. The rotation angle is incremented by 5 degrees each time the key pressed event handler executes.
The problem is that while the image does move in a circular path, a string of previously rotated images appear along the rotation path instead of just the latest rotated image.
i.e. If the maximum angle is set to 20 degrees, 4 images will be on the screen with the first rotated at 5 degrees, the next at 10 degrees and so on.
How do I just show a single bitmap image rotating instead of a string of previous images showing up along the rotation path?
The code is shown below:
Code:(in the form1 load event) Graphics g = CreateGraphics(); granade = new Bitmap("granade.jpg"); (in the form1 paint event) g.DrawImage(granade,0,0,20,20); (in the key down event) Matrix rotMatrix = new Matrix(); rotateAngle -= 5; rotMatrix.RotateAt(rotateAngle); g.Transform = rotMatrix;




Reply With Quote