SRL Archive - Research & Development Lounge

My plugin - FindMultiColorsTolerance


Markus

2007-10-10 13:58:56

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

2007-10-10 14:13:08

you done it again, still need to find out what!:D

Markus

2007-10-10 14:48:58

Lol, thanks :D

the scar noob

2007-10-10 15:06:17

Amazing work! Keep it up!
-stijn.

Santa_Clause

2007-10-10 19:35:58

Nice!

R0b0t1

2007-10-10 20:54:48

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

2007-10-11 07:47:52

From: R0b0t1
Nice job though, but I think you should refine the way it stores the points…



Like one big TPA for all colors?

PwNZoRNooB

2007-10-11 08:50:40

Pretty cool :)

SuperScripter

2007-10-11 11:49:05

Very Handy

Naum

2007-10-11 11:53:53

I could use this later thx markus.

->{Nauman}<-

mastaraymond

2007-10-11 14:58:22

Nice, well done! Keep up the good work.

~Raymond

R0b0t1

2007-10-11 17:04:08

Yes, you can read my mind Markus. Use a TPointArray instead of the T2DIntArray.

Markus

2007-10-12 05:23:16

From: R0b0t1
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

2007-10-12 12:07:36

Keep it as a T2DPointArray so that you know what points are for which colors?

Markus

2007-10-12 15:05:53

From: mat_de_b
Keep it as a T2DPointArray so that you know what points are for which colors?


That's what I currently got :)

footballjds

2008-01-18 09:21:14

Nice i like it!:D

n3ss3s

2008-01-18 10:04:48

10-12-2007, 03:05 PM

@Markus: Very good :)

Markus

2008-01-19 16:57:14

Hehe gravedig.

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