Skip to content

Commit

Permalink
Fix TImage.ExternalData typo
Browse files Browse the repository at this point in the history
  • Loading branch information
ollydev committed Oct 23, 2024
1 parent 146e6a3 commit 0a21e5e
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Source/script/imports/simba.import_image.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1882,8 +1882,8 @@ procedure ImportSimbaImage(Compiler: TSimbaScript_Compiler);
addGlobalFunc('function TImage.InImage(X, Y: Integer): Boolean', @_LapeImage_InImage);

addGlobalFunc('procedure TImage.SetSize(NewWidth, NewHeight: Integer);', @_LapeImage_SetSize);
addGlobalFunc('procedure TImage.SetExternaData(Data: PColorBGRA; DataWidth, DataHeight: Integer);', @_LapeImage_SetExternalData);
addGlobalFunc('procedure TImage.ResetExternaData(NewWidth, NewHeight: Integer);', @_LapeImage_ResetExternalData);
addGlobalFunc('procedure TImage.SetExternalData(Data: PColorBGRA; DataWidth, DataHeight: Integer);', @_LapeImage_SetExternalData);
addGlobalFunc('procedure TImage.ResetExternalData(NewWidth, NewHeight: Integer);', @_LapeImage_ResetExternalData);

addGlobalFunc('procedure TImage.Fill(Color: TColor);', @_LapeImage_Fill);
addGlobalFunc('procedure TImage.FillWithAlpha(Value: Byte);', @_LapeImage_FillWithAlpha);
Expand Down
6 changes: 6 additions & 0 deletions Source/simba.image.pas
Original file line number Diff line number Diff line change
Expand Up @@ -1962,6 +1962,9 @@ procedure TSimbaImage.DrawData(TheData: PColorBGRA; DataW, DataH: Integer; P: TP
for LoopY := 0 to H do
for LoopX := 0 to W do
begin
if (TheData[LoopY * DataW + LoopX].A = 0) then
Continue;

DestX := LoopX + P.X;
DestY := LoopY + P.Y;
if (DestX >= 0) and (DestY >= 0) and (DestX < FWidth) and (DestY < FHeight) then
Expand All @@ -1986,6 +1989,9 @@ procedure TSimbaImage.DrawDataAlpha(TheData: PColorBGRA; DataW, DataH: Integer;
for LoopY := 0 to H do
for LoopX := 0 to W do
begin
if (TheData[LoopY * DataW + LoopX].A = 0) then
Continue;

DestX := LoopX + P.X;
DestY := LoopY + P.Y;
if (DestX >= 0) and (DestY >= 0) and (DestX < FWidth) and (DestY < FHeight) then
Expand Down
4 changes: 2 additions & 2 deletions Tests/image_externaldata.simba
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ begin
FillMem(testData^, 50*50*SizeOf(TColorBGRA), 255);

img := TImage.Create(100,100);
img.SetExternaData(testData, 50, 50);
img.SetExternalData(testData, 50, 50);

Assert(img.Pixel[10,10] = Colors.WHITE);
img.Pixel[10,10] := Colors.RED;
Assert(img.Pixel[10,10] = Colors.RED);
Assert(testData[10*50+10]^ = [0,0,255,255]);

// test reseting works
img.ResetExternaData(100,100);
img.ResetExternalData(100,100);
img.SetSize(200,200);
Assert(img.Pixel[10,10] = Colors.BLACK);

Expand Down

0 comments on commit 0a21e5e

Please sign in to comment.