How to draw a thick arrow in picturebox
If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
8 posts
Page 1 of 1
Hello I have here a problem with drawing on the picture.
Draw a picture on well but it's drawing a thin line and I need a thicker thickness of at least 4.5.
But I'd like to draw arrow and not line.
Need a simple arrows with no gradient and a much smaller and thinner.
Approximately 4.5 thickness used on the image.
Here's an example of what I need.
how do i do that ?
So far, I have only this code.
Here is the code:
Any help would benefit me.
Draw a picture on well but it's drawing a thin line and I need a thicker thickness of at least 4.5.
But I'd like to draw arrow and not line.
Need a simple arrows with no gradient and a much smaller and thinner.
Approximately 4.5 thickness used on the image.
Here's an example of what I need.
how do i do that ?
So far, I have only this code.
Here is the code:
Code: Select all
Private Sub PictureBox1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
If _Previous IsNot Nothing Then
If PictureBox1.Image Is Nothing Then
Dim bmp As New Bitmap(PictureBox1.Width, PictureBox1.Height)
Using g As Graphics = Graphics.FromImage(bmp)
g.Clear(Color.White)
End Using
PictureBox1.Image = bmp
End If
Using g As Graphics = Graphics.FromImage(PictureBox1.Image)
g.DrawLine(Pens.Red, _Previous.Value, e.Location)
End Using
PictureBox1.Invalidate()
_Previous = e.Location
End If
End Sub
Private _Previous As System.Nullable(Of Point) = Nothing
Private Sub pictureBox1_MouseDown(ByVal sender As Object, ByVal e As MouseEventArgs) Handles PictureBox1.MouseDown
_Previous = e.Location
PictureBox1_MouseMove(sender, e)
End Sub
Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
_Previous = Nothing
End Sub
Any help would benefit me.
Hello,
you can use this to draw a arrow
This will draw a arrow on the picturebox
you can use this to draw a arrow
This will draw a arrow on the picturebox
Code: Select all
Private Sub PictureBox1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles PictureBox1.Paint
b = New Bitmap(PictureBox1.Image)
e.Graphics. = Graphics.FromImage(b)
e.Graphics.DrawLine(Pens.Yellow, 100, 10, 110, 20)
e.Graphics.DrawLine(Pens.Yellow, 110, 20, 100, 30)
e.Graphics.DrawLine(Pens.Yellow, 90, 20, 110, 20)
PictureBox1.Image = b
e.Graphics.Dispose()
End Sub
visit us on:
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
Try adding following code in first line after sub declatation:
Hope it helps!
-Filip
Code: Select all
I haven't been programming VB in a while now but I think this should workDim b as Bitmap
Hope it helps!
-Filip
CodenStuff wrote:Nope, it's just your sick and dirty mind. You sick twisted warped little pervo
still got error
e.Graphics. = Graphics.FromImage(b)
e.Graphics. = Graphics.FromImage(b)
Can you paste the error which are you getting?
CodenStuff wrote:Nope, it's just your sick and dirty mind. You sick twisted warped little pervo
Here is where the error is
Code: Select all
e.Graphics. = Graphics.FromImage(b)
You can use this code to draw the arrow by mouse click:
Code: Select all
The scale can also be adjusted. Dim g As Graphics
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
PictureBox1.Image = New Bitmap(PictureBox1.Width, PictureBox1.Height)
g = Graphics.FromImage(PictureBox1.Image)
End Sub
Sub drawArrow(ByVal location As PointF, ByVal scale As Single)
Dim points(8 - 1) As PointF
points(0) = location
points(1) = New PointF(location.X + (scale * 2), location.Y - (scale * 1.5))
points(2) = New PointF(points(1).X, points(1).Y + scale)
points(3) = New PointF(points(2).X + (scale * 2), points(2).Y)
points(4) = New PointF(points(3).X, points(3).Y + scale)
points(5) = New PointF(points(4).X - (scale * 2), points(4).Y)
points(6) = New PointF(points(5).X, points(5).Y + scale)
points(7) = location
Dim pathTypes(points.Length - 1) As Byte
For i As Integer = 0 To pathTypes.Length - 1
pathTypes(i) = Drawing2D.PathPointType.Line
Next
Dim gp As Drawing2D.GraphicsPath = New Drawing2D.GraphicsPath(points, pathTypes)
g.FillPath(Brushes.Red, gp)
End Sub
Private Sub PictureBox1_MouseUp(sender As System.Object, e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp
Dim location As PointF = New PointF(e.X, e.Y)
Dim scale As Single = 30
drawArrow(location, scale)
PictureBox1.Refresh()
End Sub
8 posts
Page 1 of 1
Copyright Information
Copyright © Codenstuff.com 2020 - 2023