1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-27 11:32:18 -05:00

Merge branch 'simba-next' into mem-clean

Conflicts:
	Units/MMLCore/finder.pas
This commit is contained in:
Merlijn Wajer 2011-08-04 01:36:50 +02:00
commit 6f90687b88
9 changed files with 578 additions and 343 deletions

View File

@ -44,6 +44,9 @@ Source: "C:\Simba\Extensions\paster.sex"; DestDir: "{app}\Extensions"; Flags: ig
Source: "C:\Simba\Extensions\CRov.sex"; DestDir: "{app}\Extensions"; Flags: ignoreversion
Source: "C:\Simba\Extensions\Updater.sei"; DestDir: "{app}\Extensions"; Flags: ignoreversion
Source: "C:\Simba\Includes\mml.simba"; DestDir: "{app}\Includes"; Flags: ignoreversion
Source: "C:\Simba\settings.xml"; DestDir: "{app}\"; Flags: ignoreversion
; XXX Make sure to use a MINIMAL settings.xml XXX
; Source: "C:\Simba\Fonts\*"; DestDir: "{app}\Fonts"; Flags: ignoreversion recursesubdirs createallsubdirs
; Source: "C:\Simba\Tests\PS\*"; DestDir:"{app}\Scripts\Tests"; Flags: ignoreversion
; NOTE: Don't use "Flags: ignoreversion" on any shared system files

View File

@ -62,7 +62,7 @@ uses
settings, updater;
const
SimbaVersion = 970;
SimbaVersion = 971;
interp_PS = 0; //PascalScript
interp_RT = 1; //RUTIS

5
TODO
View File

@ -7,13 +7,16 @@ Simple stuff, not required, may not be possible/useful:
- CTS/finder speedups and changes [ ]
General ideas:
- Table displaying all the different performance gains and
penalties. [ ]
- General ideas:
- everything subprocedure (lots of code)
- jit + comparison function (per cts) generated, call in loop
- comparison function (per cts), not generated, call in loop
- Investigate SIMD probable speedups [ ]
- JIT (Generate comparison functions) [ ]
- Comparison functions for HSL/XYZ/L*a*b should check for
match on each component before calculating the next.

View File

@ -0,0 +1,25 @@
program new;
//http://farm4.static.flickr.com/3067/2612399892_7df428d482.jpg
{Make the above bitmap your target}
var
Bmp : integer;
x,y : integer;
w,h : integer;
t, i: integer;
begin
Bmp := createBitmap(15, 10);
FastDrawClear(bmp, clwhite);
GetClientDimensions(w,h);
setcolortolerancespeed(2);
t:=getsystemtime;
for i := 0 to 10 do
FindBitmapToleranceIn(bmp,x,y,0,0,w-1,h-1,500);
writeln((getsystemtime-t) / 10.0);
if FindBitmapToleranceIn(bmp,x,y,0,0,w-1,h-1,500) then
begin
writeln('found');
MoveMouse(x,y);
end;
end.

View File

