1
0
mirror of https://github.com/moparisthebest/Simba synced 2024-11-25 02:32:19 -05:00

I thought I would contribute..

Just some small optimizations, is Ray's CTS2 comparison being fully implemented? If so, there are several procedures in finder.pas that need to be updated.
Also, the FindColorsArea, should it be done like the other finders?

I think several functions are not yet passed to PS, FindColors?

Unless the function list is not complete in its actually list.

Anyways, merry christmas to those who celebrate, and happy holidays to everyone else :)


git-svn-id: http://www.villavu.com/repositories/merlijn/mufasa@336 3f818213-9676-44b0-a9b4-5e4c4e03d09d
This commit is contained in:
Nava2 2009-12-25 14:08:27 +00:00
parent eb1f32e7b1
commit a176b953e1
4 changed files with 162 additions and 162 deletions

View File

@ -10,7 +10,7 @@
<TargetFileExt Value=""/>
<Title Value="Mufasa Stand Alone"/>
<UseXPManifest Value="True"/>
<ActiveEditorIndexAtStart Value="4"/>
<ActiveEditorIndexAtStart Value="1"/>
</General>
<VersionInfo>
<ProjectVersion Value=""/>
@ -139,7 +139,7 @@
<UnitName Value="TestUnit"/>
<CursorPos X="153" Y="986"/>
<TopLine Value="955"/>
<EditorIndex Value="5"/>
<EditorIndex Value="7"/>
<UsageCount Value="202"/>
<Loaded Value="True"/>
</Unit13>
@ -258,8 +258,8 @@
<Filename Value="../../Units/MMLCore/finder.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="finder"/>
<CursorPos X="17" Y="1826"/>
<TopLine Value="1807"/>
<CursorPos X="22" Y="863"/>
<TopLine Value="1464"/>
<UsageCount Value="201"/>
</Unit29>
<Unit30>
@ -360,8 +360,8 @@
<Filename Value="../../Units/MMLCore/bitmaps.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="bitmaps"/>
<CursorPos X="43" Y="326"/>
<TopLine Value="308"/>
<CursorPos X="15" Y="808"/>
<TopLine Value="789"/>
<EditorIndex Value="1"/>
<UsageCount Value="200"/>
<Loaded Value="True"/>
@ -640,9 +640,11 @@
<Filename Value="../../Units/MMLCore/dtm.pas"/>
<IsPartOfProject Value="True"/>
<UnitName Value="dtm"/>
<CursorPos X="36" Y="139"/>
<TopLine Value="133"/>
<CursorPos X="34" Y="465"/>
<TopLine Value="440"/>
<EditorIndex Value="5"/>
<UsageCount Value="200"/>
<Loaded Value="True"/>
</Unit86>
<Unit87>
<Filename Value="../../../cogat/Units/CogatUnits/comppicker.pas"/>
@ -715,8 +717,10 @@
<IsPartOfProject Value="True"/>
<UnitName Value="dtmutil"/>
<CursorPos X="21" Y="216"/>
<TopLine Value="196"/>
<TopLine Value="28"/>
<EditorIndex Value="6"/>
<UsageCount Value="206"/>
<Loaded Value="True"/>
</Unit96>
<Unit97>
<Filename Value="../../../cogat/Units/CogatUnits/compmaths.pas"/>
@ -1115,7 +1119,7 @@
<UnitName Value="framescript"/>
<CursorPos X="45" Y="165"/>
<TopLine Value="137"/>
<EditorIndex Value="7"/>
<EditorIndex Value="8"/>
<UsageCount Value="200"/>
<Loaded Value="True"/>
</Unit151>
@ -1432,7 +1436,7 @@
<CursorPos X="39" Y="310"/>
<TopLine Value="290"/>
<EditorIndex Value="3"/>
<UsageCount Value="179"/>
<UsageCount Value="180"/>
<Loaded Value="True"/>
</Unit198>
<Unit199>
@ -1683,7 +1687,7 @@
<UnitName Value="about"/>
<CursorPos X="44" Y="21"/>
<TopLine Value="4"/>
<UsageCount Value="142"/>
<UsageCount Value="143"/>
</Unit235>
<Unit236>
<Filename Value="../../Units/MMLAddon/PSInc/Wrappers/file.inc"/>
@ -1697,7 +1701,7 @@
<UnitName Value="internets"/>
<CursorPos X="87" Y="3"/>
<TopLine Value="1"/>
<UsageCount Value="136"/>
<UsageCount Value="137"/>
</Unit237>
<Unit238>
<Filename Value="debugimageform.pas"/>
@ -1706,7 +1710,7 @@
<UnitName Value="debugimageform"/>
<CursorPos X="20" Y="1"/>
<TopLine Value="1"/>
<UsageCount Value="123"/>
<UsageCount Value="124"/>
</Unit238>
<Unit239>
<Filename Value="debugimage.pas"/>
@ -1717,7 +1721,7 @@
<CursorPos X="59" Y="23"/>
<TopLine Value="88"/>
<EditorIndex Value="4"/>
<UsageCount Value="122"/>
<UsageCount Value="123"/>
<Loaded Value="True"/>
</Unit239>
<Unit240>
@ -1840,9 +1844,7 @@
<UnitName Value="framefunctionlist"/>
<CursorPos X="56" Y="9"/>
<TopLine Value="54"/>
<EditorIndex Value="6"/>
<UsageCount Value="43"/>
<Loaded Value="True"/>
<UsageCount Value="44"/>
</Unit257>
<Unit258>
<Filename Value="../../../usr/local/share/lazarus/lcl/comctrls.pp"/>
@ -1897,8 +1899,8 @@
<UnitName Value="simpleanalyzer"/>
<CursorPos X="52" Y="104"/>
<TopLine Value="193"/>
<EditorIndex Value="8"/>
<UsageCount Value="30"/>
<EditorIndex Value="9"/>
<UsageCount Value="31"/>
<Loaded Value="True"/>
</Unit265>
<Unit266>
@ -1906,7 +1908,7 @@
<UnitName Value="mPasLex"/>
<CursorPos X="1" Y="1"/>
<TopLine Value="1"/>
<EditorIndex Value="9"/>
<EditorIndex Value="10"/>
<UsageCount Value="15"/>
<Loaded Value="True"/>
</Unit266>
@ -1931,107 +1933,63 @@
<UsageCount Value="11"/>
</Unit269>
</Units>
<JumpHistory Count="25" HistoryIndex="24">
<JumpHistory Count="14" HistoryIndex="13">
<Position1>
<Filename Value="framefunctionlist.pas"/>
<Caret Line="142" Column="1" TopLine="111"/>
</Position1>
<Position2>
<Filename Value="framefunctionlist.pas"/>
<Caret Line="141" Column="28" TopLine="113"/>
</Position2>
<Position3>
<Filename Value="testunit.pas"/>
<Caret Line="969" Column="37" TopLine="960"/>
</Position3>
<Position4>
</Position1>
<Position2>
<Filename Value="testunit.pas"/>
<Caret Line="984" Column="39" TopLine="973"/>
</Position4>
<Position5>
<Filename Value="framefunctionlist.pas"/>
<Caret Line="141" Column="62" TopLine="116"/>
</Position5>
<Position6>
<Filename Value="framefunctionlist.pas"/>
<Caret Line="117" Column="101" TopLine="87"/>
</Position6>
<Position7>
<Filename Value="framefunctionlist.pas"/>
<Caret Line="140" Column="51" TopLine="113"/>
</Position7>
<Position8>
<Filename Value="framefunctionlist.pas"/>
<Caret Line="138" Column="59" TopLine="107"/>
</Position8>
<Position9>
</Position2>
<Position3>
<Filename Value="framescript.pas"/>
<Caret Line="19" Column="46" TopLine="17"/>
</Position9>
<Position10>
</Position3>
<Position4>
<Filename Value="framescript.pas"/>
<Caret Line="33" Column="20" TopLine="17"/>
</Position10>
<Position11>
</Position4>
<Position5>
<Filename Value="framescript.pas"/>
<Caret Line="175" Column="16" TopLine="137"/>
</Position5>
<Position6>
<Filename Value="testunit.pas"/>
<Caret Line="62" Column="15" TopLine="34"/>
</Position6>
<Position7>
<Filename Value="testunit.pas"/>
<Caret Line="100" Column="21" TopLine="72"/>
</Position7>
<Position8>
<Filename Value="testunit.pas"/>
<Caret Line="151" Column="17" TopLine="123"/>
</Position8>
<Position9>
<Filename Value="testunit.pas"/>
<Caret Line="193" Column="25" TopLine="165"/>
</Position9>
<Position10>
<Filename Value="testunit.pas"/>
<Caret Line="969" Column="42" TopLine="960"/>
</Position10>
<Position11>
<Filename Value="testunit.pas"/>
<Caret Line="984" Column="1" TopLine="959"/>
</Position11>
<Position12>
<Filename Value="framefunctionlist.pas"/>
<Caret Line="139" Column="26" TopLine="113"/>
<Filename Value="testunit.pas"/>
<Caret Line="983" Column="87" TopLine="955"/>
</Position12>
<Position13>
<Filename Value="testunit.pas"/>
<Caret Line="62" Column="15" TopLine="34"/>
<Caret Line="984" Column="28" TopLine="955"/>
</Position13>
<Position14>
<Filename Value="testunit.pas"/>
<Caret Line="100" Column="21" TopLine="72"/>
</Position14>
<Position15>
<Filename Value="testunit.pas"/>
<Caret Line="151" Column="17" TopLine="123"/>
</Position15>
<Position16>
<Filename Value="testunit.pas"/>
<Caret Line="193" Column="25" TopLine="165"/>
</Position16>
<Position17>
<Filename Value="testunit.pas"/>
<Caret Line="969" Column="42" TopLine="960"/>
</Position17>
<Position18>
<Filename Value="framefunctionlist.pas"/>
<Caret Line="85" Column="7" TopLine="63"/>
</Position18>
<Position19>
<Filename Value="framefunctionlist.pas"/>
<Caret Line="84" Column="73" TopLine="56"/>
</Position19>
<Position20>
<Filename Value="testunit.pas"/>
<Caret Line="984" Column="1" TopLine="959"/>
</Position20>
<Position21>
<Filename Value="testunit.pas"/>
<Caret Line="983" Column="87" TopLine="955"/>
</Position21>
<Position22>
<Filename Value="testunit.pas"/>
<Caret Line="984" Column="28" TopLine="955"/>
</Position22>
<Position23>
<Filename Value="testunit.pas"/>
<Caret Line="988" Column="72" TopLine="956"/>
</Position23>
<Position24>
<Filename Value="framefunctionlist.pas"/>
<Caret Line="124" Column="64" TopLine="117"/>
</Position24>
<Position25>
<Filename Value="framefunctionlist.pas"/>
<Caret Line="41" Column="23" TopLine="48"/>
</Position25>
</Position14>
</JumpHistory>
</ProjectOptions>
<CompilerOptions>

