|
-
Jan 29th, 2012, 08:02 AM
#1
Thread Starter
Addicted Member
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 Does someone know how to do this
-
Jan 29th, 2012, 09:36 AM
#2
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.
-
Jan 29th, 2012, 01:52 PM
#3
Thread Starter
Addicted Member
Re: rotating an images, no rotateflip
It rotates 35 degrees, but it is out of focus.
Last edited by ikdekker; Jan 29th, 2012 at 01:57 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|