Solved

VB.NET - Graphics

Posted on 2003-11-23
4
378 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
countPairs challenge 7 68
strCopies  challenge 17 83
allswap challenge 6 80
iSeries email authority 4 26
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Computer science students often experience many of the same frustrations when going through their engineering courses. This article presents seven tips I found useful when completing a bachelors and masters degree in computing which I believe may he…
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 …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

867 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

24 Experts available now in Live!

Get 1:1 Help Now