View File

@ -575,7 +575,9 @@ begin
if OldIndex > TabIndex then
PageControl1.TabIndex := OldIndex - 1
else if OldIndex < TabIndex then
PageControl1.TabIndex := OldIndex;
PageControl1.TabIndex := OldIndex
else
PageControl1.TabIndex:= TabIndex;
end;
if tabs.count <= 1 then
begin;

View File

@ -173,6 +173,7 @@ function TMBitmaps.CreateMirroredBitmap(bitmap: Integer;
var
w,h : integer;
y,x : integer;
f1, f2: Integer;
Source,Dest : PRGB32;
begin
Source := Bmp[Bitmap].FData;
@ -184,15 +185,28 @@ begin
Result := CreateBMP(w,h);
Dest := BmpArray[Result].FData;
case MirrorStyle of
MirrorWidth : for y := (h-1) downto 0 do
for x := (w-1) downto 0 do
Dest[y*w+x] := Source[y*w+w-1-x];
MirrorHeight : for y := (h-1) downto 0 do
Move(Source[y*w],Dest[(h-1 - y) * w],w*SizeOf(TRGB32));
MirrorLine : for y := (h-1) downto 0 do
MirrorWidth :
begin
f1 := w*h;
f2 := f1 + w - 1;
for y := (h-1) downto 0 do
for x := (w-1) downto 0 do
Dest[f1+x] := Source[f2-x];
end;
MirrorHeight :
begin
f1 := h - 1;
for y := f1 downto 0 do // Does SizeOf(TRGB32) Change?
Move(Source[y*w], Dest[(f1 - y) * w], w*SizeOf(TRGB32));
end;
MirrorLine :
begin
f1 := h-1;
f2 := w-1;
for y := f1 downto 0 do
for x := f2 downto 0 do
Dest[x*h+y] := Source[y*w+x];
end;
end;
//Can be optmized, this is just proof of concept
end;
@ -502,7 +516,7 @@ begin
begin;
for i := (w-1) downto 0 do
FData[i] := Rec;
for i := (h-1) downto 1 do
for i := (h-1) downto 1 do // does SizeOf(TRGB32) Change?
Move(FData[0],FData[i*w],w*SizeOf(TRGB32));
end;
end;
@ -535,11 +549,12 @@ end;
procedure TMufasaBitmap.FastReplaceColor(OldColor, NewColor: TColor);
var
OldCol,NewCol : TRGB32;
i : integer;
i, wh : integer;
begin
OldCol := RGBToBGR(OldColor);
NewCol := RGBToBGR(NewColor);
for i := w*h-1 downto 0 do
wh := w*h-1;
for i := wh downto 0 do
if LongWord(FData[i]) = LongWord(OldCol) then
FData[i] := NewCol;
end;
@ -547,7 +562,7 @@ end;
procedure TMufasaBitmap.CopyClientToBitmap(MWindow : TObject;Resize : boolean; xs, ys, xe, ye: Integer);
var
y : integer;
wi,hi : integer;
wi, hi, hh : integer;
PtrRet : TRetData;
begin
if Resize then
@ -562,7 +577,8 @@ begin
writeln('WAT y'); }
PtrRet := TMWindow(MWindow).ReturnData(xs,ys,wi,hi);
for y := 0 to (hi-1) do
hh := hi-1;
for y := 0 to hh do
Move(PtrRet.Ptr[y * (wi + PtrRet.IncPtrWith)], FData[y * self.w],wi * SizeOf(TRGB32));
TMWindow(MWindow).FreeReturnData;
end;
@ -571,7 +587,7 @@ procedure TMufasaBitmap.CopyClientToBitmap(MWindow: TObject; Resize: boolean;
x, y: integer; xs, ys, xe, ye: Integer);
var
yy : integer;
wi,hi : integer;
wi,hi,hh : integer;
PtrRet : TRetData;
begin
if Resize then
@ -580,7 +596,8 @@ begin
hi := Min(ye-ys + 1 + y,Self.h);
PtrRet := TMWindow(MWindow).ReturnData(xs,ys,wi - x,hi - y);
for yy := 0 to (hi-1 - y) do
hh := hi-1-y;
for yy := 0 to hh do
Move(PtrRet.Ptr[yy * (wi - x + PtrRet.IncPtrWith)], FData[(yy + y) * self.w + x],wi * SizeOf(TRGB32));
TMWindow(MWindow).FreeReturnData;
end;
@ -600,7 +617,7 @@ var
CosAngle,SinAngle : extended;
MinX,MinY,MaxX,MaxY : integer;
i : integer;
x,y : integer;
x,y,hm1, wm1, yy, xx : integer;
OldX,OldY : integer;
MiddlePoint : TPoint;
NewCorners : array[1..4] of TPoint; //(xs,ye);(xe,ye);(xe,ys);(xs,ys)
@ -612,9 +629,11 @@ begin
MinY := MaxInt;
MaxX := 0;
MaxY := 0;
NewCorners[1]:= RotatePointEdited(Point(0,h-1),angle,middlepoint.x,middlepoint.y);
NewCorners[2]:= RotatePointEdited(Point(w-1,h-1),angle,middlepoint.x,middlepoint.y);
NewCorners[3]:= RotatePointEdited(Point(w-1,0),angle,middlepoint.x,middlepoint.y);
hm1 := h-1;
wm1 := w-1;
NewCorners[1]:= RotatePointEdited(Point(0,hm1),angle,middlepoint.x,middlepoint.y);
NewCorners[2]:= RotatePointEdited(Point(wm1,hm1),angle,middlepoint.x,middlepoint.y);
NewCorners[3]:= RotatePointEdited(Point(wm1,0),angle,middlepoint.x,middlepoint.y);
NewCorners[4]:= RotatePointEdited(Point(0,0),angle,middlepoint.x,middlepoint.y);
for i := 1 to 4 do
begin;
@ -632,11 +651,15 @@ begin
NewH := MaxY - MinY+1;
Writeln(format('New bounds: %d,%d',[NewW,NewH]));
TargetBitmap.SetSize(NewW,NewH);
for y := NewH - 1 downto 0 do
for x := NewW - 1 downto 0 do
hm1 := NewH-1;
wm1 := NewW-1;
xx := MinX-MiddlePoint.x;
yy := MinY-MiddlePoint.y;
for y := hm1 downto 0 do
for x := wm1 downto 0 do
begin;
Oldx := Round(MiddlePoint.x + CosAngle * (x + MinX-MiddlePoint.x) - SinAngle * (y + MinY - MiddlePoint.y));
Oldy := Round(MiddlePoint.y + SinAngle * (x + MinX-MiddlePoint.x) + CosAngle * (y + MinY-MiddlePoint.y));
Oldx := Round(MiddlePoint.x + CosAngle * (x + xx) - SinAngle * (y + yy));
Oldy := Round(MiddlePoint.y + SinAngle * (x + xx) + CosAngle * (y + yy));
if not ((Oldx <0) or (Oldx >= w) or (Oldy < 0) or (Oldy >= h)) then
TargetBitmap.FData[ y * NewW + x] := Self.FData[OldY * W + OldX];
end;
@ -644,12 +667,13 @@ end;
procedure TMufasaBitmap.Desaturate;
var
I : integer;
I, HH : integer;
He,Se,Le : extended;
Ptr : PRGB32;
begin
Ptr := FData;
for i := (h*w-1) downto 0 do
HH := h*w-1;
for i := HH downto 0 do
begin;
RGBToHSL(Ptr^.R,Ptr^.G,Ptr^.B,He,Se,Le);
HSLtoRGB(He,0.0,Le,Ptr^.R,Ptr^.G,Ptr^.B);
@ -659,14 +683,15 @@ end;
procedure TMufasaBitmap.Desaturate(TargetBitmap: TMufasaBitmap);
var
I : integer;
I,HH : integer;
He,Se,Le : extended;
PtrOld,PtrNew : PRGB32;
begin
TargetBitmap.SetSize(w,h);
PtrOld := Self.FData;
PtrNew := TargetBitmap.FData;
for i := (h*w-1) downto 0 do
HH := w*h-1;
for i := HH downto 0 do
begin;
RGBToHSL(PtrOld^.R,PtrOld^.G,PtrOld^.B,He,Se,Le);
HSLtoRGB(He,0.0,Le,PtrNew^.R,PtrNew^.G,PtrNew^.B);
@ -677,14 +702,15 @@ end;
procedure TMufasaBitmap.GreyScale(TargetBitmap: TMufasaBitmap);
var
I : integer;
I, HH : integer;
Lum : byte;
PtrOld,PtrNew : PRGB32;
begin
TargetBitmap.SetSize(w,h);
PtrOld := Self.FData;
PtrNew := TargetBitmap.FData;
for i := (h*w-1) downto 0 do
HH := h*w-1;
for i := HH downto 0 do
begin;
Lum := Round(PtrOld^.r * 0.3 + PtrOld^.g * 0.59 + PtrOld^.b * 0.11);
PtrNew^.r := Lum;
@ -697,12 +723,13 @@ end;
procedure TMufasaBitmap.GreyScale;
var
I : integer;
I, HH : integer;
Lum : Byte;
Ptr: PRGB32;
begin
Ptr := Self.FData;
for i := (h*w-1) downto 0 do
HH := h*w-1;
for i := HH downto 0 do
begin;
Lum := Round(Ptr^.r * 0.3 + Ptr^.g * 0.59 + Ptr^.b * 0.11);
Ptr^.r := Lum;
@ -725,11 +752,12 @@ begin;
end;
procedure TMufasaBitmap.Brightness(br: integer);
var
I : integer;
I, hh : integer;
Ptr: PRGB32;
begin
Ptr := Self.FData;
for i := (h*w-1) downto 0 do
hh := h*w-1;
for i := hh downto 0 do
begin;
Ptr^.r := BrigthnessAdjust(Ptr^.r,br);
Ptr^.g := BrigthnessAdjust(Ptr^.g,br);
@ -740,13 +768,14 @@ end;
procedure TMufasaBitmap.Brightness(TargetBitmap: TMufasaBitmap; br: integer);
var
I : integer;
I, hh: integer;
PtrOld,PtrNew : PRGB32;
begin
TargetBitmap.SetSize(w,h);
PtrOld := Self.FData;
PtrNew := TargetBitmap.FData;
for i := (h*w-1) downto 0 do
hh := h*w-1;
for i := hh downto 0 do
begin;
PtrNew^.r := BrigthnessAdjust(PtrOld^.r,br);
PtrNew^.g := BrigthnessAdjust(PtrOld^.g,br);
@ -772,11 +801,12 @@ end;
procedure TMufasaBitmap.Contrast(co: Extended);
var
I : integer;
I, hh: integer;
Ptr: PRGB32;
begin
Ptr := Self.FData;
for i := (h*w-1) downto 0 do
hh := h*w-1;
for i := hh downto 0 do
begin;
Ptr^.r := ContrastAdjust(Ptr^.r,co);
Ptr^.g := ContrastAdjust(Ptr^.g,co);
@ -787,13 +817,14 @@ end;
procedure TMufasaBitmap.Contrast(TargetBitmap: TMufasaBitmap; co: Extended);
var
I : integer;
I,hh: integer;
PtrOld,PtrNew : PRGB32;
begin
TargetBitmap.SetSize(w,h);
PtrOld := Self.FData;
PtrNew := TargetBitmap.FData;
for i := (h*w-1) downto 0 do
hh := h*w-1;
for i := hh downto 0 do
begin;
PtrNew^.r := ContrastAdjust(PtrOld^.r,co);
PtrNew^.g := ContrastAdjust(PtrOld^.g,co);
@ -805,9 +836,10 @@ end;
procedure TMufasaBitmap.Invert;
var
i : integer;
i, hh : integer;
begin
for i := (h*w-1) downto 0 do
hh := h*w-1;
for i := hh downto 0 do
begin;
Self.FData[i].r := not Self.FData[i].r;
Self.FData[i].g := not Self.FData[i].g;
@ -817,7 +849,7 @@ end;
procedure TMufasaBitmap.Posterize(TargetBitmap: TMufasaBitmap; Po: integer);
var
I : integer;
I,hh : integer;
PtrOld,PtrNew : PRGB32;
begin
if not InRange(Po,1,255) then
@ -825,7 +857,8 @@ begin
TargetBitmap.SetSize(w,h);
PtrOld := Self.FData;
PtrNew := TargetBitmap.FData;
for i := (h*w-1) downto 0 do
hh := w*h-1;
for i := hh downto 0 do
begin;
PtrNew^.r := min(Round(PtrOld^.r / po) * Po, 255);
PtrNew^.g := min(Round(PtrOld^.g / po) * Po, 255);
@ -837,21 +870,22 @@ end;
procedure TMufasaBitmap.Posterize(Po: integer);
var
I : integer;
I,hh: integer;
Ptr: PRGB32;
{a:integer; }
begin
if not InRange(Po,1,255) then
Raise exception.CreateFmt('Posterize Po(%d) out of range[1,255]',[Po]);
Ptr := Self.FData;
for i := (h*w-1) downto 0 do
hh := w*h-1;
for i := hh downto 0 do
begin;
{ a := round(ptr^.r / po);
a := a * po;
ptr^.r := min(a,255);
a := round(ptr^.g / po);
a := a * po;
ptr^.g := min(a,255);
ptr^.g := min(a,255); // bit redundant math, aye?
a := round(ptr^.b / po);
a := a * po;
ptr^.b := min(a,255); }

