I have a picturebox, and would need to draw a single red pixel at a given coordinate. This pixel will move, and when i assign a new position the old position is removed, so that only a single pixel is red at any given time. If possible it would be nice that this pixel is 50% transparent.
The most crucial thing is that it has to be fast. It is just used to display the current position that is beeing processed on the image, so it is imperative that it does not slow down the main program.
Can this be done? Thanks
In addition to Hans's comment:
Dim currentPoint As Point = Point.Empty
Private Sub button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles button1.Click
' Clear previous pixel
Dim invalidRect As Rectangle = New Rectangle(currentPoInteger.X,currentPoInteger.Y, 1, 1)
pictureBox1.Invalidate(invalidRect)
' Move to next point some how
currentPoint.X = currentPoint.X + 1
' Invalidate to draw new pixel
invalidRect = New Rectangle(currentPoInteger.X, currentPoInteger.Y, 1, 1)
pictureBox1.Invalidate(invalidRect)
End Sub
Private Sub pictureBox1_Paint(ByVal sender As Object, ByVal e As PaintEventArgs) Handles pictureBox1.Click
If e.ClipRectangle.Contains(currentPoint) Then
e.Graphics.FillRectangle(Brushes.Red, currentPoInteger.X, currentPoInteger.Y, 1, 1)
End If
End Sub
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.