In my program, I rotate the image in a PictureBox 180 degrees, showing it every .05 degrees. My problem is that the image flickers because I clear it before it redraws the image at the next angle. However, when I dont clear it, it leaves a mess behind. Does anyone know how to fix this problem? Here is my code:
Code:
Dim g As Graphics = Graphics.FromHwnd(Handle)
Dim decAngle As Decimal
Me.PictureBox.Visible = False
For decAngle = 180 To 360 Step 0.05
g.RotateTransform(decAngle)
g.TranslateTransform(Me.PictureBox.Location.X + Me.PictureBox.Image.Width \ 2, Me.PictureBox.Location.Y + Me.PictureBox.Image.Height \ 2, Drawing2D.MatrixOrder.Append)
g.DrawImage(Me.PictureBox.Image, Me.PictureBox.Image.Width \ 2, Me.PictureBox.Image.Height \ 2, -Me.PictureBox.Image.Width, -Me.PictureBox.Image.Height)
g.ResetTransform()
g.Clear(System.Drawing.SystemColors.Control)
Next decAngle
g.Dispose()
Me.PictureBox.Image.RotateFlip(RotateFlipType.Rotate180FlipNone)
Me.PictureBox.Visible = True