View File

@ -180,7 +180,7 @@ end;
//SkipCoords[y][x] = False/True; True means its "transparent" and therefore not needed to be checked.
procedure CalculateBitmapSkipCoords(Bitmap : TMufasaBitmap; out SkipCoords : T2DBoolArray);
var
x,y : integer;
x,y,ww, hh : integer;
R,G,B : byte;
Ptr : PRGB32;
begin;
@ -191,8 +191,10 @@ begin;
ColorToRGB(Bitmap.GetTransparentColor,r,g,b);
Ptr := Bitmap.FData;
SetLength(SkipCoords,Bitmap.Height,Bitmap.Width);
for y := 0 to Bitmap.Height - 1 do
for x := 0 to Bitmap.Width - 1 do
ww := Bitmap.Width - 1;
hh := Bitmap.Height - 1;
for y := 0 to hh do
for x := 0 to ww do
begin;
if (Ptr^.r = r) and (Ptr^.g = g) and (Ptr^.b = b) then
SkipCoords[y][x] := True
@ -204,7 +206,7 @@ end;
//Points left holds the amount of points that are "left" to be checked (Including the point itself.. So for example Pointsleft[0][0] would hold the total amount of pixels that are to be checked.
procedure CalculateBitmapSkipCoordsEx(Bitmap : TMufasaBitmap; out SkipCoords : T2DBoolArray;out TotalPoints : integer; out PointsLeft : T2DIntArray);
var
x,y : integer;
x,y,ww,hh : integer;
R,G,B : byte;
Ptr : PRGB32;
TotalC : integer;
@ -218,8 +220,10 @@ begin;
Ptr := Bitmap.FData;
SetLength(SkipCoords,Bitmap.Height,Bitmap.Width);
SetLength(PointsLeft,Bitmap.Height,Bitmap.Width);
for y := 0 to Bitmap.Height - 1 do
for x := 0 to Bitmap.Width - 1 do
ww := Bitmap.Width - 1;
hh := Bitmap.Height - 1;
for y := 0 to hh do
for x := 0 to ww do
begin;
if (Ptr^.r = r) and (Ptr^.g = g) and (Ptr^.b = b) then
SkipCoords[y][x] := True
@ -231,8 +235,8 @@ begin;
inc(ptr);
end;
TotalPoints:= TotalC;
for y := 0 to Bitmap.Height - 1 do
for x := 0 to Bitmap.Width - 1 do
for y := 0 to hh do
for x := 0 to ww do
begin;
PointsLeft[y][x] := TotalC;
if not SkipCoords[y][x] then
@ -275,11 +279,14 @@ var
H1,S1,L1,H2,S2,L2 : extended;
begin
Result := False;
if Color1 = Color2 then
begin
Result := true;
exit;
end;
ColorToRGB(Color1,R1,G1,B1);
ColorToRGB(Color2,R2,G2,B2);
if Color1 = Color2 then
Result := true
else
case CTS of
0: Result := ((Abs(R1-R2) <= Tolerance) and (Abs(G1-G2) <= Tolerance) and (Abs(B1-B2) <= Tolerance));
1: Result := (Sqrt(sqr(R1-R2) + sqr(G1-G2) + sqr(B1-B2)) <= Tolerance);
@ -413,7 +420,6 @@ begin
begin;
for xx := xs to xe do
begin;
// Colour comparison here. Possibly with tolerance? ;)
if (Ptr^.R = clR) and (Ptr^.G = clG) and (Ptr^.B = clB) then
inc(result);
Inc(Ptr);