Solved

VB.NET - Graphics

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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

This is an explanation of a simple data model to help parse a JSON feed
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.
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 seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

729 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