Skip to content

Commit

Permalink
Rename TMufasaBitmap to TSimbaImage
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Jul 25, 2023
1 parent f98270a commit 1e8bcdc
Show file tree
Hide file tree
Showing 28 changed files with 1,117 additions and 1,114 deletions.
46 changes: 21 additions & 25 deletions Source/Simba.lpi
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@
<PackageName Value="LCL"/>
</Item4>
</RequiredPackages>
<Units Count="134">
<Units Count="133">
<Unit0>
<Filename Value="Simba.lpr"/>
<IsPartOfProject Value="True"/>
Expand Down Expand Up @@ -855,92 +855,88 @@
<IsPartOfProject Value="True"/>
</Unit112>
<Unit113>
<Filename Value="simba.bitmap_finders.pas"/>
<Filename Value="simba.ide_events.pas"/>
<IsPartOfProject Value="True"/>
</Unit113>
<Unit114>
<Filename Value="simba.ide_events.pas"/>
<Filename Value="simba.threading.pas"/>
<IsPartOfProject Value="True"/>
</Unit114>
<Unit115>
<Filename Value="simba.threading.pas"/>
<Filename Value="components/simba.component_statusbar.pas"/>
<IsPartOfProject Value="True"/>
</Unit115>
<Unit116>
<Filename Value="components/simba.component_statusbar.pas"/>
<Filename Value="simba.ide_mainstatusbar.pas"/>
<IsPartOfProject Value="True"/>
</Unit116>
<Unit117>
<Filename Value="simba.ide_mainstatusbar.pas"/>
<Filename Value="editor/simba.editor_popupmenu.pas"/>
<IsPartOfProject Value="True"/>
</Unit117>
<Unit118>
<Filename Value="editor/simba.editor_popupmenu.pas"/>
<Filename Value="components/simba.component_treeview.pas"/>
<IsPartOfProject Value="True"/>
</Unit118>
<Unit119>
<Filename Value="components/simba.component_treeview.pas"/>
<Filename Value="components/simba.component_edit.pas"/>
<IsPartOfProject Value="True"/>
</Unit119>
<Unit120>
<Filename Value="components/simba.component_edit.pas"/>
<Filename Value="components/simba.component_synedit.pas"/>
<IsPartOfProject Value="True"/>
</Unit120>
<Unit121>
<Filename Value="components/simba.component_synedit.pas"/>
<Filename Value="simba.theme.pas"/>
<IsPartOfProject Value="True"/>
</Unit121>
<Unit122>
<Filename Value="simba.theme.pas"/>
<Filename Value="components/simba.component_menubar.pas"/>
<IsPartOfProject Value="True"/>
</Unit122>
<Unit123>
<Filename Value="components/simba.component_menubar.pas"/>
<Filename Value="components/simba.component_button.pas"/>
<IsPartOfProject Value="True"/>
</Unit123>
<Unit124>
<Filename Value="components/simba.component_button.pas"/>
<Filename Value="components/simba.component_scrollbar.pas"/>
<IsPartOfProject Value="True"/>
</Unit124>
<Unit125>
<Filename Value="components/simba.component_scrollbar.pas"/>
<Filename Value="simba.singlematrix.pas"/>
<IsPartOfProject Value="True"/>
</Unit125>
<Unit126>
<Filename Value="simba.singlematrix.pas"/>
<Filename Value="simba.integermatrix.pas"/>
<IsPartOfProject Value="True"/>
</Unit126>
<Unit127>
<Filename Value="simba.integermatrix.pas"/>
<Filename Value="../Third-Party/fpsha512_simba.pas"/>
<IsPartOfProject Value="True"/>
</Unit127>
<Unit128>
<Filename Value="../Third-Party/fpsha512_simba.pas"/>
<Filename Value="../Third-Party/fpsha256_simba.pas"/>
<IsPartOfProject Value="True"/>
</Unit128>
<Unit129>
<Filename Value="../Third-Party/fpsha256_simba.pas"/>
<Filename Value="../Third-Party/fphashutils_simba.pas"/>
<IsPartOfProject Value="True"/>
</Unit129>
<Unit130>
<Filename Value="../Third-Party/fphashutils_simba.pas"/>
<Filename Value="package/simba.package_menubuilder.pas"/>
<IsPartOfProject Value="True"/>
</Unit130>
<Unit131>
<Filename Value="package/simba.package_menubuilder.pas"/>
<Filename Value="components/simba.component_buttonpanel.pas"/>
<IsPartOfProject Value="True"/>
</Unit131>
<Unit132>
<Filename Value="components/simba.component_buttonpanel.pas"/>
<IsPartOfProject Value="True"/>
</Unit132>
<Unit133>
<Filename Value="forms/simba.backupsform.pas"/>
<IsPartOfProject Value="True"/>
<ComponentName Value="SimbaBackupsForm"/>
<HasResources Value="True"/>
<ResourceBaseClass Value="Form"/>
</Unit133>
</Unit132>
</Units>
</ProjectOptions>
<CompilerOptions>
Expand Down
10 changes: 5 additions & 5 deletions Source/finders/simba.finder_bitmap.pas
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ interface
simba.mufasatypes, simba.colormath, simba.colormath_distance, simba.target, simba.bitmap,
simba.colormath_distance_unrolled, simba.simplelock;

