rotating an images, no rotateflip
hi,
I need to rotate a picture box with about 35 degrees. now I tried this
Code:
PictureBox1.CreateGraphics.ResetTransform()
PictureBox1.CreateGraphics.TranslateTransform(64.0F, 64.0F)
PictureBox1.CreateGraphics.RotateTransform(35)
PictureBox1.CreateGraphics.DrawImage(sword, (-sword.Width \ 2), -sword.Height \ 2)
PictureBox1.Refresh()
But it doesn't seem to work :ehh: Does someone know how to do this
Re: rotating an images, no rotateflip
Don't use CreateGraphics for drawing in dotNet. Instead use the graphics in the Paint event sub:
Code:
Private Sub Picture_Box1.Paint(sender As Object, e As PaintEventArgs) _
_Handles PictureBox1.Paint
'no need for ResetTransform
e.Graphics.TranslateTransform(64.0F, 64.0F)
e.Graphics.RotateTransform(35)
e.Graphics.DrawImage(... etc.)
'DO NOT put Refresh here!!!
End Sub
When you need to make the Paint event fire, put PictureBox1.Refresh or PictureBox1.Invalidate in another sub -- for example a ButtonClick, Timer.Tick or MouseMove depending on what you are doing.
BB
Then you can be sure that Windows can repaint the rotated image whenever necessary.
Re: rotating an images, no rotateflip
It rotates 35 degrees, but it is out of focus.