Skip to content

Commit

Permalink
Added KeepAspectCheckBox to Benchmark
Browse files Browse the repository at this point in the history
Added centering paint of image with Cairo
Added stretched image32 support when KeepAspectRatio is false
  • Loading branch information
carloBarazzetta committed Jul 15, 2021
1 parent 0a291b0 commit 6bd7559
Show file tree
Hide file tree
Showing 13 changed files with 262 additions and 90 deletions.
90 changes: 53 additions & 37 deletions Demo/Benchmark/UBenchmark.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ object frmBenchmark: TfrmBenchmark
Left = 0
Top = 0
Caption = 'Benchmark'
ClientHeight = 545
ClientWidth = 784
ClientHeight = 573
ClientWidth = 819
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Expand All @@ -16,7 +16,7 @@ object frmBenchmark: TfrmBenchmark
TextHeight = 15
object splHorizontal: TSplitter
Left = 0
Top = 421
Top = 449
Width = 784
Height = 4
Cursor = crVSplit
Expand All @@ -26,10 +26,19 @@ object frmBenchmark: TfrmBenchmark
MinSize = 100
ExplicitTop = 422
end
object SVGIconImage: TSVGIconImage
Left = 0
Top = 0
Width = 669
Height = 449
AutoSize = False
ImageList = SVGIconVirtualImageList
Align = alClient
end
object memOutput: TMemo
Left = 0
Top = 425
Width = 784
Top = 453
Width = 819
Height = 120
Align = alBottom
Font.Charset = DEFAULT_CHARSET
Expand All @@ -41,17 +50,8 @@ object frmBenchmark: TfrmBenchmark
ReadOnly = True
ScrollBars = ssVertical
TabOrder = 0
end
object SVGIconImage: TSVGIconImage
Left = 0
Top = 0
Width = 634
Height = 421
AutoSize = False
ParentDoubleBuffered = False
DoubleBuffered = True
ImageList = SVGIconVirtualImageList
Align = alClient
ExplicitTop = 425
ExplicitWidth = 784
end
object pnlButtons: TPanel
Left = 634
Expand All @@ -60,17 +60,17 @@ object frmBenchmark: TfrmBenchmark
Height = 421
Align = alRight
BevelOuter = bvNone
TabOrder = 2
TabOrder = 1
object btnClear: TButton
AlignWithMargins = True
Left = 10
Top = 386
Width = 130
Height = 30
Margins.Left = 10
Margins.Top = 5
Margins.Top = 2
Margins.Right = 10
Margins.Bottom = 5
Margins.Bottom = 2
Align = alBottom
Caption = '&Clear Output'
TabOrder = 0
Expand Down Expand Up @@ -98,24 +98,24 @@ object frmBenchmark: TfrmBenchmark
Width = 130
Height = 30
Margins.Left = 10
Margins.Top = 5
Margins.Top = 2
Margins.Right = 10
Margins.Bottom = 5
Margins.Bottom = 2
Align = alBottom
Caption = '&Benchmark'
TabOrder = 2
OnClick = btnRunBenchmarkClick
end
object chkGrayScale: TCheckBox
AlignWithMargins = True
Left = 10
Top = 256
Left = 13
Top = 300
Width = 130
Height = 20
Margins.Left = 10
Margins.Top = 5
Margins.Top = 2
Margins.Right = 10
Margins.Bottom = 5
Margins.Bottom = 2
Align = alBottom
Caption = '&Grayscale'
Checked = True
Expand All @@ -129,9 +129,9 @@ object frmBenchmark: TfrmBenchmark
Width = 130
Height = 20
Margins.Left = 10
Margins.Top = 5
Margins.Top = 2
Margins.Right = 10
Margins.Bottom = 5
Margins.Bottom = 2
Align = alBottom
Caption = '&Fixed Color'
Checked = True
Expand All @@ -151,15 +151,14 @@ object frmBenchmark: TfrmBenchmark
Left = 10
Top = 8
Width = 32
Height = 17
Height = 15
Margins.Left = 10
Margins.Top = 8
Margins.Top = 10
Margins.Right = 5
Margins.Bottom = 5
Margins.Bottom = 2
Align = alLeft
Caption = '&Loops'
FocusControl = speLoops
ExplicitHeight = 15
end
object speLoops: TSpinEdit
AlignWithMargins = True
Expand All @@ -168,9 +167,9 @@ object frmBenchmark: TfrmBenchmark
Width = 88
Height = 24
Margins.Left = 5
Margins.Top = 5
Margins.Top = 2
Margins.Right = 10
Margins.Bottom = 5
Margins.Bottom = 2
MaxValue = 999
MinValue = 1
TabOrder = 0
Expand All @@ -195,19 +194,36 @@ object frmBenchmark: TfrmBenchmark
object chkDrawVisible: TCheckBox
AlignWithMargins = True
Left = 10
Top = 226
Top = 228
Width = 130
Height = 20
Height = 19
Margins.Left = 10
Margins.Top = 5
Margins.Top = 2
Margins.Right = 10
Margins.Bottom = 5
Margins.Bottom = 2
Align = alBottom
Caption = '&Draw visible'
Checked = True
State = cbChecked
TabOrder = 7
end
object KeepAspectCheckBox: TCheckBox
AlignWithMargins = True
Left = 10
Top = 228
Width = 130
Height = 19
Margins.Left = 10
Margins.Top = 2
Margins.Right = 10
Margins.Bottom = 2
Align = alTop
Caption = '&Keep aspect ratio'
Checked = True
State = cbChecked
TabOrder = 8
OnClick = KeepAspectCheckBoxClick
end
end
object SVGIconImageCollection: TSVGIconImageCollection
SVGIconItems = <>
Expand Down
9 changes: 8 additions & 1 deletion Demo/Benchmark/UBenchmark.pas
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,13 @@ TfrmBenchmark = class(TForm)
grpFactory: TRadioGroup;
chkDrawVisible: TCheckBox;
SVGIconVirtualImageList: TSVGIconVirtualImageList;
KeepAspectCheckBox: TCheckBox;
procedure btnClearClick(Sender: TObject);
procedure btnLoadClick(Sender: TObject);
procedure btnRunBenchmarkClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure grpFactoryClick(Sender: TObject);
procedure KeepAspectCheckBoxClick(Sender: TObject);
private
FSvgSource : string;
FStartTick : Int64;
Expand Down Expand Up @@ -104,7 +106,7 @@ procedure TfrmBenchmark.BenchmarkDraw;
LSize := LSize + LStep;
LRect := TRect.Create(0, 0, Round(LSize), Round(LSize));