function FindBitmapOnTarget(Target: TSimbaTarget; Bitmap: TMufasaBitmap; Bounds: TBox;
function FindBitmapOnTarget(Target: TSimbaTarget; Bitmap: TSimbaImage; Bounds: TBox;
Formula: EColorSpace; Tolerance: Single; Multipliers: TChannelMultipliers; MaxToFind: Integer = -1): TPointArray;

function FindBitmapOnBuffer(var Limit: TSimpleThreadsafeLimit;
Bitmap: TMufasaBitmap;
Bitmap: TSimbaImage;
ColorSpace: EColorSpace; Tolerance: Single; Multipliers: TChannelMultipliers;
Buffer: PColorBGRA; BufferWidth: Integer;
SearchWidth, SearchHeight: Integer): TPointArray;
Expand Down Expand Up @@ -62,7 +62,7 @@ function CalculateSlices(SearchWidth, SearchHeight: Integer): Integer;

// Pre calculate color space
// and "transparent" (aka ignore) colors.
function ConvertBitmapColors(Bitmap: TMufasaBitmap; ColorSpace: EColorSpace): PByte;
function ConvertBitmapColors(Bitmap: TSimbaImage; ColorSpace: EColorSpace): PByte;
var
I: Integer;
Source: PColorBGRA;
Expand Down Expand Up @@ -96,7 +96,7 @@ function ConvertBitmapColors(Bitmap: TMufasaBitmap; ColorSpace: EColorSpace): PB
end;
end;

function FindBitmapOnTarget(Target: TSimbaTarget; Bitmap: TMufasaBitmap; Bounds: TBox; Formula: EColorSpace; Tolerance: Single; Multipliers: TChannelMultipliers; MaxToFind: Integer): TPointArray;
function FindBitmapOnTarget(Target: TSimbaTarget; Bitmap: TSimbaImage; Bounds: TBox; Formula: EColorSpace; Tolerance: Single; Multipliers: TChannelMultipliers; MaxToFind: Integer): TPointArray;
var
Buffer: PColorBGRA;
BufferWidth: Integer;
Expand Down Expand Up @@ -146,7 +146,7 @@ function FindBitmapOnTarget(Target: TSimbaTarget; Bitmap: TMufasaBitmap; Bounds:
end;
end;

function FindBitmapOnBuffer(var Limit: TSimpleThreadsafeLimit; Bitmap: TMufasaBitmap; ColorSpace: EColorSpace; Tolerance: Single; Multipliers: TChannelMultipliers; Buffer: PColorBGRA; BufferWidth: Integer; SearchWidth, SearchHeight: Integer): TPointArray;
function FindBitmapOnBuffer(var Limit: TSimpleThreadsafeLimit; Bitmap: TSimbaImage; ColorSpace: EColorSpace; Tolerance: Single; Multipliers: TChannelMultipliers; Buffer: PColorBGRA; BufferWidth: Integer; SearchWidth, SearchHeight: Integer): TPointArray;
var
BitmapColors: PByte;

Expand Down
4 changes: 2 additions & 2 deletions Source/forms/simba.aca.pas
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,9 @@ procedure TSimbaACAForm.PanelRightResize(Sender: TObject);

procedure TSimbaACAForm.LoadHSLCircle(Radius: Integer);
var
Bitmap: TMufasaBitmap;
Bitmap: TSimbaImage;
begin
Bitmap := TMufasaBitmap.Create(Radius*2, Radius*2);
Bitmap := TSimbaImage.Create(Radius*2, Radius*2);
Bitmap.DrawHSLCircle(Bitmap.Center, Radius);

FImageBox.SetBackground(Bitmap);
Expand Down
12 changes: 6 additions & 6 deletions Source/forms/simba.bitmaptostringform.pas
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ TSimbaBitmapConversionForm = class(TForm)
procedure OpenButtonClick(Sender: TObject);
procedure ToStringButtonClick(Sender: TObject);
public
dispPic: TMufasaBitmap;
dispPic: TSimbaImage;
end;

var
Expand All @@ -45,14 +45,14 @@ implementation

procedure TSimbaBitmapConversionForm.OpenButtonClick(Sender: TObject);
var
x : TMufasaBitmap;
x : TSimbaImage;
begin
if OpenPictureDialog.Execute then
begin
try
ImagePreview.Picture.LoadFromFile(OpenPictureDialog.FileName);
GroupBox.Caption:= Format(BmpSizeTxt,[ImagePreview.Picture.Width,ImagePreview.Picture.Height]);
x := TMufasaBitmap.Create;
x := TSimbaImage.Create;
x.LoadFromFile(OpenPictureDialog.FileName);
if dispPic <> nil then
dispPic.Free;
Expand All @@ -75,7 +75,7 @@ procedure TSimbaBitmapConversionForm.ClipboardButtonClick(Sender: TObject);
if Assigned(dispPic) then
FreeAndNil(dispPic);

dispPic := TMufasaBitmap.Create();
dispPic := TSimbaImage.Create();
dispPic.LoadFromTBitmap(ImagePreview.Picture.Bitmap);
except
on E: Exception do
Expand Down Expand Up @@ -104,7 +104,7 @@ procedure TSimbaBitmapConversionForm.ToStringButtonClick(Sender: TObject);
if PadOutput.Checked then
begin
Builder := TStringList.Create();
Builder.Add(' BMP := TMufasaBitmap.CreateFromString(%d, %d,', [dispPic.Width, dispPic.Height]);
Builder.Add(' BMP := TSimbaImage.CreateFromString(%d, %d,', [dispPic.Width, dispPic.Height]);

Offset := 1;
while (Offset < Length(Str) - PAD_WIDTH) do
Expand All @@ -115,7 +115,7 @@ procedure TSimbaBitmapConversionForm.ToStringButtonClick(Sender: TObject);
end;
Builder.Add(' ' + #39 + Copy(Str, Offset) + #39 + ');');
end else
Builder.Add(Format(' BMP := TMufasaBitmap.CreateFromString(%d, %d, %s);', [dispPic.Width, dispPic.Height, QuotedStr(Str)]));
Builder.Add(Format(' BMP := TSimbaImage.CreateFromString(%d, %d, %s);', [dispPic.Width, dispPic.Height, QuotedStr(Str)]));

SimbaDebugLn([EDebugLn.FOCUS], Builder.Text);

Expand Down
43 changes: 29 additions & 14 deletions Source/imagebox/simba.imagebox.pas
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ TSimbaImageBox = class(TWinControl)

procedure SetBackground(Data: PColorBGRA; AWidth, AHeight: Integer); overload;
procedure SetBackground(FileName: String); overload;
procedure SetBackground(Bitmap: TMufasaBitmap); overload;
procedure SetBackground(Bitmap: TSimbaImage); overload;
procedure SetBackground(Window: TWindowHandle); overload;

procedure Paint;
Expand All @@ -113,7 +113,7 @@ implementation

uses
Math, GraphType, LCLIntf,
simba.finder, simba.bitmap_utils, simba.windowhandle, simba.bitmap_finders;
simba.finder, simba.bitmap_utils, simba.windowhandle;

procedure TSimbaImageBox_ScrollBox.GetPreferredSize(var PreferredWidth, PreferredHeight: integer; Raw: boolean; WithThemeSpace: boolean);
begin
Expand Down Expand Up @@ -616,32 +616,47 @@ function TSimbaImageBox.IsVisible(X, Y: Integer): Boolean;
end;

function TSimbaImageBox.FindDTM(DTM: TDTM): TPointArray;
var
Finder: TSimbaFinder;
Img: TSimbaImage;
begin
with FBackground.ToMufasaBitmap() do
Img := FBackground.ToMufasaBitmap();
try
Result := Finder.FindDTMEx(DTM, -1, NullBox);
Finder.Target.SetImage(Img);

Result := Finder.FindDTMEx(DTM, -1, Box(-1, -1, -1, -1));
finally
Free();
Img.Free();
end;
end;

function TSimbaImageBox.FindColor(AColor: TColor; Tolerance: Single; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers): TPointArray;
var
Finder: TSimbaFinder;
Img: TSimbaImage;
begin
with FBackground.ToMufasaBitmap() do
Img := FBackground.ToMufasaBitmap();
try
Result := Finder.FindColor(AColor, Tolerance, ColorSpace, Multipliers, NullBox);
Finder.Target.SetImage(Img);

Result := Finder.FindColor(AColor, Tolerance, ColorSpace, Multipliers, Box(-1, -1, -1, -1));
finally
Free();
Img.Free();
end;
end;

function TSimbaImageBox.MatchColor(AColor: TColor; ColorSpace: EColorSpace; Multipliers: TChannelMultipliers): TSingleMatrix;
var
Finder: TSimbaFinder;
Img: TSimbaImage;
begin
with FBackground.ToMufasaBitmap() do
Img := FBackground.ToMufasaBitmap();
try
Result := Finder.MatchColor(AColor, ColorSpace, Multipliers, NullBox);
Finder.Target.SetImage(Img);

Result := Finder.MatchColor(AColor, ColorSpace, Multipliers, Box(-1, -1, -1, -1));
finally
Free();
Img.Free();
end;
end;

Expand All @@ -655,18 +670,18 @@ procedure TSimbaImageBox.SetBackground(FileName: String);
FBackground.LoadFromFile(FileName);
end;

procedure TSimbaImageBox.SetBackground(Bitmap: TMufasaBitmap);
procedure TSimbaImageBox.SetBackground(Bitmap: TSimbaImage);
begin
FBackground.FromData(Bitmap.Data, Bitmap.Width, Bitmap.Height);
end;

procedure TSimbaImageBox.SetBackground(Window: TWindowHandle);
var
Image: TMufasaBitmap;
Image: TSimbaImage;
begin
if Window.IsValid() then
begin
Image := TMufasaBitmap.CreateFromWindow(Window);
Image := TSimbaImage.CreateFromWindow(Window);
try
SetBackground(Image);
finally
Expand Down
4 changes: 2 additions & 2 deletions Source/imagebox/simba.imagebox_zoom.pas
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ TSimbaImageBoxZoom = class(TCustomControl)

procedure Move(Image: TImage; X, Y: Integer); overload;
procedure Move(Image: TBitmap; X, Y: Integer); overload;
procedure Move(Image: TMufasaBitmap; X, Y: Integer); overload;
procedure Move(Image: TSimbaImage; X, Y: Integer); overload;
end;

implementation
Expand Down Expand Up @@ -166,7 +166,7 @@ procedure TSimbaImageBoxZoom.Move(Image: TBitmap; X, Y: Integer);
Invalidate();
end;

procedure TSimbaImageBoxZoom.Move(Image: TMufasaBitmap; X, Y: Integer);
procedure TSimbaImageBoxZoom.Move(Image: TSimbaImage; X, Y: Integer);
var
LoopX, LoopY: Integer;
begin
Expand Down
Loading

0 comments on commit 1e8bcdc

Please sign in to comment.