diff --git a/Examples/General/PNG Image32/MainUnit.dfm b/Examples/General/PNG Image32/MainUnit.dfm
index de6be767..6993a78f 100644
--- a/Examples/General/PNG Image32/MainUnit.dfm
+++ b/Examples/General/PNG Image32/MainUnit.dfm
@@ -11,22 +11,15 @@ object FmPngDemo: TFmPngDemo
Font.Height = -11
Font.Name = 'Tahoma'
Font.Style = []
- Padding.Left = 8
- Padding.Top = 8
- Padding.Right = 8
- Padding.Bottom = 8
OldCreateOrder = False
OnCreate = FormCreate
- DesignSize = (
- 475
- 279)
PixelsPerInch = 96
TextHeight = 13
object ImageDisplay: TImage32
- Left = 8
- Top = 8
- Width = 459
- Height = 262
+ Left = 0
+ Top = 38
+ Width = 475
+ Height = 241
Align = alClient
Bitmap.DrawMode = dmBlend
Bitmap.ResamplerClassName = 'TNearestResampler'
@@ -34,7 +27,43 @@ object FmPngDemo: TFmPngDemo
Scale = 1.000000000000000000
ScaleMode = smNormal
TabOrder = 0
- OnClick = ImageDisplayClick
- OnDblClick = ImageDisplayDblClick
+ ExplicitTop = 8
+ ExplicitHeight = 262
+ end
+ object Panel1: TPanel
+ Left = 0
+ Top = 0
+ Width = 475
+ Height = 38
+ Align = alTop
+ BevelOuter = bvNone
+ TabOrder = 1
+ object CheckBoxFit: TCheckBox
+ Left = 184
+ Top = 11
+ Width = 97
+ Height = 19
+ Caption = 'Scale to fit'
+ TabOrder = 0
+ OnClick = CheckBoxFitClick
+ end
+ end
+ object ButtonLoad: TButton
+ Left = 8
+ Top = 8
+ Width = 75
+ Height = 25
+ Caption = 'Load...'
+ TabOrder = 2
+ OnClick = ButtonLoadClick
+ end
+ object ButtonSave: TButton
+ Left = 89
+ Top = 8
+ Width = 75
+ Height = 25
+ Caption = 'Save...'
+ TabOrder = 3
+ OnClick = ButtonSaveClick
end
end
diff --git a/Examples/General/PNG Image32/MainUnit.lfm b/Examples/General/PNG Image32/MainUnit.lfm
deleted file mode 100644
index 46f64944..00000000
--- a/Examples/General/PNG Image32/MainUnit.lfm
+++ /dev/null
@@ -1,35 +0,0 @@
-object FmPngDemo: TFmPngDemo
- Left = 299
- Top = 55
- Caption = 'PNG Demonstration'
- ClientHeight = 279
- ClientWidth = 475
- Color = clBtnFace
- Font.Charset = DEFAULT_CHARSET
- Font.Color = clWindowText
- Font.Height = -11
- Font.Name = 'Tahoma'
- Font.Style = []
- OldCreateOrder = False
- OnCreate = FormCreate
- DesignSize = (
- 475
- 279)
- PixelsPerInch = 96
- TextHeight = 13
- object ImageDisplay: TImage32
- Left = 8
- Top = 8
- Width = 459
- Height = 262
- Anchors = [akLeft, akTop, akRight, akBottom]
- Bitmap.DrawMode = dmBlend
- Bitmap.ResamplerClassName = 'TNearestResampler'
- BitmapAlign = baTopLeft
- Scale = 1.000000000000000000
- ScaleMode = smNormal
- TabOrder = 0
- OnClick = ImageDisplayClick
- OnDblClick = ImageDisplayDblClick
- end
-end
diff --git a/Examples/General/PNG Image32/MainUnit.pas b/Examples/General/PNG Image32/MainUnit.pas
index 1c0d7e5c..9631a3b1 100644
--- a/Examples/General/PNG Image32/MainUnit.pas
+++ b/Examples/General/PNG Image32/MainUnit.pas
@@ -3,15 +3,21 @@
interface
uses
- {$IFDEF FPC} LCLIntf, {$ELSE}Windows, Messages, {$ENDIF} SysUtils, Classes,
- Graphics, Controls, Forms, Dialogs, GR32_Image;
+ {$IFDEF FPC} LCLIntf, {$ELSE} Windows, Messages, {$ENDIF}
+ SysUtils, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls,
+ GR32_Image;
type
TFmPngDemo = class(TForm)
ImageDisplay: TImage32;
+ Panel1: TPanel;
+ ButtonLoad: TButton;
+ ButtonSave: TButton;
+ CheckBoxFit: TCheckBox;
procedure FormCreate(Sender: TObject);
- procedure ImageDisplayClick(Sender: TObject);
- procedure ImageDisplayDblClick(Sender: TObject);
+ procedure ButtonLoadClick(Sender: TObject);
+ procedure ButtonSaveClick(Sender: TObject);
+ procedure CheckBoxFitClick(Sender: TObject);
end;
var
@@ -22,61 +28,89 @@ implementation
uses
GR32_PNG, GR32_PortableNetworkGraphic;
-{$IFDEF FPC}
-{$R *.lfm}
-{$ELSE}
{$R *.dfm}
-{$ENDIF}
-procedure TFmPngDemo.FormCreate(Sender: TObject);
+procedure TFmPngDemo.ButtonLoadClick(Sender: TObject);
+var
+ OpenDialog: TOpenDialog;
+ PNG: TPortableNetworkGraphic32;
begin
- if FileExists('..\Demo.png') then
- with TPortableNetworkGraphic32.Create do
- try
- LoadFromFile('..\Demo.png');
- AssignTo(ImageDisplay.Bitmap);
- finally
- Free;
- end
- else
- raise Exception.Create('File not found: Demo.png');
-
- ClientWidth := ImageDisplay.Bitmap.Width + 16;
- ClientHeight := ImageDisplay.Bitmap.Height + 16;
-end;
+ OpenDialog := TOpenDialog.Create(Self);
+ try
+ OpenDialog.Filter := 'PNG Images (*.png)|*.png|All files (*.*)|*.*';
+ OpenDialog.DefaultExt := '.png';
+ if not OpenDialog.Execute then
+ exit;
-procedure TFmPngDemo.ImageDisplayClick(Sender: TObject);
-begin
- with TSaveDialog.Create(Self) do
+ PNG := TPortableNetworkGraphic32.Create;
try
- Filter := 'PNG Images (*.png)|*.png';
- DefaultExt := '.png';
- if Execute then
- begin
- with TPortableNetworkGraphic32.Create do
- try
- AdaptiveFilterMethods := [aafmSub, aafmUp, aafmAverage];
- Assign(ImageDisplay.Bitmap);
- InterlaceMethod := imAdam7;
- SaveToFile(FileName);
- finally
- Free;
- end;
- end;
+ PNG.LoadFromFile(OpenDialog.FileName);
+ PNG.AssignTo(ImageDisplay.Bitmap);
finally
- Free;
+ PNG.Free;
end;
+ finally
+ OpenDialog.Free;
+ end;
end;
-procedure TFmPngDemo.ImageDisplayDblClick(Sender: TObject);
+procedure TFmPngDemo.ButtonSaveClick(Sender: TObject);
+var
+ SaveDialog: TSaveDialog;
+ PNG: TPortableNetworkGraphic32;
begin
- with TPortableNetworkGraphic32.Create do
+ SaveDialog := TSaveDialog.Create(Self);
+ try
+ SaveDialog.Filter := 'PNG Images (*.png)|*.png|All files (*.*)|*.*';
+ SaveDialog.DefaultExt := '.png';
+ if not SaveDialog.Execute then
+ exit;
+
+ PNG := TPortableNetworkGraphic32.Create;
try
- Assign(ImageDisplay.Bitmap);
- SaveToFile('Test.png');
+ PNG.AdaptiveFilterMethods := [aafmSub, aafmUp, aafmAverage];
+ PNG.Assign(ImageDisplay.Bitmap);
+ PNG.InterlaceMethod := imAdam7;
+ PNG.SaveToFile(SaveDialog.FileName);
finally
- Free;
+ PNG.Free;
end;
+ finally
+ SaveDialog.Free;
+ end;
+end;
+
+procedure TFmPngDemo.CheckBoxFitClick(Sender: TObject);
+begin
+ if (TCheckBox(Sender).Checked) then
+ begin
+ ImageDisplay.ScaleMode := smResize;
+ ImageDisplay.BitmapAlign := baCenter;
+ end else
+ begin
+ ImageDisplay.ScaleMode := smNormal;
+ ImageDisplay.BitmapAlign := baTopLeft;
+ end;
+end;
+
+procedure TFmPngDemo.FormCreate(Sender: TObject);
+begin
+{$IFNDEF FPC}
+ ImageDisplay.Margins.Top := 8;
+ ImageDisplay.Margins.Left := 8;
+ ImageDisplay.Margins.Bottom := 8;
+ ImageDisplay.Margins.Right := 8;
+ ImageDisplay.AlignWithMargins := True;
+{$ENDIF}
+
+ if FileExists('..\Demo.png') then
+ with TPortableNetworkGraphic32.Create do
+ try
+ LoadFromFile('..\Demo.png');
+ AssignTo(ImageDisplay.Bitmap);
+ finally
+ Free;
+ end;
end;
end.
diff --git a/Examples/General/PNG Image32/PNG_GR32_Demo.dpr b/Examples/General/PNG Image32/PNG_GR32_Demo.dpr
index c4456277..5b51688d 100644
--- a/Examples/General/PNG Image32/PNG_GR32_Demo.dpr
+++ b/Examples/General/PNG Image32/PNG_GR32_Demo.dpr
@@ -2,9 +2,7 @@ program PNG_GR32_Demo;
uses
Forms,
- MainUnit in 'MainUnit.pas' {FmPngDemo},
- GR32_Png in '..\GR32_Png.pas',
- GR32_PortableNetworkGraphic in '..\GR32_PortableNetworkGraphic.pas';
+ MainUnit in 'MainUnit.pas' {FmPngDemo};
{$R *.res}
diff --git a/Examples/General/PNG Image32/PNG_GR32_Demo.dproj b/Examples/General/PNG Image32/PNG_GR32_Demo.dproj
index 4b487480..1eddeaf6 100644
--- a/Examples/General/PNG Image32/PNG_GR32_Demo.dproj
+++ b/Examples/General/PNG Image32/PNG_GR32_Demo.dproj
@@ -83,8 +83,6 @@
-
-
Base
diff --git a/Examples/General/PNG Image32/PNG_GR32_Demo.lpi b/Examples/General/PNG Image32/PNG_GR32_Demo.lpi
index 2d574c20..1a06ac72 100644
--- a/Examples/General/PNG Image32/PNG_GR32_Demo.lpi
+++ b/Examples/General/PNG Image32/PNG_GR32_Demo.lpi
@@ -1,13 +1,13 @@
-
+
+
-
@@ -22,11 +22,11 @@
-
+
-
-
+
+
@@ -44,7 +44,7 @@
-
+
@@ -73,26 +73,24 @@
-
+
-
-
-
+
+
+
-
-
+
-
@@ -106,27 +104,32 @@
+
+
-
+
-
-
-
+
+
+
+
+
+
@@ -137,17 +140,20 @@
+
+
+
@@ -187,139 +193,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
-
+
-
-
+
+
@@ -336,6 +262,7 @@
+
diff --git a/Examples/General/PNG Image32/PNG_GR32_Demo.lpr b/Examples/General/PNG Image32/PNG_GR32_Demo.lpr
deleted file mode 100644
index d3b34e1a..00000000
--- a/Examples/General/PNG Image32/PNG_GR32_Demo.lpr
+++ /dev/null
@@ -1,18 +0,0 @@
-program PNG_GR32_Demo;
-
-{$R *.res}
-
-uses
- Interfaces,
- Forms,
- GR32_Lazarus,
- GR32_PortableNetworkGraphic,
- GR32_Png,
- MainUnit;
-
-begin
- Application.Title:='GR32 PNG Demo';
- Application.Initialize;
- Application.CreateForm(TFmPngDemo, FmPngDemo);
- Application.Run;
-end.