@ -1,6 +1,5 @@
program new;
//http://farm4.static.flickr.com/3067/2612399892_7df428d482.jpg
{Make the above bitmap your target}
var
Bmp : integer;
x,y : integer;
@ -19,11 +18,14 @@ begin
setcolortolerancespeed(c);
t:=getsystemtime;
for i := 0 to 100 do
for i := 0 to 10 do
findBitmapToleranceIn(bmp,x,y,0,0,w-1,h-1,10);
writeln((getsystemtime-t) / 100.0);
if findBitmapToleranceIn(bmp,x,y,0,0,w-1,h-1,200) then
writeln((getsystemtime-t) / 10.0);
if findBitmapToleranceIn(bmp,x,y,0,0,w-1,h-1,10) then
begin
writeln('found');
movemouse(x,y);
end;
end;
{if FindBitmapToleranceIn(bmp,x,y,0,0,w-1,h-1,300) then

View File

@ -64,6 +64,7 @@ type
function FastGetPixel(x,y : integer) : TColor;
function FastGetPixels(Points : TPointArray) : TIntegerArray;
function GetAreaColors(xs,ys,xe,ye : integer) : T2DIntArray;
function GetHSLValues(xs, ys, xe, ye: integer): T2DHSLArray;
procedure FastDrawClear(Color : TColor);
procedure FastDrawTransparent(x, y: Integer; TargetBitmap: TMufasaBitmap);
procedure FastReplaceColor(OldColor, NewColor: TColor);
@ -876,6 +877,23 @@ begin
result[x-xs][y-ys] := BGRToRGB(FData[y*w+x]);
end;
function TMufasaBitmap.GetHSLValues(xs, ys, xe, ye: integer): T2DHSLArray;
var
x, y: integer;
R, G, B, C: integer;
begin
ValidatePoint(xs,ys);
ValidatePoint(xe,ye);
setlength(result,ye-ys+1,xe-xs+1);
for y := ys to ye do
for x := xs to xe do
begin { REWRITE THIS }
RGBToHSL(FData[y*w+x].R, FData[y*w+x].G, FData[y*w+x].B,
Result[y-ys][x-xs].H, Result[y-ys][x-xs].S,
Result[y-ys][x-xs].L);
end;
end;
procedure TMufasaBitmap.SetTransparentColor(Col: TColor);
begin
self.FTransparentSet:= True;
@ -1406,7 +1424,7 @@ var
i,minw,minh : integer;
begin
if (AWidth <> w) or (AHeight <> h) then
begin;
begin
if AWidth*AHeight <> 0 then
begin;
NewData := GetMem(AWidth * AHeight * SizeOf(TRGB32));

View File

@ -48,7 +48,8 @@ procedure ColorToXYZ(color: Integer; out X, Y, Z: Extended); inline;
function XYZToColor(X, Y, Z: Extended): TColor; inline;
function HSLToColor(H, S, L: Extended): TColor; inline;
function BGRToRGB(BGR : TRGB32) : TColor;inline;
procedure XYZtoCIELab(X, Y, Z: Extended; out L, a, b: Extended);
procedure CIELabtoXYZ(L, a, b: Extended; out X, Y, Z: Extended);
implementation
@ -336,4 +337,53 @@ begin
Result := RGBToColor(r, g, b);
end;
procedure XYZtoCIELab(X, Y, Z: Extended; out L, a, b: Extended);
begin
X := X / 95.047;
Y := Y / 100.000;
Z := Z / 108.883;
if ( X > 0.008856 ) then
X := Power(X, 1.0/3.0)
else
X := ( 7.787 * X ) + ( 16.0 / 116.0 );
if ( Y > 0.008856 ) then
Y := Power(Y, 1.0/3.0)
else
Y := ( 7.787 * Y ) + ( 16.0 / 116.0 );
if ( Z > 0.008856 ) then
Z := Power(Z, 1.0/3.0)
else
Z := ( 7.787 * Z ) + ( 16.0 / 116.0 );
L := (116.0 * Y ) - 16.0;
a := 500.0 * ( X - Y );
b := 200.0 * ( Y - Z );
end;
procedure CIELabtoXYZ(L, a, b: Extended; out X, Y, Z: Extended);
begin
Y := ( L + 16 ) / 116.0;
X := ( a / 500.0 )+ Y;
Z := Y - ( b / 200.0 );
if ( Power(Y, 3) > 0.008856 ) then
Y := Power(Y, 3)
else
Y := ( Y - (16.0 / 116.0 )) / 7.787;
if ( Power(X, 3) > 0.008856 ) then
X := Power(X, 3)
else
X := ( X - (16.0 / 116.0) ) / 7.787;
if ( Power(Z, 3) > 0.008856 ) then
Z := Power(Z, 3)
else
Z := ( Z - (16.0 / 116.0) ) / 7.787;
X := 95.047 * X;
Y := 100.000 * Y;
Z := 108.883 * Z;
end;
end.

File diff suppressed because it is too large Load Diff

View File

@ -60,6 +60,14 @@ type
TRGB32Array = array of TRGB32;
TPRGB32Array = array of PRGB32; //Array of Pointers
THSL = record
H, S, L: extended;
end;
PHSL = ^THSL;
THSLArray = array of THSL;
T2DHSLArray = array of array of THSL;
TRetData = record
Ptr : PRGB32;
IncPtrWith : integer;