Skip to content

Commit

Permalink
FMX demo has logo as exe resource
Browse files Browse the repository at this point in the history
- supports standalone use outside Imaging's Demo folder (no external logo file)
- demo shows reading from resources to TSingleImage
  • Loading branch information
galfar committed Aug 2, 2024
1 parent 298fb39 commit f6ef092
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 7 deletions.
2 changes: 1 addition & 1 deletion Demos/ObjectPascal/FireMonkeyDemo/AboutForm.fmx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ object FormAbout: TFormAbout
Caption = 'About - FireMonkey Demo'
ClientHeight = 394
ClientWidth = 440
Position = Designed
FormFactor.Width = 320
FormFactor.Height = 480
FormFactor.Devices = [Desktop, iPhone, iPad]
Expand Down Expand Up @@ -43,6 +42,7 @@ object FormAbout: TFormAbout
TabOrder = 1
Text = 'OK'
TextSettings.Font.Size = 14.000000000000000000
TextSettings.Trimming = None
OnClick = BtnOkClick
end
object FlowLayout: TFlowLayout
Expand Down
30 changes: 24 additions & 6 deletions Demos/ObjectPascal/FireMonkeyDemo/AboutForm.pas
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ interface
uses
System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,
FMX.Types, FMX.Controls, FMX.Forms, FMX.Dialogs, FMX.Objects, FMX.Ani, FMX.Layouts,
FMX.Filter.Effects, FMX.Effects, FMX.StdCtrls, FMX.Controls.Presentation,
FMX.Filter.Effects, FMX.Effects, FMX.StdCtrls, FMX.Controls.Presentation, FMX.Graphics,

Imaging,
DemoUtils;
Expand Down Expand Up @@ -36,21 +36,39 @@ TFormAbout = class(TForm)

implementation

uses
ImagingClasses,
ImagingFmx;

{$R *.fmx}

procedure LoadFmxBitmapFromResourceWithImaging(const ResName: string; Bitmap: TBitmap);
var
ResourceStream: TResourceStream;
Image: TSingleImage;
begin
// Could read from stream directly to FMX Bitmap but let's also show
// reading from resources to TSingleImage.
ResourceStream := TResourceStream.Create(HInstance, ResName, RT_RCDATA);
Image := TSingleImage.Create;
try
Image.LoadFromStream(ResourceStream);
ImagingFmx.ConvertImageToFmxBitmap(Image, Bitmap);
finally
ResourceStream.Free;
Image.Free;
end;
end;

procedure TFormAbout.EffectAnimationFinish(Sender: TObject);
begin
Effect.Enabled := False;
Close;
end;

procedure TFormAbout.FormCreate(Sender: TObject);
var
LogoPath: string;
begin
LogoPath := GetDataDir + PathDelim + 'Logo.png';
if FileExists(LogoPath) then
ImgLogo.Bitmap.LoadFromFile(LogoPath);
LoadFmxBitmapFromResourceWithImaging('LOGO', ImgLogo.Bitmap);
LabVersion.Text := LabVersion.Text + GetVersionStr;
end;

Expand Down

0 comments on commit f6ef092

Please sign in to comment.