TPAInversusBMP & InversusTPA by n3ss3s
Okay, what it does is that lets say that you have
***-**
**--***
******
and now the "-" are the points of your TPA, this function makes the "*"'s the TPA.
Also works as gap finder :)
Uses a bitmap, 0 - 15 ms.
Bitmap and TPA ofc :)
SCAR Code:
Procedure TPAInversusBMP(Var TPA: TPointArray; x1, y1, x2, y2: Integer);
Var
Bmp, I, L, H: Integer;
nTPA: TPointArray;
Begin
H := GetClientWindowHandle;
Bmp := BitmapFromString(x2, y2, '');
L := High(TPA);
For I := 0 To L Do
SetPixel(bmp, TPA[i].x, TPA[i].y, 255);
SetTargetDC(GetBitmapDC(Bmp));
FindColorsTolerance(nTPA, 0, x1, y1, x2, y2, 0);
SetArrayLength(TPA, GetArrayLength(nTPA));
TPA := nTPA;
SetTargetDC(H);
End;
EDIT: NOW ALSO A NON BMP VERS :)
SCAR Code:
Function InversusTPA(TPA: TPointArray; x1, y1, x2, y2: Integer): TPointArray;
Var
B: Array of Array of Boolean;
L, I, Z: Integer;
Begin
SetArrayLength(Result, Max(x1, x2) * Max(y1, y2));
SetArrayLength(B, x2);
For I := 0 To X2 - 1 Do
SetArrayLength(B[i], y2);
L := High(TPA);
For I := 0 To L Do
B[TPA[i].x][TPA[i].y] := True;
L := High(B);
For W := x1 to x2 Do
For H := y1 To y2 Do
If Not B[W][H] Then
Begin
Result[z] := Point(W, H);
Z := Z + 1;
End;
SetArrayLength(Result, Z);
End;