SvgIconImageCollection.Draw(ACanvas, LRect, 0, true);
SvgIconImageCollection.Draw(ACanvas, LRect, 0, KeepAspectCheckBox.Checked);
end;
end;

Expand Down Expand Up @@ -251,6 +253,11 @@ procedure TfrmBenchmark.grpFactoryClick(Sender: TObject);
end;
end;

procedure TfrmBenchmark.KeepAspectCheckBoxClick(Sender: TObject);
begin
SVGIconImage.Proportional := KeepAspectCheckBox.Checked;
end;

procedure TfrmBenchmark.LogTicks(var AMessage: string; ATick: Int64);
var
LCurrentTick: Int64;
Expand Down
2 changes: 1 addition & 1 deletion Demo/D10_4/SVGIconImageCollectionIntoControlList.dproj
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
<UWP_DelphiLogo44>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_44.png</UWP_DelphiLogo44>
<UWP_DelphiLogo150>$(BDS)\bin\Artwork\Windows\UWP\delphi_UwpDefault_150.png</UWP_DelphiLogo150>
<SanitizedProjectName>SVGIconImageCollectionIntoControlList</SanitizedProjectName>
<DCC_UnitSearchPath>..\..\Source;..\..\Svg;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
<DCC_UnitSearchPath>..\..\Source;..\..\Svg;..\..\Image32\Source;..\..\Image32\Source\Image32_SVG;$(DCC_UnitSearchPath)</DCC_UnitSearchPath>
<VerInfo_Locale>1040</VerInfo_Locale>
<VerInfo_Keys>CompanyName=;FileDescription=$(MSBuildProjectName);FileVersion=1.0.0.0;InternalName=;LegalCopyright=;LegalTrademarks=;OriginalFilename=;ProgramID=com.embarcadero.$(MSBuildProjectName);ProductName=$(MSBuildProjectName);ProductVersion=1.0.0.0;Comments=</VerInfo_Keys>
</PropertyGroup>
Expand Down
Loading

0 comments on commit 6bd7559

Please sign in to comment.