Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VB.NET - Graphics

Posted on 2003-11-23
4
Medium Priority
?
398 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

A short article about problems I had with the new location API and permissions in Marshmallow
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
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 …
Loops Section Overview

598 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