Results 1 to 2 of 2
  1. #1
    Join Date
    Nov 2002

    Unanswered: finding picture edge in visual basic

    i am currently working on a program which loads field maps to a picture box and performs a model of patch spraying operation. basically a tractor and sprayer drives around the field and by recognising the colour of a pixel it decides whether to spray or not. the maps are in black and white. black for weed white for non weed. i am trying to develop some code which steps around the edge pixels of the field and changes their colour to show that they have been processed. i am very new to programming and any help in this process would be greatly appreciated. thank you

  2. #2
    Join Date
    Nov 2002
    Hello jpcar,

    The "Point" command will allow you to read a pixel.

    The "PSet" command will allow you to update a pixel.

    I'd recommend setting up a subroutine you could call using X and Y parameters to reduce the amount of coding and debugging. Something like this:
    ' clockwise from upper left
    ScanPoints(Picture.Width,Picture.Width,0,0,Picture .Height,1)
    ' Routine
    Public Sub ScanPoints(tmpXFrom as long, tmpXTo as long,
    tmpXStep as long, tmpYFrom as long,
    tmpYTo as long, tmpYStep as long)
    ' Left/right or Up/down
    If tmpXStep = 0 then
    for lclIndex=tmpYFrom to tmpYTo step tmpYStep
    for lclIndex=tmpXFrom to tmpXTo step tmpXStep
    End If

    End Sub

    This isn't elegant or fast, but should put you in the ballpark.

    If you need more information, here are some books that go into graphics:

    Instant Visual Basic Animation
    The Revolutionary Guide to Bitmapped Graphics
    The Visual Basic Programmers Guide to the Win32 API

    Good luck,
    Bruce Baasch

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts