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 :)
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 :)