-
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 ?
-
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.
-
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.
-
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.
-
Here's a post of me :D See signature ;)
Just to make this complete :rolleyes:
:)