I have a picturebox that I need to rotate by angle and at the same time draw a crosshair when the mouse focuses on the image.
I can draw a crosshair on the image and also rotate the image inside the picturebox but what I can't do is BOTH.
If I rotate the image, the crosshair will be gone, or of I draw crosshair over the rotated image, the image will be back to it's original position.
please can anyone help me on this. TIA!
here's the code on the picturebox paint event:
Dim pic As Bitmap
picTemp.Load("C:\test.tif")
pic = New Bitmap(picTemp.Image)
Private Sub picImage_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles picImage.Paint
If isRotate = True Then
With e.Graphics
.TranslateTransform(pic.Width / 2, pic.Height / 2, Drawing2D.MatrixOrder.Append)
.RotateTransform(Me.rotateAngle)
.DrawImage(pic, -pic.Width \ 2, -pic.Height \ 2)
isRotate = False
picTemp.Image = picImage.Image
End With
End If
Dim newpen As New Pen(Color.Red, 1)
newpen.DashStyle = Drawing2D.DashStyle.Dash
e.Graphics.DrawLine(newpen, rubberNow.X, 1, rubberNow.X, picImage.Height)
e.Graphics.DrawLine(newpen, 1, rubberNow.Y, picImage.Width, rubberNow.Y)
end sub
I can draw a crosshair on the image and also rotate the image inside the picturebox but what I can't do is BOTH.
If I rotate the image, the crosshair will be gone, or of I draw crosshair over the rotated image, the image will be back to it's original position.
please can anyone help me on this. TIA!
here's the code on the picturebox paint event:
Dim pic As Bitmap
picTemp.Load("C:\test.tif")
pic = New Bitmap(picTemp.Image)
Private Sub picImage_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles picImage.Paint
If isRotate = True Then
With e.Graphics
.TranslateTransform(pic.Width / 2, pic.Height / 2, Drawing2D.MatrixOrder.Append)
.RotateTransform(Me.rotateAngle)
.DrawImage(pic, -pic.Width \ 2, -pic.Height \ 2)
isRotate = False
picTemp.Image = picImage.Image
End With
End If
Dim newpen As New Pen(Color.Red, 1)
newpen.DashStyle = Drawing2D.DashStyle.Dash
e.Graphics.DrawLine(newpen, rubberNow.X, 1, rubberNow.X, picImage.Height)
e.Graphics.DrawLine(newpen, 1, rubberNow.Y, picImage.Width, rubberNow.Y)
end sub