PDA

View Full Version : My plugin - FindMultiColorsTolerance



Markus
10-10-2007, 05:58 PM
I was bored, so I thought: Why not create a nice little plugin?

So here I present:
function FindMultiColorsTolerance(var Points : T2dPointArray; colors : TIntegerArray; xs, ys, xe, ye : integer; tolerances : TIntegerArray; dc : longword) : boolean;

WTF will this do? Eat my cookies???!?!?!
It'll search for multiple colors in one function, saving some time compared to multiple findcolorstolerance, as this reduces some overhead with multiple colors. That will make this faster then just a few old plain FindColorsTolerance

So, tell me exactly why I should use this
Ok. If you mess with TPAA's much, you know that FindColorsTolerance takes a while, as you need to run it for every color you want to look for. So everytime it'll create a new bitmap, loop through all pixels etc etc.
This, creates one bitmap, loops one time through the pixels, and then compares if the pixel matches any of the colors.

Wow, sounds nice, but how can I use it?
Let's go through all parameters.
var Points : T2dPointArray; - This is the functions output. Each color gets its own TPA.
Example: You are looking for three colors, color 1, 2 and 3.
color 1 is found at 12, 34. color 2 is found at 1,1 2,2 and 5,5 and color 3 isn't found
The array would then look like this:

Points[0][0] = 12, 34
Points[1][0] = 1,1
Points[1][1] = 2, 2
Points[1][2] = 5, 5
Points[2] = empty

colors : TIntegerArray - Here you enter the colors: example: [123456, 1236, 122]
xs, ys, xe, ye : integer; - You should know about these
tolerances : TIntegerArray; - Here you enter the tolerances. Each color must have it's own tol, duplicate tols are allowed. Example: [0, 0, 56]
dc : longword - If you are really leet, enter the dc here. If not: getclientcanvas.handle :f:

Credits
Freddy1990, it's based on his FindColorTolerance source :)

ShowerThoughts
10-10-2007, 06:13 PM
you done it again, still need to find out what!:D

Markus
10-10-2007, 06:48 PM
Lol, thanks :D

the scar noob
10-10-2007, 07:06 PM
Amazing work! Keep it up!
-stijn.

Santa_Clause
10-10-2007, 11:35 PM
Nice!

R0b0t1
10-11-2007, 12:54 AM
I though it was a HDC? Never would have though.


Nice job though, but I think you should refine the way it stores the points...

Markus
10-11-2007, 11:47 AM
Nice job though, but I think you should refine the way it stores the points...


Like one big TPA for all colors?

PwNZoRNooB
10-11-2007, 12:50 PM
Pretty cool :)

SuperScripter
10-11-2007, 03:49 PM
Very Handy

Naum
10-11-2007, 03:53 PM
I could use this later thx markus.

->{Nauman}<-

mastaraymond
10-11-2007, 06:58 PM
Nice, well done! Keep up the good work.

~Raymond

R0b0t1
10-11-2007, 09:04 PM
Yes, you can read my mind Markus. Use a TPointArray instead of the T2DIntArray.

Markus
10-12-2007, 09:23 AM
Yes, you can read my mind Markus. Use a TPointArray instead of the T2DIntArray.

Well it's actually a T2dPointArray ;)
But ok, it's five mins of work. How should I call it? FindMultiTpaColorsTolerance?

mat_de_b
10-12-2007, 04:07 PM
Keep it as a T2DPointArray so that you know what points are for which colors?

Markus
10-12-2007, 07:05 PM
Keep it as a T2DPointArray so that you know what points are for which colors?

That's what I currently got :)

footballjds
01-18-2008, 02:21 PM
Nice i like it!:D

n3ss3s
01-18-2008, 03:04 PM
10-12-2007, 03:05 PM

@Markus: Very good :)

Markus
01-19-2008, 09:57 PM
Hehe gravedig.

Few things:
1. This doesnt work correctly if the X and Y corner aren't 0
2. Tolerance is a bit broken