Skip to content

Commit

Permalink
Minor tweak.
Browse files Browse the repository at this point in the history
  • Loading branch information
martijnlaan committed Jan 4, 2025
1 parent f46ea42 commit 40c2504
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions Projects/Src/Setup.WizardForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -742,17 +742,20 @@ constructor TWizardForm.Create(AOwner: TComponent);
var
TargetArea, Difference, SmallestDifference, I: Integer;
begin
{ Find the image with the smallest area difference compared to the target area. }
TargetArea := TargetWidth*TargetHeight;
SmallestDifference := -1;
Result := nil;
for I := 0 to WizardImages.Count-1 do begin
Difference := Abs(TargetArea-TBitmap(WizardImages[I]).Width*TBitmap(WizardImages[I]).Height);
if (SmallestDifference = -1) or (Difference < SmallestDifference) then begin
Result := WizardImages[I];
SmallestDifference := Difference;
if WizardImages.Count <> 1 then begin
{ Find the image with the smallest area difference compared to the target area. }
TargetArea := TargetWidth*TargetHeight;
SmallestDifference := -1;
Result := nil;
for I := 0 to WizardImages.Count-1 do begin
Difference := Abs(TargetArea-TBitmap(WizardImages[I]).Width*TBitmap(WizardImages[I]).Height);
if (SmallestDifference = -1) or (Difference < SmallestDifference) then begin
Result := WizardImages[I];
SmallestDifference := Difference;
end;
end;
end;
end else
Result := WizardImages[0];
end;

var
Expand Down

0 comments on commit 40c2504

Please sign in to comment.