Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function TColorFinder.Find(Buffer: PRGB32; BufferWidth: Integer; SearchWidth, SearchHeight: Integer; Offset: TPoint; MaxToFind: Integer): TPointArray;
- var
- X, Y, RowSize: Integer;
- RowPtr, Ptr: PByte;
- PointBuffer: TSimbaPointBuffer;
- PrevColor: record Hit: Boolean; Color: TColor; end;
- Hit: Boolean;
- label
- Finished;
- begin
- Result := nil;
- if (SearchWidth <= 0) or (SearchHeight <= 0) or (Buffer = nil) or (BufferWidth <= 0) then
- Exit;
- RowSize := BufferWidth * SizeOf(TRGB32);
- RowPtr := PByte(Buffer);
- PrevColor.Hit := Self.FCompareFunc(FColor, PColorBGRA(RowPtr)^, FMultipliers) / FMaxDistance * 100 <= FTolerance;
- PrevColor.Color := PColorBGRA(RowPtr)^;
- Dec(SearchHeight);
- Dec(SearchWidth);
- for Y := 0 to SearchHeight do
- begin
- Ptr := RowPtr;
- for X := 0 to SearchWidth do
- begin
- if (PrevColor.Hit and (PrevColor.Color = PColorBGRA(Ptr)^)) or
- (Self.FCompareFunc(FColor, PColorBGRA(Ptr)^, FMultipliers) / FMaxDistance * 100 <= FTolerance) then
- begin
- PointBuffer.Add(X + Offset.X, Y + Offset.Y);
- if (PointBuffer.Count = MaxToFind) then
- goto Finished;
- end else
- begin
- PrevColor.Hit := False;
- PrevColor.Color := PColorBGRA(Ptr)^;
- end;
- Inc(Ptr, SizeOf(TRGB32));
- end;
- Inc(RowPtr, RowSize);
- end;
- Finished:
- Result := PointBuffer.Trim();
- end;
Advertisement
Comments
-
- Show Box The Best Movie App
- Are you looking for a great movie app? ShowBox is the best one out there! With a massive selection of movies and TV shows, itโs perfect for anyone who loves to watch films. And with new releases being added, youโll never run out of things to watch.
- You need to check out Show Box if youโre a movie lover. Itโs the best movie app, with a vast selection of films and TV shows.
- https://show-boxapk.com/
- https://giphy.com/channel/showboxapk
- https://www.quora.com/profile/Showbox-Apk-3
Add Comment
Please, Sign In to add comment
Advertisement