Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 289
  • Last Modified:

Paint circles on an image

I need to implement a work sheet for a workshop mechanics. I need to record in a car which damaged parts (As attached picture shows). What better way to do it.
Img.jpg
0
rflorencio
Asked:
rflorencio
  • 3
  • 2
1 Solution
 
käµfm³d 👽Commented:
What kind of application are you building:  WinForms, WPF, web?
0
 
rflorencioAuthor Commented:
winforms
0
 
käµfm³d 👽Commented:
You marked this as both VB.NET and C#. Which language are you using?
0
 
rflorencioAuthor Commented:
Vb.net, first option.
0
 
käµfm³d 👽Commented:
Here's one way to do it:

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Me.PictureBox1.Tag = Me.PictureBox1.Image.Clone()  ' Create a copy that we can use to clear the image
    End Sub

    Private Sub PictureBox1_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseUp
        Dim centerPoint As Point = e.Location  ' Where did we click?

        centerPoint.Offset(-10, -10)  ' Offset the circle so that it is drawn with the center where we clicked

        Using g As Graphics = Graphics.FromImage(Me.PictureBox1.Image)  ' We need a Graphics object in order to do drawing on the image
            g.FillEllipse(Brushes.Red, New Rectangle(centerPoint, New Size(20, 20)))  ' Draw the circle
        End Using

        Me.PictureBox1.Invalidate()
    End Sub

    Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
        Me.PictureBox1.Image = DirectCast(Me.PictureBox1.Tag, Image).Clone()  ' Assign the copy we made above as a "clean" image. Be sure to copy it (the Clone method)!!
        Me.PictureBox1.Invalidate()
    End Sub
End Class

Open in new window


 Screenshot
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now