J J
2012-07-04 18:59:05
Currently working on speeding it up as the full mainscreen takes around 10 seconds or so. Let me know if you have any idea's on how to speed it up. The code:
Fill in your desired coordinates where it should detect the edges and the threshold. Will show a debug of where it searches for and will draw the result in SMART.
Some results:


Should be useful, but it isn't that fast right now for loads of pixels. Not sure if I can make it faster in Simba, I would probably need to write a plugin to make it faster? :P Enjoy.
Fill in your desired coordinates where it should detect the edges and the threshold. Will show a debug of where it searches for and will draw the result in SMART.
program Edge;
{$DEFINE SMART}
{$i srl/srl.simba}
{$i srl/srl/misc/paintsmart.simba}
{$loadlib irokiplugin}
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := '';
Pass := '';
Pin := '';
Active := True;
end;
end;
procedure SetupLogin;
begin
ClearDebug;
Smart_Server := 10;
Smart_Members := False;
Smart_Signed := True;
Smart_SuperDetail := False;
SetupSRL;
DeclarePlayers;
LoginPlayer;
end;
procedure Edges(X1, Y1, X2, Y2, Threshold: Integer);
var
Width, Height, ClientBMP, i, a, b: Integer;
Colors: TIntegerArray;
ColorCoords, Edge: TPointArray;
Box: TBox;
begin
// Making a bmp and showing in debug box
Box := IntToBox(X1, Y1, X2, Y2);
Width := Box.X2-Box.X1;
Height := Box.Y2-Box.Y1;
DisplayDebugImgWindow(Width, Height);
ClientBMP := BitmapFromClient(Box.X1, Box.Y1, Box.X2, Box.Y2);
DrawBitmapDebugImg(ClientBMP);
FreeBitmap(ClientBMP);
// Grabbing all the colors and asigning a TPoint to them.
Colors := GetColorsBox(Box.X1, Box.Y1, Box.X2, Box.Y2, False);
SetLength(ColorCoords, Length(Colors));
for i:=0 to high(Colors) do
begin
if a > (Box.Y2-Box.Y1) then
begin
a := 0;
Inc(b);
end;
ColorCoords[i] := Point(Box.X1+b, Box.Y1+a);
Inc(a);
end;
// Finding the edges
for i:=0 to high(Colors)-1 do
begin
// Checking R value
if Abs((Colors[i] and $ff) - (Colors[i+1] and $ff)) > Threshold then
begin
SetLength(Edge, Length(Edge)+1);
Edge[Length(Edge)-1] := ColorCoords[i];
Continue;
end;
// Checking G value
if Abs((Colors[i] shr 8 and $ff) - (Colors[i+1] shr 8 and $ff)) > Threshold then
begin
SetLength(Edge, Length(Edge)+1);
Edge[Length(Edge)-1] := ColorCoords[i];
Continue;
end;
//Checking B value
if Abs((Colors[i] shr 16 and $ff) - (Colors[i+1] shr 16 and $ff)) > Threshold then
begin
SetLength(Edge, Length(Edge)+1);
Edge[Length(Edge)-1] := ColorCoords[i];
Continue;
end;
end;
// Drawing the edges
SMART_DrawDotsEx(True, TPAFromBox(Box), RGBtoColor(1, 1, 1));
SMART_DrawDotsEx(False, Edge, RGBToColor(255, 255, 255));
end;
begin
SetUpLogin;
Edges(100, 15, 420, 310, 4);
end.Some results:


Should be useful, but it isn't that fast right now for loads of pixels. Not sure if I can make it faster in Simba, I would probably need to write a plugin to make it faster? :P Enjoy.
