Solved

Paint circles on an image

Posted on 2013-12-26
5
279 Views
Last Modified: 2013-12-27
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
Comment
Question by:rflorencio
  • 3
  • 2
5 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 39739882
What kind of application are you building:  WinForms, WPF, web?
0
 

Author Comment

by:rflorencio
ID: 39739943
winforms
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 39739947
You marked this as both VB.NET and C#. Which language are you using?
0
 

Author Comment

by:rflorencio
ID: 39739995
Vb.net, first option.
0
 
LVL 74

Accepted Solution

by:
käµfm³d   👽 earned 500 total points
ID: 39740003
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

It’s quite interesting for me as I worked with Excel using vb.net for some time. Here are some topics which I know want to share with others whom this might help. First of all if you are working with Excel then you need to Download the Following …
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now