Răsfoiți Sursa

Tell [Code] about the new stuff. #180.

Martijn Laan 10 ani în urmă
părinte
comite
09f158531a
3 a modificat fișierele cu 27 adăugiri și 2 ștergeri
  1. 8 1
      Projects/ScriptClasses_C.pas
  2. 9 0
      Projects/ScriptClasses_R.pas
  3. 10 1
      ishelp/isxclasses.pas

+ 8 - 1
Projects/ScriptClasses_C.pas

@@ -223,12 +223,19 @@ end;
 
 procedure RegisterBitmapImage_C(Cl: TPSPascalCompiler);
 begin
+  cl.AddTypeS('TAlphaFormat', '(afIgnored, afDefined, afPremultiplied)');
+  cl.AddTypeS('TPixelFormat', '(pfUndefined, pfDevice, pf1bit, pf4bit, pf8bit, pf15bit, pf16bit, pf24bit, pf32bit, pfCustom))');
+  with Cl.AddClassN(CL.FindClass('TBitmap'),'TAlphaBitmap') do
+  begin
+    RegisterProperty('AlphaFormat', 'TAlphaFormat', iptrw);
+    RegisterProperty('PixelFormat', 'TPixelFormat', iptr);
+  end;
   with Cl.AddClassN(CL.FindClass('TGraphicControl'),'TBitmapImage') do
   begin
     RegisterProperty('AutoSize', 'Boolean', iptrw);
     RegisterProperty('BackColor', 'TColor', iptrw);
     RegisterProperty('Center', 'Boolean', iptrw);
-    RegisterProperty('Bitmap', 'TBitmap', iptrw);
+    RegisterProperty('Bitmap', 'TAlphaBitmap', iptrw); //TBitmapImage.Bitmap property is actually published as a TBitmap but in reality it always returns a TAlphaBitmap
     RegisterProperty('ReplaceColor', 'TColor', iptrw);
     RegisterProperty('ReplaceWithColor', 'TColor', iptrw);
     RegisterProperty('Stretch', 'Boolean', iptrw);

+ 9 - 0
Projects/ScriptClasses_R.pas

@@ -136,8 +136,17 @@ begin
   Cl.Add(TFolderTreeView);
 end;
 
+procedure TAlphaBitmapAlphaFormat_W(Self: TAlphaBitmap; const T: TAlphaFormat); begin Self.AlphaFormat := T; end;
+procedure TAlphaBitmapAlphaFormat_R(Self: TAlphaBitmap; var T: TAlphaFormat); begin T := Self.AlphaFormat; end;
+procedure TAlphaBitmapPixelFormat_R(Self: TAlphaBitmap; var T: TPixelFormat); begin T := Self.PixelFormat; end;
+
 procedure RegisterBitmapImage_R(Cl: TPSRuntimeClassImporter);
 begin
+  with Cl.Add(TAlphaBitmap) do
+  begin
+    RegisterPropertyHelper(@TAlphaBitmapAlphaFormat_R, @TAlphaBitmapAlphaFormat_W, 'AlphaFormat');
+    RegisterPropertyHelper(@TAlphaBitmapPixelFormat_R, nil, 'PixelFormat');
+  end;
   Cl.Add(TBitmapImage);
 end;
 

+ 10 - 1
ishelp/isxclasses.pas

@@ -588,11 +588,20 @@ TStartMenuFolderTreeView = class(TCustomFolderTreeView)
   property OnRename: TFolderRenameEvent; read write;
 end;
 
+TAlphaFormat = (afIgnored, afDefined, afPremultiplied);
+
+TPixelFormat = (pfUndefined, pfDevice, pf1bit, pf4bit, pf8bit, pf15bit, pf16bit, pf24bit, pf32bit, pfCustom);
+
+TAlphaBitmap = class(TBitmap)
+  property AlphaFormat: TAlphaFormat; read write;
+  property PixelFormat: TPixelFormat; read;
+end;
+
 TBitmapImage = class(TGraphicControl)
   property AutoSize: Boolean; read write;
   property BackColor: TColor; read write;
   property Center: Boolean; read write;
-  property Bitmap: TBitmap; read write;
+  property Bitmap: TAlphaBitmap; read write;
   property ReplaceColor: TColor; read write;
   property ReplaceWithColor: TColor; read write;
   property Stretch: Boolean; read write;