SRL Archive - General

FindColorsTolerance


Jason2gs

2007-06-10 13:52:10

Is there a command that works like FindColorsTolerance, but instead of finding a color, it finds all but one color?

Oh, and how much faster is FastGetPixel than GetColor?

Would it be worth it to copy the canvas of the screen, then use FastGetPixel to pick a color, rather than using the normal GetColor?

IEatJ00erBaybees

2007-06-10 13:53:40

Off-Topic - Gratz on 1500 posts :p, pic pl0x? 1 Face and 1/2 of a face?

Jason2gs

2007-06-10 14:11:20

Heh, thanks :)

A picture of what, now?

Wizzup?

2007-06-10 15:25:28

From: Jason2gs
Is there a command that works like FindColorsTolerance, but instead of finding a color, it finds all but one color?

Oh, and how much faster is FastGetPixel than GetColor?

Would it be worth it to copy the canvas of the screen, then use FastGetPixel to pick a color, rather than using the normal GetColor?


- a:= GetClientWindowHandle;
- Copy Client To BMP
- Set Target Bitmap
- Preform FindColorsTolerance
- Add another Array
- For every coord in the findcolorstolerance preform a fastgetpixel.
For every color that isn't the color you don't want to have, add it to "another Array".
- SetClientWindowHandle(a);
- There you go, your points are in the "another array".
I'll make one when I get time.

Sumilion

2007-06-10 15:35:37

From: Wizzup?
- a:= GetClientWindowHandle;
- Copy Client To BMP
- Set Target Bitmap
- Preform FindColorsTolerance
- Add another Array
- For every coord in the findcolorstolerance preform a fastgetpixel.
For every color that isn't the color you don't want to have, add it to "another Array".
- SetClientWindowHandle(a);
- There you go, your points are in the "another array".
I'll make one when I get time.


Or this :

- GetColors on the area
- Loop through them
- If the color is the one you dont want, then dont add it to a diff array.

Jason2gs

2007-06-10 15:53:34

Thanks Wizzup ;)

For every color that isn't the color you don't want to have, add it to "another Array".


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.

Wizzup?

2007-06-10 16:06:08

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.

Jason2gs

2007-06-10 16:53:07

Oooh, thanks :)

I had to modify it a little to fit what I needed it for (I didn't really need it that flexible. I was just going to use it once.), and I think I modified it pretty well to get only the main parts, but it still doesn't seem to work like it should.

Is it alright if I PM you the script? Me and a friend are currently working on it, and I'm not sure if it should be public :)

BTW: It's not a script for RS, the FastGetPixel vs GetColor was just an idea I had for an RS script.

Wizzup?

2007-06-11 02:42:02

Sure, PM. :)