Просмотр исходного кода

Add to [Code]. Allows to simply do: BitmapImage.PngImage.LoadFromFile().

Martijn Laan 3 недель назад
Родитель
Сommit
52a50f14a2

+ 1 - 0
Components/BitmapImage.pas

@@ -139,6 +139,7 @@ end;
 procedure TBitmapImageImplementation.DeInit;
 begin
   FreeAndNil(StretchedBitmap);
+  FreeAndNil(PngImage);
   FreeAndNil(Bitmap);
 end;
 

+ 10 - 2
ISHelp/isxclasses.pas

@@ -170,6 +170,12 @@ TBitmap = class(TGraphic)
   property Handle: HBITMAP; read write;
 end;
 
+TPngImage = class(TGraphic)
+  procedure LoadFromStream(Stream: TStream);
+  procedure SaveToStream(Stream: TStream);
+  property Canvas: TCanvas; read write;
+end;
+
 TAlign = (alNone, alTop, alBottom, alLeft, alRight, alClient);
 
 TAnchorKind = (akLeft, akTop, akRight, akBottom);
@@ -671,9 +677,10 @@ TBitmapButton = class(TCustomControl)
   property Anchors: TAnchors; read write;
   property AutoSize: Boolean; read write;
   property BackColor: TColor; read write;
+  property Bitmap: TBitmap; read write;
   property Caption: Boolean; read write;
   property Center: Boolean; read write;
-  property Bitmap: TBitmap; read write;
+  property PngImage: TPngImage; read write;
   property ReplaceColor: TColor; read write;
   property ReplaceWithColor: TColor; read write;
   property Stretch: Boolean; read write;
@@ -685,8 +692,9 @@ TBitmapImage = class(TGraphicControl)
   property Anchors: TAnchors; read write;
   property AutoSize: Boolean; read write;
   property BackColor: TColor; read write;
-  property Center: Boolean; read write;
   property Bitmap: TBitmap; read write;
+  property Center: Boolean; read write;
+  property PngImage: TPngImage; read write;
   property ReplaceColor: TColor; read write;
   property ReplaceWithColor: TColor; read write;
   property Stretch: Boolean; read write;

+ 6 - 6
ISHelp/isxclasses_wordlists_generated.pas

@@ -33,10 +33,10 @@ var
     'TNewProgressBar', 'TNewProgressBarState', 'TNewProgressBarStyle', 'TNewRadioButton',
     'TNewStaticText', 'TNotifyEvent', 'TObject', 'TOutputMarqueeProgressWizardPage', 'TOutputMsgMemoWizardPage',
     'TOutputMsgWizardPage', 'TOutputProgressWizardPage', 'TPanel', 'TPanelBevel', 'TPasswordEdit',
-    'TPen', 'TPenMode', 'TPenStyle', 'TPersistent', 'TPopupMode', 'TPosition', 'TRadioButton',
-    'TRichEditViewer', 'TScrollingWinControl', 'TScrollStyle', 'TSetupForm', 'TShiftState',
-    'TSizeConstraints', 'TStartMenuFolderTreeView', 'TStream', 'TStringList', 'TStrings',
-    'TStringStream', 'TSysLinkEvent', 'TSysLinkType', 'TUIStateForm', 'TUninstallProgressForm',
+    'TPen', 'TPenMode', 'TPenStyle', 'TPersistent', 'TPngImage', 'TPopupMode', 'TPosition',
+    'TRadioButton', 'TRichEditViewer', 'TScrollingWinControl', 'TScrollStyle', 'TSetupForm',
+    'TShiftState', 'TSizeConstraints', 'TStartMenuFolderTreeView', 'TStream', 'TStringList',
+    'TStrings', 'TStringStream', 'TSysLinkEvent', 'TSysLinkType', 'TUIStateForm', 'TUninstallProgressForm',
     'TWinControl', 'TWizardForm', 'TWizardPage', 'TWizardPageButtonEvent', 'TWizardPageCancelEvent',
     'TWizardPageNotifyEvent', 'TWizardPageShouldSkipEvent'
   ];
@@ -193,8 +193,8 @@ var
     'OnRename', 'OnResize', 'OnShouldSkipPage', 'OnShow', 'OuterNotebook', 'Owner', 'PageCount',
     'PageDescriptionLabel', 'PageIndex', 'PageNameLabel', 'Pages', 'Parent', 'ParentBackground',
     'Password', 'PasswordChar', 'PasswordEdit', 'PasswordEditLabel', 'PasswordLabel', 'PasswordPage',
