Solved

VB.NET - Graphics

Posted on 2003-11-23
4
375 Views
Last Modified: 2013-12-04
I'm using VB.NET and I need to create functionality where I can select different parts of a jpeg image (like an image selector in photoshop) and return the co-ordinates. I then need to store those co-ordinates in a database so later on when I go to view the image I can tell where I have selected and where I haven't.

I'm not sure if this is the best way to do it. But I need to tell where different parts of an image are. It is for a map of a retirement village and they have different units and I need to associate each unit number with an area on the diagram so my program can tell where each unit is.

If you can help me out with some code or a better suggestion on how to do it I will be very grateful.
0
Comment
Question by:AndrewADunn
4 Comments
 

Accepted Solution

by:
omid_krd earned 125 total points
ID: 10061870
Create a winform and put a picturebox on it named "pic" :
----------------------------
    Private pt As Point, lastPt As Point, startPt As Point
    Private selecting As Boolean

    Private Sub pic_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pic.MouseDown
        selecting = True
        lastPt = New Point(e.X, e.Y)
        startPt = lastPt
    End Sub

    Private Sub pic_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pic.MouseMove
        If (selecting) Then
            Dim rect As Rectangle
            Dim pt1 As Point = pic.PointToScreen(startPt)
            rect = New Rectangle(pt1.X, pt1.Y, lastPt.X - startPt.X, lastPt.Y - startPt.Y)
            ControlPaint.DrawReversibleFrame(rect, Color.Black, FrameStyle.Dashed)
            lastPt.X = e.X
            lastPt.Y = e.Y
            rect = New Rectangle(pt1.X, pt1.Y, lastPt.X - startPt.X, lastPt.Y - startPt.Y)
            ControlPaint.DrawReversibleFrame(rect, Color.Black, FrameStyle.Dashed)
        End If
    End Sub

    Private Sub pic_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles pic.MouseUp
        If (selecting) Then
            Dim rect As Rectangle
            Dim pt1 As Point = pic.PointToScreen(startPt)
            rect = New Rectangle(pt1.X, pt1.Y, lastPt.X - startPt.X, lastPt.Y - startPt.Y)
            ControlPaint.DrawReversibleFrame(rect, Color.Black, FrameStyle.Dashed)
        End If
        selecting = False
    End Sub
-----------------
After mousedown the positions are stored in startPt and lastPt
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Displaying an arrayList in a listView using the default adapter is rarely the best solution. To get full control of your display data, and to be able to refresh it after editing, requires the use of a custom adapter.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

708 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

15 Experts available now in Live!

Get 1:1 Help Now