?
Solved

VB.NET - Graphics

Posted on 2003-11-23
4
Medium Priority
?
395 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
4 Comments
 

Accepted Solution

by:
omid_krd earned 500 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

Learn how to optimize MySQL for your business need

With the increasing importance of apps & networks in both business & personal interconnections, perfor. has become one of the key metrics of successful communication. This ebook is a hands-on business-case-driven guide to understanding MySQL query parameter tuning & database perf

Question has a verified solution.

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

Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
Make the most of your online learning experience.
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 …
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

764 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