-    'Pen', 'Pitch', 'Pixels', 'PixelsPerInch', 'PopupMode', 'PopupParent', 'Position',
-    'PreparingErrorBitmapImage', 'PreparingLabel', 'PreparingMemo', 'PreparingNoRadio',
+    'Pen', 'Pitch', 'Pixels', 'PixelsPerInch', 'PngImage', 'PopupMode', 'PopupParent',
+    'Position', 'PreparingErrorBitmapImage', 'PreparingLabel', 'PreparingMemo', 'PreparingNoRadio',
     'PreparingPage', 'PreparingYesRadio', 'PrevAppDir', 'ProgressBar', 'ProgressGauge',
     'PromptLabels', 'ReadOnly', 'ReadyLabel', 'ReadyMemo', 'ReadyPage', 'ReplaceColor',
     'ReplaceWithColor', 'RequireRadioSelection', 'RichEditViewer', 'RightToLeft', 'RTFText',

+ 16 - 2
Projects/Src/Compiler.ScriptClasses.pas

@@ -33,6 +33,16 @@ begin
   end;
 end;
 
+procedure RegisterPngImage_C(Cl: TPSPascalCompiler);
+begin
+  with CL.AddClassN(CL.FindClass('TGraphic'),'TPngImage') do
+  begin
+    RegisterMethod('procedure LoadFromStream(Stream: TStream)');
+    RegisterMethod('procedure SaveToStream(Stream: TStream)');
+    RegisterProperty('Canvas', 'TCanvas', iptr);
+  end;
+end;
+
 procedure RegisterNewStaticText_C(Cl: TPSPascalCompiler);
 begin
   with Cl.AddClassN(Cl.FindClass('TWinControl'), 'TNewStaticText') do
@@ -241,9 +251,10 @@ begin
     RegisterProperty('Anchors', 'TAnchors', iptrw);
     RegisterProperty('AutoSize', 'Boolean', iptrw);
     RegisterProperty('BackColor', 'TColor', iptrw);
+    RegisterProperty('Bitmap', 'TBitmap', iptrw);
     RegisterProperty('Caption', 'String', iptrw);
     RegisterProperty('Center', 'Boolean', iptrw);
-    RegisterProperty('Bitmap', 'TBitmap', iptrw);
+    RegisterProperty('PngImage', 'TPngImage', iptrw);
     RegisterProperty('ReplaceColor', 'TColor', iptrw);
     RegisterProperty('ReplaceWithColor', 'TColor', iptrw);
     RegisterProperty('Stretch', 'Boolean', iptrw);
@@ -259,8 +270,9 @@ begin
     RegisterProperty('Anchors', 'TAnchors', iptrw);
     RegisterProperty('AutoSize', 'Boolean', iptrw);
     RegisterProperty('BackColor', 'TColor', iptrw);
-    RegisterProperty('Center', 'Boolean', iptrw);
     RegisterProperty('Bitmap', 'TBitmap', iptrw);
+    RegisterProperty('Center', 'Boolean', iptrw);
+    RegisterProperty('PngImage', 'TPngImage', iptrw);
     RegisterProperty('ReplaceColor', 'TColor', iptrw);
     RegisterProperty('ReplaceWithColor', 'TColor', iptrw);
     RegisterProperty('Stretch', 'Boolean', iptrw);
@@ -673,6 +685,8 @@ begin
   { ComObj }
   SIRegister_ComObj(Cl);
 
+  RegisterPngImage_C(Cl);
+
   RegisterNewStaticText_C(Cl);
   RegisterNewCheckListBox_C(Cl);
   RegisterNewProgressBar_C(Cl);

+ 15 - 1
Projects/Src/Setup.ScriptClasses.pas

@@ -20,7 +20,7 @@ procedure ScriptClassesLibraryUpdateVars(ScriptInterpreter: TIFPSExec);
 implementation
 
 uses
-  Windows, Controls, Forms, StdCtrls, Graphics,
+  Windows, Controls, Forms, StdCtrls, Graphics, Imaging.pngimage,
   uPSR_std, uPSR_classes, uPSR_graphics, uPSR_controls, uPSR_forms,
   uPSR_stdctrls, uPSR_extctrls, uPSR_comobj,
   NewStaticText, NewCheckListBox, NewProgressBar, RichEditViewer,
@@ -44,6 +44,18 @@ begin
   end;
 end;
 
+procedure TPngImageCanvas_R(Self: TPngImage; var T: TCanvas); begin T := Self.Canvas; end;
+
+procedure RegisterPngImage_R(Cl: TPSRuntimeClassImporter);
+begin
+  with Cl.Add(TPngImage) do
+  begin
+    RegisterMethod(@TPngImage.LoadFromStream, 'LoadFromStream');
+    RegisterMethod(@TPngImage.SaveToStream, 'SaveToStream');
+    RegisterPropertyHelper(@TPngImageCanvas_R,nil,'Canvas');
+  end;
+end;
+
 procedure RegisterNewStaticText_R(Cl: TPSRuntimeClassImporter);
 begin
   with Cl.Add(TNewStaticText) do
@@ -428,6 +440,8 @@ begin
     { ComObj }
     RIRegister_ComObj(ScriptInterpreter);
 
+    RegisterPngImage_R(Cl);
+
     RegisterNewStaticText_R(Cl);
     RegisterNewCheckListBox_R(Cl);
     RegisterNewProgressBar_R(Cl);