From: Jason2gs
Thanks Wizzup ;)
So…
TempColor := FastGetPixel(Bitmap, CoordX, CoordY);
if Not(TempColor = Color) then
Is that correct? I'd still only be checking it for a single color though, right?
I'm sorry if I didn't catch what you said. Twas a little confusing :p
Oh, and in my original post. Those were actually two separate questions. The first one about FindColorsTolerance, the second about FastGetPixel vs GetColor.
This should work.. in theory…
I made it exactly like FindColorsTolerance, but this one skips the Color badColor.
I haven't tested it yet. Please tell me if it works.
BTW: The Tol is only for the Color and not for the badColor.
Procedure FindColorsToleranceBut(Var Points: TPointArray; Color, x1, y1, x2, y2, Tol, badColor: LongInt);
Var
Width, Height, ClientBMP, I, TempH, C: LongInt;
Points2: TPointArray;
Begin
TempH := GetClientWindowHandle;
GetClientDimensions(Width, Height);
ClientBMP := BitmapFromString(Width, Height, '');
CopyClientToBitmap(ClientBMP, 0, 0, Width, Height);
SetTargetBitmap(ClientBMP);
FindColorsTolerance(Points2, Color, x1, y1, x2, y2, Tol);
SetArrayLength(Points, GetArrayLength(Points2));
For I := 0 To GetArrayLength(Points2) - 1 Do
Begin
If FastGetPixel(ClientBMP, Points2[I].X, Points2[I].Y) <> badColor Then
Begin
Points[C] := Points2[I];
C := C + 1;
End;
End;
SetArrayLength(Points, C + 1);
FreeBitmap(ClientBMP);
SetClientWindowHandle(TempH);
End;
And yes, FastGetPixel is faster than getcolor.
EDIT: I didn't use Tol; now I do.