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

Make BitmapImage always use a custom TAlphaBitmap even on Delphi 2009+. Having such a difference between ANSI and Unicode versions make its too hard to expose things to [Code]. #180.

Martijn Laan 10 лет назад
Родитель
Сommit
c7b5160a41
4 измененных файлов с 9 добавлено и 27 удалено
  1. 9 20
      Components/BitmapImage.pas
  2. 0 2
      Projects/ScriptClasses_C.pas
  3. 0 2
      Projects/ScriptClasses_R.pas
  4. 0 3
      ishelp/isxclasses.pas

+ 9 - 20
Components/BitmapImage.pas

@@ -17,25 +17,19 @@ uses
   Windows, Controls, Graphics, Classes;
 
 type
-{$IFNDEF IS_D12}
-  {$DEFINE CUSTOM_BITMAP}
-  {$IFNDEF IS_D3}
-    {$DEFINE CUSTOM_BITMAP_D2}
-  {$ENDIF}
+{$IFNDEF IS_D3}
+  {$DEFINE CUSTOM_PIXELFORMAT_D2}
 {$ENDIF}
 
-{$IFNDEF CUSTOM_BITMAP}
-  TAlphaBitmap = TBitmap;
-{$ELSE CUSTOM_BITMAP}
- {$IFDEF CUSTOM_BITMAP_D2}
+{$IFDEF CUSTOM_PIXELFORMAT_D2}
   TPixelFormat = (pfUndefined, pfDevice, pf1bit, pf4bit, pf8bit, pf15bit, pf16bit, pf24bit, pf32bit, pfCustom);
- {$ENDIF}
+{$ENDIF}
   TAlphaFormat = (afIgnored, afDefined, afPremultiplied);
   TAlphaBitmap = class(TBitmap)
   private
     FAlphaFormat: TAlphaFormat;
     procedure PreMultiplyAlpha;
-{$IFDEF CUSTOM_BITMAP_D2}
+{$IFDEF CUSTOM_PIXELFORMAT_D2}
   private
     FPixelFormat: TPixelFormat;
     function GetPixelFormat: TPixelFormat;
@@ -44,11 +38,10 @@ type
     procedure Assign(Source: TPersistent); override;
     procedure LoadFromStream(Stream: TStream); override;
     property AlphaFormat: TAlphaFormat read FAlphaFormat write FAlphaFormat;
-{$IFDEF CUSTOM_BITMAP_D2}
+{$IFDEF CUSTOM_PIXELFORMAT_D2}
     property PixelFormat: TPixelFormat read GetPixelFormat;
 {$ENDIF}
   end;
-{$ENDIF CUSTOM_BITMAP}
 
   TBitmapImage = class(TGraphicControl)
   private
@@ -306,9 +299,7 @@ begin
   end;
 end;
 
-{$IFDEF CUSTOM_BITMAP}
-
-{$IFDEF CUSTOM_BITMAP_D2}
+{$IFDEF CUSTOM_PIXELFORMAT_D2}
 // Types defined to access internal private fields, must match exactly the
 // implementation of both types from Graphics.
 type
@@ -344,7 +335,7 @@ begin
     FAlphaFormat := TAlphaBitmap(Source).AlphaFormat;
 end;
 
-{$IFDEF CUSTOM_BITMAP_D2}
+{$IFDEF CUSTOM_PIXELFORMAT_D2}
 function TAlphaBitmap.GetPixelFormat: TPixelFormat;
 begin
   // We use cached value as default since after the canvas handle has been
@@ -395,7 +386,7 @@ var
 begin
   if (PixelFormat = pf32bit) then //Premultiply the alpha into the color
   begin
-{$IFNDEF CUSTOM_BITMAP_D2}
+{$IFNDEF CUSTOM_PIXELFORMAT_D2}
     Pointer(ImageData) := ScanLine[0];
     if ImageData = NativeUInt(nil) then
       Exit;
@@ -420,6 +411,4 @@ begin
   end;
 end;
 
-{$ENDIF CUSTOM_BITMAP}
-
 end.

+ 0 - 2
Projects/ScriptClasses_C.pas

@@ -224,11 +224,9 @@ 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

+ 0 - 2
Projects/ScriptClasses_R.pas

@@ -138,14 +138,12 @@ 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;

+ 0 - 3
ishelp/isxclasses.pas

@@ -590,11 +590,8 @@ 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)