Results 1 to 5 of 5

Thread: Trace Wizzard

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Location
    Israel
    Posts
    27

    Lightbulb Trace Wizzard

    I have been dabbling with a simple drawing program.
    And I can't seem to create a very (seemingly) simple function.

    As with Photoshops "Trace Wizzard" I would like to be able to "Mark" a non Rectanguar area, that locates the color difference between the background and the Image I'm trying to trace.

    I don't know a whole lotta graphics.
    Daamn my last project of this type was done in Pascal / ASM way back in 1997.

    Please help ?
    -Mick-
    Cheers,
    | Mickey Perlstein
    | Quality Computerized solutions
    Email: [email protected]
    ....................
    Artificial intelligence is no match for natural stupidity.

  2. #2
    Addicted Member
    Join Date
    Apr 2000
    Location
    England
    Posts
    246
    Well Assuming you have the whole image in memory.

    You can then get the pixels values into an array

    Then write a Recursive Function to check the colour is with range of starting colour

    Something like: (not exact code, not sure of getlockedarray, never used it myself)
    Code:
    dim MatchArray() as byte
    dim PixelArray() as long
    dim range as long
    
    
    sub click Event(button as button, x as long, y as long)
    
    range = textboxRange.text
    
    pixelArray = getlockedArray(ImageDC)
    
    redim MatchArray(sizeof(pixelarray))
    dim temp as long
    for i = 0 to sizeof(matcharray)
         matcharray(temp) = 0
    next
    
    dim colour as colour
    colour = pixelarray(y*picture.width + x)
    CheckPixels(x,y, colour)
    
    end sub
    
    sub CheckPixels(x as long, y as long, colour as colour)
    
         dim co-ord as long
         co-ord = y*picture.width + x
         if matcharray(co-ord) = 0 then
                if (pixelarray(co-ord) < colour+range) and (pixelarray(co-ord) > colour-range) then
                      matcharray(co-ord) = 2 'true
                else
                      matcharray(co-ord) = 1 'false
                end if
              checkpixels(x+1,y,colour)
              checkpixels(x-1,y,colour)
              checkpixels(x,y+1,colour)
              checkpixels(x,y-1,colour)
         end if
    end sub
    MatchArray will now contain 0 for unchecked (colour with range, but not touching clicked pixel), 1 for not within range and 2 for within selection.

    the above code is a click hash, and will not work, but the concept will.
    Some Days, i just get this feeling that i'm helping to write dozens of Viruses...

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Jul 2000
    Location
    Israel
    Posts
    27
    Thankyou for the fast reply.
    I unfortunately don't have the array in memory.

    I have another Question though

    how can I get an entire JPG file into memory???

    thanks.
    -Mick-
    Cheers,
    | Mickey Perlstein
    | Quality Computerized solutions
    Email: [email protected]
    ....................
    Artificial intelligence is no match for natural stupidity.

  4. #4
    Addicted Member
    Join Date
    Apr 2000
    Location
    England
    Posts
    246
    Have a look at Fox's Site (look for a post by him)

    GetLockedArray is an API call you can use to return the array froma DC, you need to put it back again i think, before blting it back to your picturebox?

    to get the entire thing into memory, you first need to CreateCompatibleDC(API) to put it in, details on Fox Site or several posts here. you load it up.
    Some Days, i just get this feeling that i'm helping to write dozens of Viruses...

  5. #5
    PowerPoster Fox's Avatar
    Join Date
    Jan 2000
    Location
    *afk*
    Posts
    2,088
    Here's a post of me See signature

    Just to make this complete


Posting Permissions

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



Click Here to Expand Forum to Full Width