Ignore:
Timestamp:
Apr 17, 2019, 10:42:18 AM (5 years ago)
Author:
chronos
Message:
  • Modified: Updated Graphics32 library.
Location:
GraphicTest/Packages/Graphics32
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GraphicTest/Packages/Graphics32

    • Property svn:ignore set to
      lib
  • GraphicTest/Packages/Graphics32/GR32.pas

    r450 r522  
    4444
    4545uses
    46   {$IFDEF FPC} LCLIntf, LCLType, Types, Controls, Graphics,{$ELSE}
    47   Windows, Messages, Controls, Graphics,{$ENDIF}
    48   Classes, SysUtils, GR32_System;
    49  
     46  {$IFDEF FPC} LCLIntf, LCLType, Types, {$ELSE}
     47  {$IFDEF COMPILERXE2_UP}UITypes, Types, {$ENDIF} Windows, {$ENDIF}
     48  Controls, Graphics, Classes, SysUtils;
     49
    5050{ Version Control }
    5151
    5252const
    53   Graphics32Version = '1.9.1';
     53  Graphics32Version = '2.0.0 alpha';
    5454
    5555{ 32-bit Color }
     
    6363  TArrayOfColor32 = array of TColor32;
    6464
     65{$IFNDEF RGBA_FORMAT}
    6566  TColor32Component = (ccBlue, ccGreen, ccRed, ccAlpha);
     67{$ELSE}
     68  TColor32Component = (ccRed, ccGreen, ccBlue, ccAlpha);
     69{$ENDIF}
    6670  TColor32Components = set of TColor32Component;
    6771
     
    6973  TColor32Entry = packed record
    7074    case Integer of
     75{$IFNDEF RGBA_FORMAT}
    7176      0: (B, G, R, A: Byte);
     77{$ELSE}
     78      0: (R, G, B, A: Byte);
     79{$ENDIF}
    7280      1: (ARGB: TColor32);
    7381      2: (Planes: array[0..3] of Byte);
     
    236244  // Some semi-transparent color constants
    237245  clTrWhite32             = TColor32($7FFFFFFF);
     246  clTrGray32              = TColor32($7F7F7F7F);
    238247  clTrBlack32             = TColor32($7F000000);
    239248  clTrRed32               = TColor32($7FFF0000);
     
    258267function AlphaComponent(Color32: TColor32): Integer; {$IFDEF USEINLINING} inline; {$ENDIF}
    259268function Intensity(Color32: TColor32): Integer; {$IFDEF USEINLINING} inline; {$ENDIF}
     269function InvertColor(Color32: TColor32): TColor32; {$IFDEF USEINLINING} inline; {$ENDIF}
    260270function SetAlpha(Color32: TColor32; NewAlpha: Integer): TColor32; {$IFDEF USEINLINING} inline; {$ENDIF}
     271procedure ModifyAlpha(var Color32: TColor32; NewAlpha: Byte); {$IFDEF USEINLINING} inline; {$ENDIF}
     272procedure ScaleAlpha(var Color32: TColor32; Scale: Single); {$IFDEF USEINLINING} inline; {$ENDIF}
    261273
    262274// Color space conversion
    263275function HSLtoRGB(H, S, L: Single): TColor32; overload;
    264276procedure RGBtoHSL(RGB: TColor32; out H, S, L : Single); overload;
    265 function HSLtoRGB(H, S, L: Integer): TColor32; overload;
     277function HSLtoRGB(H, S, L: Integer; A: Integer = $ff): TColor32; overload;
    266278procedure RGBtoHSL(RGB: TColor32; out H, S, L: Byte); overload;
     279function HSVtoRGB(H, S, V: Single): TColor32;
     280procedure RGBToHSV(Color: TColor32; out H, S, V: Single);
    267281
    268282{$IFNDEF PLATFORM_INDEPENDENT}
     
    277291  PFixed = ^TFixed;
    278292  TFixed = type Integer;
    279 
     293  {$NODEFINE TFixed}
     294
     295  {$NODEFINE PFixedRec}
    280296  PFixedRec = ^TFixedRec;
     297  {$NODEFINE TFixedRec}
    281298  TFixedRec = packed record
    282299    case Integer of
     
    315332  TArrayOfArrayOfInteger = array of TArrayOfInteger;
    316333
     334  PCardinalArray = ^TCardinalArray;
     335  TCardinalArray = array [0..0] of Cardinal;
     336  PArrayOfCardinal = ^TArrayOfCardinal;
     337  TArrayOfCardinal = array of Cardinal;
     338  PArrayOfArrayOfCardinal = ^TArrayOfArrayOfCardinal;
     339  TArrayOfArrayOfCardinal = array of TArrayOfCardinal;
     340
    317341  PSingleArray = ^TSingleArray;
    318342  TSingleArray = array [0..0] of Single;
     
    330354  FixedHalf = $7FFF;
    331355  FixedPI  = Round(PI * FixedOne);
    332   FixedToFloat = 1/FixedOne;
     356  FixedToFloat = 1 / FixedOne;
     357
     358  COne255th = 1 / $FF;
    333359
    334360function Fixed(S: Single): TFixed; overload; {$IFDEF USEINLINING} inline; {$ENDIF}
     
    355381  TFloatPoint = record
    356382    X, Y: TFloat;
     383  {$IFDEF SUPPORT_ENHANCED_RECORDS}
     384  public
     385    {$IFNDEF FPC}
     386    {$IFDEF COMPILERXE2_UP}
     387    constructor Create(P: TPointF); overload;
     388    {$ENDIF}
     389    constructor Create(P: TPoint); overload;
     390    constructor Create(X, Y: Integer); overload;
     391    constructor Create(X, Y: Single); overload;
     392    {$ENDIF}
     393
     394    // operator overloads
     395    class operator Equal(const Lhs, Rhs: TFloatPoint): Boolean;
     396    class operator NotEqual(const Lhs, Rhs: TFloatPoint): Boolean;
     397    class operator Add(const Lhs, Rhs: TFloatPoint): TFloatPoint;
     398    class operator Subtract(const Lhs, Rhs: TFloatPoint): TFloatPoint;
     399    {$IFDEF COMPILERXE2_UP}
     400    class operator Explicit(A: TPointF): TFloatPoint;
     401    class operator Implicit(A: TPointF): TFloatPoint;
     402    {$ENDIF}
     403
     404    class function Zero: TFloatPoint; inline; static;
     405  {$ENDIF}
    357406  end;
    358407
     
    367416  TFixedPoint = record
    368417    X, Y: TFixed;
    369   end;
     418  {$IFDEF SUPPORT_ENHANCED_RECORDS}
     419  public
     420    {$IFNDEF FPC}
     421    {$IFDEF COMPILERXE2_UP}
     422    constructor Create(P: TPointF); overload;
     423    {$ENDIF}
     424    constructor Create(P: TFloatPoint); overload;
     425    constructor Create(X, Y: TFixed); overload;
     426    constructor Create(X, Y: Integer); overload;
     427    constructor Create(X, Y: TFloat); overload;
     428    {$ENDIF}
     429
     430    // operator overloads
     431    class operator Equal(const Lhs, Rhs: TFixedPoint): Boolean;
     432    class operator NotEqual(const Lhs, Rhs: TFixedPoint): Boolean;
     433    class operator Add(const Lhs, Rhs: TFixedPoint): TFixedPoint;
     434    class operator Subtract(const Lhs, Rhs: TFixedPoint): TFixedPoint;
     435
     436    class function Zero: TFixedPoint; inline; static;
     437  {$ENDIF}
     438  end;
     439  {$NODEFINE TFixedPoint}
    370440
    371441  PFixedPointArray = ^TFixedPointArray;
     
    397467
    398468  PFloatRect = ^TFloatRect;
     469  {$NODEFINE TFloatRect}
     470{$IFDEF SupportsBoost}
     471  (*$HPPEMIT '#include <boost/strong_typedef.hpp>'*)
     472{$ENDIF}
     473  (*$HPPEMIT 'namespace Gr32 {'*)
     474{$IFDEF SupportsBoost}
     475  (*$HPPEMIT 'BOOST_STRONG_TYPEDEF(int, TFixed)'*)
     476{$ELSE}
     477  (*$HPPEMIT 'typedef int TFixed;'*)
     478{$ENDIF}
     479  (*$HPPEMIT 'struct TFixedPoint { float X, Y; }; typedef struct TFixedPoint TFixedPoint;'*)
     480  (*$HPPEMIT 'struct TFloatRect { float Left, Top, Right, Bottom; }; typedef struct TFloatRect TFloatRect;'*)
     481  (*$HPPEMIT 'struct TFixedRect { TFixed Left, Top, Right, Bottom; }; typedef struct TFixedRect TFixedRect;'*)
     482  (*$HPPEMIT '} // namespace Gr32 '*)
    399483  TFloatRect = packed record
    400484    case Integer of
     
    403487  end;
    404488
     489  {$NODEFINE PFixedRect}
    405490  PFixedRect = ^TFixedRect;
     491  {$NODEFINE TFixedRect}
    406492  TFixedRect = packed record
    407493    case Integer of
     
    417503function MakeRect(const FXR: TFixedRect; Rounding: TRectRounding = rrClosest): TRect; overload;
    418504function FixedRect(const L, T, R, B: TFixed): TFixedRect; overload; {$IFDEF USEINLINING} inline; {$ENDIF}
     505function FixedRect(const TopLeft, BottomRight: TFixedPoint): TFixedRect; overload; {$IFDEF USEINLINING} inline; {$ENDIF}
    419506function FixedRect(const ARect: TRect): TFixedRect; overload; {$IFDEF USEINLINING} inline; {$ENDIF}
    420507function FixedRect(const FR: TFloatRect): TFixedRect; overload; {$IFDEF USEINLINING} inline; {$ENDIF}
    421508function FloatRect(const L, T, R, B: TFloat): TFloatRect; overload; {$IFDEF USEINLINING} inline; {$ENDIF}
     509function FloatRect(const TopLeft, BottomRight: TFloatPoint): TFloatRect; overload; {$IFDEF USEINLINING} inline; {$ENDIF}
    422510function FloatRect(const ARect: TRect): TFloatRect; overload; {$IFDEF USEINLINING} inline; {$ENDIF}
    423511function FloatRect(const FXR: TFixedRect): TFloatRect; overload; {$IFDEF USEINLINING} inline; {$ENDIF}
     
    458546{$ENDIF}
    459547
    460 { Gamma bias for line/pixel antialiasing }
    461 
    462 var
    463   GAMMA_TABLE: array [Byte] of Byte;
    464 
    465 procedure SetGamma(Gamma: Single = 0.7);
    466 
    467548type
    468549  { TPlainInterfacedPersistent }
     
    475556  protected
    476557    { IInterface }
    477     function _AddRef: Integer; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
    478     function _Release: Integer; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
    479     function QueryInterface({$IFDEF FPC_HAS_CONSTREF}constref{$ELSE}const{$ENDIF}IID: TGUID; out Obj): HResult; virtual; {$IFNDEF WINDOWS}cdecl{$ELSE}stdcall{$ENDIF};
    480 
     558{$IFDEF FPC_HAS_CONSTREF}
     559    function QueryInterface(constref iid: TGuid; out obj): HResult; {$IFDEF WINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
     560    function _AddRef: LongInt; {$IFDEF WINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
     561    function _Release: LongInt; {$IFDEF WINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
     562{$ELSE}
     563    function QueryInterface(const iid: TGuid; out obj): HResult; stdcall;
     564    function _AddRef: LongInt; stdcall;
     565    function _Release: LongInt; stdcall;
     566{$ENDIF}
    481567    property RefCounted: Boolean read FRefCounted write FRefCounted;
    482568  public
     
    535621    procedure ChangeSize(var Width, Height: Integer; NewWidth, NewHeight: Integer); virtual;
    536622  public
     623    constructor Create(Width, Height: Integer); reintroduce; overload;
     624
    537625    procedure Delete; virtual;
    538626    function  Empty: Boolean; virtual;
     
    540628    function SetSizeFrom(Source: TPersistent): Boolean;
    541629    function SetSize(NewWidth, NewHeight: Integer): Boolean; virtual;
     630
    542631    property Height: Integer read FHeight write SetHeight;
    543632    property Width: Integer read FWidth write SetWidth;
     
    602691
    603692{$IFDEF BITS_GETTER}
    604     function GetBits: PColor32Array;     {$IFDEF USEINLINING} inline; {$ENDIF}
     693    function GetBits: PColor32Array; {$IFDEF USEINLINING} inline; {$ENDIF}
    605694{$ENDIF}
    606695
     
    618707    procedure SetResampler(Resampler: TCustomResampler);
    619708    function GetResamplerClassName: string;
    620     procedure SetResamplerClassName(Value: string);
     709    procedure SetResamplerClassName(const Value: string);
     710    function GetPenPos: TPoint;
     711    procedure SetPenPos(const Value: TPoint);
     712    function GetPenPosF: TFixedPoint;
     713    procedure SetPenPosF(const Value: TFixedPoint);
    621714  protected
    622715    WrapProcHorz: TWrapProcEx;
     
    638731    procedure DefineProperties(Filer: TFiler); override;
    639732
    640     procedure InitializeBackend; virtual;
     733    procedure InitializeBackend(Backend: TCustomBackendClass); virtual;
    641734    procedure FinalizeBackend; virtual;
    642735    procedure SetBackend(const Backend: TCustomBackend); virtual;
    643736
    644     function QueryInterface({$IFDEF FPC_HAS_CONSTREF}constref{$ELSE}const{$ENDIF} IID: TGUID; out Obj): HResult; override;
     737{$IFDEF FPC_HAS_CONSTREF}
     738    function QueryInterface(constref iid: TGuid; out obj): HResult; {$IFDEF WINDOWS}stdcall{$ELSE}cdecl{$ENDIF};
     739{$ELSE}
     740    function QueryInterface(const iid: TGuid; out obj): HResult; stdcall;
     741{$ENDIF}
    645742
    646743    function  GetPixel(X, Y: Integer): TColor32; {$IFDEF USEINLINING} inline; {$ENDIF}
     
    673770    procedure SetPixelXW(X, Y: TFixed; Value: TColor32);
    674771  public
    675     constructor Create; override;
     772    constructor Create(Backend: TCustomBackendClass); reintroduce; overload; virtual;
     773    constructor Create; reintroduce; overload; virtual;
     774    constructor Create(Width, Height: Integer); reintroduce; overload; virtual;
    676775    destructor Destroy; override;
     776
     777    class function GetPlatformBackendClass: TCustomBackendClass; virtual;
    677778
    678779    procedure Assign(Source: TPersistent); override;
     
    713814
    714815    procedure DrawTo(Dst: TCustomBitmap32); overload;
     816    procedure DrawTo(Dst: TCustomBitmap32; DstX, DstY: Integer); overload;
    715817    procedure DrawTo(Dst: TCustomBitmap32; DstX, DstY: Integer; const SrcRect: TRect); overload;
    716     procedure DrawTo(Dst: TCustomBitmap32; DstX, DstY: Integer); overload;
    717818    procedure DrawTo(Dst: TCustomBitmap32; const DstRect: TRect); overload;
    718819    procedure DrawTo(Dst: TCustomBitmap32; const DstRect, SrcRect: TRect); overload;
     
    765866    procedure LineToXSP(X, Y: TFixed);
    766867    procedure LineToFSP(X, Y: Single);
     868    property PenPos: TPoint read GetPenPos write SetPenPos;
     869    property PenPosF: TFixedPoint read GetPenPosF write SetPenPosF;
    767870
    768871    procedure FillRect(X1, Y1, X2, Y2: Integer; Value: TColor32);
     
    840943  private
    841944    FOnHandleChanged: TNotifyEvent;
    842      
     945
    843946    procedure BackendChangedHandler(Sender: TObject); override;
    844947    procedure BackendChangingHandler(Sender: TObject); override;
     
    855958    procedure SetFont(Value: TFont);
    856959  protected
    857     procedure InitializeBackend; override;
    858960    procedure FinalizeBackend; override;
    859961    procedure SetBackend(const Backend: TCustomBackend); override;
    860    
     962
    861963    procedure HandleChanged; virtual;
    862964    procedure CopyPropertiesTo(Dst: TCustomBitmap32); override;
    863965  public
     966    class function GetPlatformBackendClass: TCustomBackendClass; override;
     967
    864968  {$IFDEF BCB}
    865969    procedure Draw(const DstRect, SrcRect: TRect; hSrc: Cardinal); overload;
     
    871975    procedure DrawTo(hDst: Cardinal; DstX, DstY: Integer); overload;
    872976    procedure DrawTo(hDst: Cardinal; const DstRect, SrcRect: TRect); overload;
    873     procedure TileTo(hDst: Cardinal; const DstRect, SrcRect: TRect);
     977    procedure TileTo(hDst: Cardinal; const DstRect, SrcRect: TRect); overload;
    874978{$ELSE}
    875     procedure DrawTo(hDst: HDC; DstX, DstY: Integer); overload;
     979    procedure DrawTo(hDst: HDC; DstX: Integer = 0; DstY: Integer = 0); overload;
    876980    procedure DrawTo(hDst: HDC; const DstRect, SrcRect: TRect); overload;
    877     procedure TileTo(hDst: HDC; const DstRect, SrcRect: TRect);
     981    procedure TileTo(hDst: HDC; const DstRect, SrcRect: TRect); overload;
    878982{$ENDIF}
    879983
     984{$IFDEF COMPILER2009_UP}
     985    procedure DrawTo(Dst: TControlCanvas; DstX: Integer = 0; DstY: Integer = 0); overload;
     986    procedure DrawTo(Dst: TControlCanvas; const DstRect, SrcRect: TRect); overload;
     987    procedure TileTo(Dst: TControlCanvas; const DstRect, SrcRect: TRect); overload;
     988{$ENDIF}
     989
    880990    procedure UpdateFont;
    881     procedure Textout(X, Y: Integer; const Text: String); overload;
    882     procedure Textout(X, Y: Integer; const ClipRect: TRect; const Text: String); overload;
    883     procedure Textout(DstRect: TRect; const Flags: Cardinal; const Text: String); overload;
    884     function  TextExtent(const Text: String): TSize;
    885     function  TextHeight(const Text: String): Integer;
    886     function  TextWidth(const Text: String): Integer;
    887     procedure RenderText(X, Y: Integer; const Text: String; AALevel: Integer; Color: TColor32);
     991    procedure Textout(X, Y: Integer; const Text: string); overload;
     992    procedure Textout(X, Y: Integer; const ClipRect: TRect; const Text: string); overload;
     993    procedure Textout(var DstRect: TRect; const Flags: Cardinal; const Text: string); overload;
     994    function  TextExtent(const Text: string): TSize;
     995    function  TextHeight(const Text: string): Integer;
     996    function  TextWidth(const Text: string): Integer;
     997    procedure RenderText(X, Y: Integer; const Text: string; AALevel: Integer; Color: TColor32);
    888998    procedure TextoutW(X, Y: Integer; const Text: Widestring); overload;
    889999    procedure TextoutW(X, Y: Integer; const ClipRect: TRect; const Text: Widestring); overload;
    890     procedure TextoutW(DstRect: TRect; const Flags: Cardinal; const Text: Widestring); overload;
     1000    procedure TextoutW(var DstRect: TRect; const Flags: Cardinal; const Text: Widestring); overload;
    8911001    function  TextExtentW(const Text: Widestring): TSize;
    8921002    function  TextHeightW(const Text: Widestring): Integer;
     
    9361046    function Empty: Boolean; virtual;
    9371047
    938     procedure ChangeSize(var Width, Height: Integer; NewWidth, NewHeight: Integer; ClearBuffer: Boolean = True); virtual;
     1048    procedure ChangeSize(out Width, Height: Integer; NewWidth, NewHeight: Integer; ClearBuffer: Boolean = True); virtual;
    9391049
    9401050{$IFDEF BITS_GETTER}
     
    9921102  TCustomResamplerClass = class of TCustomResampler;
    9931103
    994 function GetPlatformBackendClass: TCustomBackendClass;
    995 
    9961104var
    9971105  StockBitmap: TBitmap;
    9981106
     1107resourcestring
     1108  RCStrUnmatchedReferenceCounting = 'Unmatched reference counting.';
     1109  RCStrCannotSetSize = 'Can''t set size from ''%s''';
     1110  RCStrInpropriateBackend = 'Inappropriate Backend';
     1111
    9991112implementation
    10001113
    10011114uses
    1002   Math, GR32_Blend, GR32_Filters, GR32_LowLevel, GR32_Math,
    1003   GR32_Resamplers, GR32_Containers, GR32_Backends, GR32_Backends_Generic,
     1115  Math, GR32_Blend, GR32_LowLevel, GR32_Math, GR32_Resamplers,
     1116  GR32_Containers, GR32_Gamma, GR32_Backends, GR32_Backends_Generic,
    10041117{$IFDEF FPC}
    10051118  Clipbrd,
     
    10191132  Clipbrd, GR32_Backends_VCL,
    10201133{$ENDIF}
    1021   GR32_DrawingEx;
     1134  GR32_VectorUtils;
    10221135
    10231136type
     
    10451158const
    10461159  ZERO_RECT: TRect = (Left: 0; Top: 0; Right: 0; Bottom: 0);
    1047 
    1048 resourcestring
    1049   RCStrUnmatchedReferenceCounting = 'Unmatched reference counting.';
    1050   RCStrCannotSetSize = 'Can''t set size from ''%s''';
    1051   RCStrInpropriateBackend = 'Inpropriate Backend';
    10521160
    10531161{ Color construction and conversion functions }
     
    11281236{$ENDIF}
    11291237        // the alpha channel byte is set to zero!
    1130         ROL     EAX, 8  // ABGR  ->  BGRA
     1238        ROL     EAX, 8  // ABGR  ->  RGBA
    11311239        XOR     AL, AL  // BGRA  ->  BGR0
    11321240        BSWAP   EAX     // BGR0  ->  0RGB
     
    11991307end;
    12001308
     1309function InvertColor(Color32: TColor32): TColor32;
     1310begin
     1311  TColor32Entry(Result).R := $FF - TColor32Entry(Color32).R;
     1312  TColor32Entry(Result).G := $FF - TColor32Entry(Color32).G;
     1313  TColor32Entry(Result).B := $FF - TColor32Entry(Color32).B;
     1314  TColor32Entry(Result).A := TColor32Entry(Color32).A;
     1315end;
     1316
    12011317function SetAlpha(Color32: TColor32; NewAlpha: Integer): TColor32;
    12021318begin
    1203   if NewAlpha < 0 then NewAlpha := 0
    1204   else if NewAlpha > 255 then NewAlpha := 255;
     1319  if NewAlpha < 0 then
     1320    NewAlpha := 0
     1321  else if NewAlpha > $FF then
     1322    NewAlpha := $FF;
    12051323  Result := (Color32 and $00FFFFFF) or (TColor32(NewAlpha) shl 24);
     1324end;
     1325
     1326procedure ModifyAlpha(var Color32: TColor32; NewAlpha: Byte);
     1327begin
     1328  TColor32Entry(Color32).A := NewAlpha;
     1329end;
     1330
     1331procedure ScaleAlpha(var Color32: TColor32; Scale: Single);
     1332begin
     1333  TColor32Entry(Color32).A := Round(Scale * TColor32Entry(Color32).A);
    12061334end;
    12071335
     
    12131341var
    12141342  M1, M2: Single;
    1215   R, G, B: Byte;
    12161343
    12171344  function HueToColor(Hue: Single): Byte;
     
    12201347  begin
    12211348    Hue := Hue - Floor(Hue);
    1222     if 6 * Hue < 1 then V := M1 + (M2 - M1) * Hue * 6
    1223     else if 2 * Hue < 1 then V := M2
    1224     else if 3 * Hue < 2 then V := M1 + (M2 - M1) * (2 * OneOverThree - Hue) * 6
     1349    if 6 * Hue < 1 then
     1350      V := M1 + (M2 - M1) * Hue * 6
     1351    else if 2 * Hue < 1 then
     1352      V := M2
     1353    else if 3 * Hue < 2 then
     1354      V := M1 + (M2 - M1) * (2 * OneOverThree - Hue) * 6
    12251355    else V := M1;
    1226     Result := Round(255 * V);
     1356    Result := Round($FF * V);
    12271357  end;
    12281358
     
    12301360  if S = 0 then
    12311361  begin
    1232     R := Round(255 * L);
    1233     G := R;
    1234     B := R;
    1235   end
     1362    Result := Gray32(Round($FF * L));
     1363    Exit;
     1364  end;
     1365
     1366  if L <= 0.5 then
     1367    M2 := L * (1 + S)
    12361368  else
    1237   begin
    1238     if L <= 0.5 then M2 := L * (1 + S)
    1239     else M2 := L + S - L * S;
    1240     M1 := 2 * L - M2;
    1241     R := HueToColor(H + OneOverThree);
    1242     G := HueToColor(H);
    1243     B := HueToColor(H - OneOverThree)
    1244   end;
    1245   Result := Color32(R, G, B);
     1369    M2 := L + S - L * S;
     1370  M1 := 2 * L - M2;
     1371  Result := Color32(
     1372    HueToColor(H + OneOverThree),
     1373    HueToColor(H),
     1374    HueToColor(H - OneOverThree));
    12461375end;
    12471376
     
    12491378const
    12501379  // reciprocal mul. opt.
    1251   R255 = 1 / 255;
    12521380  R6 = 1 / 6;
    12531381
     
    12551383  R, G, B, D, Cmax, Cmin: Single;
    12561384begin
    1257   R := RedComponent(RGB) * R255;
    1258   G := GreenComponent(RGB) * R255;
    1259   B := BlueComponent(RGB) * R255;
     1385  R := RedComponent(RGB) * COne255th;
     1386  G := GreenComponent(RGB) * COne255th;
     1387  B := BlueComponent(RGB) * COne255th;
    12601388  Cmax := Max(R, Max(G, B));
    12611389  Cmin := Min(R, Min(G, B));
     
    12881416end;
    12891417
    1290 function HSLtoRGB(H, S, L: Integer): TColor32;
     1418function HSLtoRGB(H, S, L, A: Integer): TColor32;
    12911419var
    12921420  V, M, M1, M2, VSF: Integer;
     
    13061434    M2 := V - VSF;
    13071435    case H shr 8 of
    1308       0: Result := Color32(V, M1, M);
    1309       1: Result := Color32(M2, V, M);
    1310       2: Result := Color32(M, V, M1);
    1311       3: Result := Color32(M, M2, V);
    1312       4: Result := Color32(M1, M, V);
    1313       5: Result := Color32(V, M, M2);
     1436      0: Result := Color32(V, M1, M, A);
     1437      1: Result := Color32(M2, V, M, A);
     1438      2: Result := Color32(M, V, M1, A);
     1439      3: Result := Color32(M, M2, V, A);
     1440      4: Result := Color32(M1, M, V, A);
     1441      5: Result := Color32(V, M, M2, A);
    13141442    else
    13151443      Result := 0;
     
    13371465  else
    13381466  begin
    1339     D := (Cmax - Cmin) * 255;
     1467    D := (Cmax - Cmin) * $FF;
    13401468    if L <= $7F then
    13411469      S := D div (Cmax + Cmin)
    13421470    else
    1343       S := D div (255 * 2 - Cmax - Cmin);
     1471      S := D div ($FF * 2 - Cmax - Cmin);
    13441472
    13451473    D := D * 6;
    13461474    if R = Cmax then
    1347       HL := (G - B) * 255 * 255 div D
     1475      HL := (G - B) * $FF * $FF div D
    13481476    else if G = Cmax then
    1349       HL := 255 * 2 div 6 + (B - R) * 255 * 255 div D
     1477      HL := $FF * 2 div 6 + (B - R) * $FF * $FF div D
    13501478    else
    1351       HL := 255 * 4 div 6 + (R - G) * 255 * 255 div D;
    1352 
    1353     if HL < 0 then HL := HL + 255 * 2;
     1479      HL := $FF * 4 div 6 + (R - G) * $FF * $FF div D;
     1480
     1481    if HL < 0 then HL := HL + $FF * 2;
    13541482    H := HL;
     1483  end;
     1484end;
     1485
     1486function HSVtoRGB(H, S, V: Single): TColor32;
     1487var
     1488  Tmp: TFloat;
     1489  Sel, Q, P: Integer;
     1490begin
     1491  V := 255 * V;
     1492  if S = 0 then
     1493  begin
     1494    Result := Gray32(Trunc(V));
     1495    Exit;
     1496  end; 
     1497
     1498  H := H - Floor(H);
     1499  Tmp := 6 * H - Floor(6 * H);
     1500
     1501  Sel := Trunc(6 * H);
     1502  if (Sel mod 2) = 0 then
     1503    Tmp := 1 - Tmp;
     1504
     1505  Q := Trunc(V * (1 - S));
     1506  P := Trunc(V * (1 - S * Tmp));
     1507
     1508  case Sel of
     1509    0:
     1510      Result := Color32(Trunc(V), P, Q);
     1511    1:
     1512      Result := Color32(P, Trunc(V), Q);
     1513    2:
     1514      Result := Color32(Q, Trunc(V), P);
     1515    3:
     1516      Result := Color32(Q, P, Trunc(V));
     1517    4:
     1518      Result := Color32(P, Q, Trunc(V));
     1519    5:
     1520      Result := Color32(Trunc(V), Q, P);
     1521  else
     1522    Result := Gray32(0);
     1523  end;
     1524end;
     1525
     1526procedure RGBToHSV(Color: TColor32; out H, S, V: Single);
     1527var
     1528  Delta, Min, Max: Single;
     1529  R, G, B: Integer;
     1530const
     1531  COneSixth = 1 / 6;
     1532begin
     1533  R := RedComponent(Color);
     1534  G := GreenComponent(Color);
     1535  B := BlueComponent(Color);
     1536
     1537  Min := MinIntValue([R, G, B]);
     1538  Max := MaxIntValue([R, G, B]);
     1539  V := Max / 255;
     1540
     1541  Delta := Max - Min;
     1542  if Max = 0 then
     1543    S := 0
     1544  else
     1545    S := Delta / Max;
     1546
     1547  if S = 0.0 then
     1548    H := 0
     1549  else
     1550  begin
     1551    if R = Max then
     1552      H := COneSixth * (G - B) / Delta
     1553    else if G = Max then
     1554      H := COneSixth * (2 + (B - R) / Delta)
     1555    else if B = Max then
     1556      H := COneSixth * (4 + (R - G) / Delta);
     1557
     1558    if H < 0.0 then
     1559      H := H + 1;
    13551560  end;
    13561561end;
     
    13671572  L.palVersion := $300;
    13681573  L.palNumEntries := 256;
    1369   for I := 0 to 255 do
     1574  for I := 0 to $FF do
    13701575  begin
    13711576    Cl := P[I];
     
    13861591function Fixed(S: Single): TFixed;
    13871592begin
    1388   Result := Round(S * 65536);
     1593  Result := Round(S * FixedOne);
    13891594end;
    13901595
     
    14281633
    14291634function FloatPoint(const FXP: TFixedPoint): TFloatPoint;
    1430 const
    1431   F = 1 / 65536;
    14321635begin
    14331636  with FXP do
    14341637  begin
    1435     Result.X := X * F;
    1436     Result.Y := Y * F;
    1437   end;
    1438 end;
     1638    Result.X := X * FixedToFloat;
     1639    Result.Y := Y * FixedToFloat;
     1640  end;
     1641end;
     1642
     1643{$IFDEF SUPPORT_ENHANCED_RECORDS}
     1644{$IFNDEF FPC}
     1645constructor TFloatPoint.Create(P: TPoint);
     1646begin
     1647  Self.X := P.X;
     1648  Self.Y := P.Y;
     1649end;
     1650
     1651{$IFDEF COMPILERXE2_UP}
     1652constructor TFloatPoint.Create(P: TPointF);
     1653begin
     1654  Self.X := P.X;
     1655  Self.Y := P.Y;
     1656end;
     1657{$ENDIF}
     1658
     1659constructor TFloatPoint.Create(X, Y: Integer);
     1660begin
     1661  Self.X := X;
     1662  Self.Y := Y;
     1663end;
     1664
     1665constructor TFloatPoint.Create(X, Y: TFloat);
     1666begin
     1667  Self.X := X;
     1668  Self.Y := Y;
     1669end;
     1670{$ENDIF}
     1671
     1672// operator overloads
     1673class operator TFloatPoint.Equal(const Lhs, Rhs: TFloatPoint): Boolean;
     1674begin
     1675  Result := (Lhs.X = Rhs.X) and (Lhs.Y = Rhs.Y);
     1676end;
     1677
     1678class operator TFloatPoint.NotEqual(const Lhs, Rhs: TFloatPoint): Boolean;
     1679begin
     1680  Result := (Lhs.X <> Rhs.X) or (Lhs.Y <> Rhs.Y);
     1681end;
     1682
     1683class operator TFloatPoint.Add(const Lhs, Rhs: TFloatPoint): TFloatPoint;
     1684begin
     1685  Result.X := Lhs.X + Rhs.X;
     1686  Result.Y := Lhs.Y + Rhs.Y;
     1687end;
     1688
     1689class operator TFloatPoint.Subtract(const Lhs, Rhs: TFloatPoint): TFloatPoint;
     1690begin
     1691  Result.X := Lhs.X - Rhs.X;
     1692  Result.Y := Lhs.Y - Rhs.Y;
     1693end;
     1694
     1695{$IFDEF COMPILERXE2_UP}
     1696class operator TFloatPoint.Explicit(A: TPointF): TFloatPoint;
     1697begin
     1698  Result.X := A.X;
     1699  Result.Y := A.Y;
     1700end;
     1701
     1702class operator TFloatPoint.Implicit(A: TPointF): TFloatPoint;
     1703begin
     1704  Result.X := A.X;
     1705  Result.Y := A.Y;
     1706end;
     1707{$ENDIF}
     1708
     1709class function TFloatPoint.Zero: TFloatPoint;
     1710begin
     1711  Result.X := 0;
     1712  Result.Y := 0;
     1713end;
     1714
     1715{$IFNDEF FPC}
     1716{$IFDEF COMPILERXE2_UP}
     1717constructor TFixedPoint.Create(P: TPointF);
     1718begin
     1719  Self.X := Fixed(P.X);
     1720  Self.Y := Fixed(P.Y);
     1721end;
     1722{$ENDIF}
     1723
     1724constructor TFixedPoint.Create(P: TFloatPoint);
     1725begin
     1726  Self.X := Fixed(P.X);
     1727  Self.Y := Fixed(P.Y);
     1728end;
     1729
     1730constructor TFixedPoint.Create(X, Y: TFixed);
     1731begin
     1732  Self.X := X;
     1733  Self.Y := Y;
     1734end;
     1735
     1736constructor TFixedPoint.Create(X, Y: Integer);
     1737begin
     1738  Self.X := Fixed(X);
     1739  Self.Y := Fixed(Y);
     1740end;
     1741
     1742constructor TFixedPoint.Create(X, Y: TFloat);
     1743begin
     1744  Self.X := Fixed(X);
     1745  Self.Y := Fixed(Y);
     1746end;
     1747{$ENDIF}
     1748
     1749// operator overloads
     1750class operator TFixedPoint.Equal(const Lhs, Rhs: TFixedPoint): Boolean;
     1751begin
     1752  Result := (Lhs.X = Rhs.X) and (Lhs.Y = Rhs.Y);
     1753end;
     1754
     1755class operator TFixedPoint.NotEqual(const Lhs, Rhs: TFixedPoint): Boolean;
     1756begin
     1757  Result := (Lhs.X <> Rhs.X) or (Lhs.Y <> Rhs.Y);
     1758end;
     1759
     1760class operator TFixedPoint.Add(const Lhs, Rhs: TFixedPoint): TFixedPoint;
     1761begin
     1762  Result.X := Lhs.X + Rhs.X;
     1763  Result.Y := Lhs.Y + Rhs.Y;
     1764end;
     1765
     1766class operator TFixedPoint.Subtract(const Lhs, Rhs: TFixedPoint): TFixedPoint;
     1767begin
     1768  Result.X := Lhs.X - Rhs.X;
     1769  Result.Y := Lhs.Y - Rhs.Y;
     1770end;
     1771
     1772class function TFixedPoint.Zero: TFixedPoint;
     1773begin
     1774  Result.X := 0;
     1775  Result.Y := 0;
     1776end;
     1777{$ENDIF}
    14391778
    14401779function FixedPoint(X, Y: Integer): TFixedPoint; overload;
     
    14461785function FixedPoint(X, Y: Single): TFixedPoint; overload;
    14471786begin
    1448   Result.X := Round(X * 65536);
    1449   Result.Y := Round(Y * 65536);
     1787  Result.X := Round(X * FixedOne);
     1788  Result.Y := Round(Y * FixedOne);
    14501789end;
    14511790
     
    14581797function FixedPoint(const FP: TFloatPoint): TFixedPoint; overload;
    14591798begin
    1460   Result.X := Round(FP.X * 65536);
    1461   Result.Y := Round(FP.Y * 65536);
     1799  Result.X := Round(FP.X * FixedOne);
     1800  Result.Y := Round(FP.Y * FixedOne);
    14621801end;
    14631802
     
    15511890end;
    15521891
     1892function FixedRect(const TopLeft, BottomRight: TFixedPoint): TFixedRect;
     1893begin
     1894  Result.TopLeft := TopLeft;
     1895  Result.BottomRight := BottomRight;
     1896end;
     1897
    15531898function FixedRect(const ARect: TRect): TFixedRect;
    15541899begin
     
    15821927    Bottom := B;
    15831928  end;
     1929end;
     1930
     1931function FloatRect(const TopLeft, BottomRight: TFloatPoint): TFloatRect;
     1932begin
     1933  Result.TopLeft := TopLeft;
     1934  Result.BottomRight := BottomRight;
    15841935end;
    15851936
     
    17452096end;
    17462097
    1747 { Gamma / Pixel Shape Correction table }
    1748 
    1749 procedure SetGamma(Gamma: Single);
    1750 var
    1751   i: Integer;
    1752 begin
    1753   for i := 0 to 255 do
    1754     GAMMA_TABLE[i] := Round(255 * Power(i / 255, Gamma));
    1755 end;
    1756 
    1757 function GetPlatformBackendClass: TCustomBackendClass;
    1758 begin
    1759 {$IFDEF FPC}
    1760   Result := TLCLBackend;
    1761 {$ELSE}
    1762   Result := TGDIBackend;
    1763 {$ENDIF}
    1764 end;
    1765 
    17662098{ TSimpleInterfacedPersistent }
    17672099
     
    18692201
    18702202{ TCustomMap }
     2203
     2204constructor TCustomMap.Create(Width, Height: Integer);
     2205begin
     2206  Create;
     2207  SetSize(Width, Height);
     2208end;
    18712209
    18722210procedure TCustomMap.ChangeSize(var Width, Height: Integer; NewWidth, NewHeight: Integer);
     
    19312269{ TCustomBitmap32 }
    19322270
    1933 constructor TCustomBitmap32.Create;
    1934 begin
    1935   inherited;
    1936 
    1937   InitializeBackend;
     2271constructor TCustomBitmap32.Create(Backend: TCustomBackendClass);
     2272begin
     2273  inherited Create;
     2274
     2275  InitializeBackend(Backend);
    19382276
    19392277  FOuterColor := $00000000;  // by default as full transparency black
     
    19492287end;
    19502288
     2289constructor TCustomBitmap32.Create;
     2290begin
     2291  Create(GetPlatformBackendClass);
     2292end;
     2293
    19512294destructor TCustomBitmap32.Destroy;
    19522295begin
     
    19632306end;
    19642307
    1965 procedure TCustomBitmap32.InitializeBackend;
    1966 begin
    1967   TMemoryBackend.Create(Self);
     2308procedure TCustomBitmap32.InitializeBackend(Backend: TCustomBackendClass);
     2309begin
     2310  Backend.Create(Self);
    19682311end;
    19692312
     
    19882331  http://qc.codegear.com/wc/qcmain.aspx?d=9500
    19892332
    1990   If any backend interface is used within the same procedure in which
     2333  if any backend interface is used within the same procedure in which
    19912334  the owner bitmap is also freed, the magic procedure cleanup will
    19922335  clear that particular interface long after the bitmap and its backend
     
    22392582        // this checks for transparency by comparing the pixel-color of the
    22402583        // temporary bitmap (red masked) with the pixel of our
    2241         // bitmap (white masked). If they match, make that pixel opaque
     2584        // bitmap (white masked). if they match, make that pixel opaque
    22422585        if DstColor = (SrcP^ and $00FFFFFF) then
    22432586          DstP^ := DstColor or $FF000000
     
    22922635
    22932636    // Check if the icon was painted with a merged alpha channel.
    2294     // The happens transparently for new-style 32-bit icons.
     2637    // That happens transparently for new-style 32-bit icons.
    22952638    // For all other bit depths GDI will reset our alpha channel to opaque.
    22962639    ReassignFromMasked := True;
     
    23202663    else if SrcGraphic is TMetaFile then
    23212664      AssignFromGraphicMasked(TargetBitmap, SrcGraphic)
     2665{$IFDEF COMPILER2005_UP}
     2666    else if SrcGraphic is TWICImage then
     2667      AssignFromGraphicPlain(TargetBitmap, SrcGraphic, 0, False)
     2668{$ENDIF}
    23222669{$ENDIF}
    23232670    else
     
    23852732end;
    23862733
     2734constructor TCustomBitmap32.Create(Width, Height: Integer);
     2735begin
     2736  Create;
     2737  SetSize(Width, Height);
     2738end;
     2739
    23872740{$IFDEF BITS_GETTER}
    23882741function TCustomBitmap32.GetBits: PColor32Array;
     
    23912744end;
    23922745{$ENDIF}
     2746
     2747procedure TCustomBitmap32.SetPenPos(const Value: TPoint);
     2748begin
     2749  MoveTo(Value.X, Value.Y);
     2750end;
     2751
     2752procedure TCustomBitmap32.SetPenPosF(const Value: TFixedPoint);
     2753begin
     2754  MoveTo(Value.X, Value.Y);
     2755end;
    23932756
    23942757procedure TCustomBitmap32.SetPixel(X, Y: Integer; Value: TColor32);
     
    24122775begin
    24132776  Result := @Bits[Y * FWidth];
     2777end;
     2778
     2779function TCustomBitmap32.GetPenPos: TPoint;
     2780begin
     2781  Result.X := RasterX;
     2782  Result.Y := RasterY;
     2783end;
     2784
     2785function TCustomBitmap32.GetPenPosF: TFixedPoint;
     2786begin
     2787  Result.X := RasterXF;
     2788  Result.Y := RasterYF;
    24142789end;
    24152790
     
    24382813end;
    24392814
    2440 procedure TCustomBitmap32.Draw(DstX, DstY: Integer; const SrcRect: TRect; Src: TCustomBitmap32);
     2815procedure TCustomBitmap32.Draw(DstX, DstY: Integer; const SrcRect: TRect;
     2816  Src: TCustomBitmap32);
    24412817begin
    24422818  if Assigned(Src) then Src.DrawTo(Self, DstX, DstY, SrcRect);
     
    24502826procedure TCustomBitmap32.DrawTo(Dst: TCustomBitmap32);
    24512827begin
    2452   BlockTransfer(Dst, 0, 0, Dst.ClipRect, Self, BoundsRect, DrawMode, FOnPixelCombine);
     2828  BlockTransfer(Dst, 0, 0, Dst.ClipRect, Self, BoundsRect, DrawMode,
     2829    FOnPixelCombine);
    24532830end;
    24542831
    24552832procedure TCustomBitmap32.DrawTo(Dst: TCustomBitmap32; DstX, DstY: Integer);
    24562833begin
    2457   BlockTransfer(Dst, DstX, DstY, Dst.ClipRect, Self, BoundsRect, DrawMode, FOnPixelCombine);
    2458 end;
    2459 
    2460 procedure TCustomBitmap32.DrawTo(Dst: TCustomBitmap32; DstX, DstY: Integer; const SrcRect: TRect);
    2461 begin
    2462   BlockTransfer(Dst, DstX, DstY, Dst.ClipRect, Self, SrcRect, DrawMode, FOnPixelCombine);
     2834  BlockTransfer(Dst, DstX, DstY, Dst.ClipRect, Self, BoundsRect, DrawMode,
     2835    FOnPixelCombine);
     2836end;
     2837
     2838procedure TCustomBitmap32.DrawTo(Dst: TCustomBitmap32; DstX, DstY: Integer;
     2839    const SrcRect: TRect);
     2840begin
     2841  BlockTransfer(Dst, DstX, DstY, Dst.ClipRect, Self, SrcRect,
     2842    DrawMode, FOnPixelCombine);
    24632843end;
    24642844
    24652845procedure TCustomBitmap32.DrawTo(Dst: TCustomBitmap32; const DstRect: TRect);
    24662846begin
    2467   StretchTransfer(Dst, DstRect, Dst.ClipRect, Self, BoundsRect, Resampler, DrawMode, FOnPixelCombine);
    2468 end;
    2469 
    2470 procedure TCustomBitmap32.DrawTo(Dst: TCustomBitmap32; const DstRect, SrcRect: TRect);
    2471 begin
    2472   StretchTransfer(Dst, DstRect, Dst.ClipRect, Self, SrcRect, Resampler, DrawMode, FOnPixelCombine);
     2847  StretchTransfer(Dst, DstRect, Dst.ClipRect, Self, BoundsRect, Resampler,
     2848    DrawMode, FOnPixelCombine);
     2849end;
     2850
     2851procedure TCustomBitmap32.DrawTo(Dst: TCustomBitmap32; const DstRect,
     2852  SrcRect: TRect);
     2853begin
     2854  StretchTransfer(Dst, DstRect, Dst.ClipRect, Self, SrcRect, Resampler,
     2855    DrawMode, FOnPixelCombine);
    24732856end;
    24742857
     
    26102993  begin
    26112994    A := C shr 24;  // opacity
    2612     celx := A * GAMMA_TABLE[flrx xor 255];
    2613     cely := GAMMA_TABLE[flry xor 255];
    2614     flrx := A * GAMMA_TABLE[flrx];
    2615     flry := GAMMA_TABLE[flry];
     2995    celx := A * GAMMA_ENCODING_TABLE[flrx xor $FF];
     2996    cely := GAMMA_ENCODING_TABLE[flry xor $FF];
     2997    flrx := A * GAMMA_ENCODING_TABLE[flrx];
     2998    flry := GAMMA_ENCODING_TABLE[flry];
    26162999
    26173000    CombineMem(C, P^, celx * cely shr 16); Inc(P);
     
    26223005  else
    26233006  begin
    2624     celx := GAMMA_TABLE[flrx xor 255];
    2625     cely := GAMMA_TABLE[flry xor 255];
    2626     flrx := GAMMA_TABLE[flrx];
    2627     flry := GAMMA_TABLE[flry];
    2628    
     3007    celx := GAMMA_ENCODING_TABLE[flrx xor $FF];
     3008    cely := GAMMA_ENCODING_TABLE[flry xor $FF];
     3009    flrx := GAMMA_ENCODING_TABLE[flrx];
     3010    flry := GAMMA_ENCODING_TABLE[flry];
     3011
    26293012    CombineMem(MergeReg(C, P^), P^, celx * cely shr 8); Inc(P);
    26303013    CombineMem(MergeReg(C, P^), P^, flrx * cely shr 8); Inc(P, FWidth);
     
    26633046  begin
    26643047    A := C shr 24;  // opacity
    2665     celx := A * GAMMA_TABLE[flrx xor 255];
    2666     cely := GAMMA_TABLE[flry xor 255];
    2667     flrx := A * GAMMA_TABLE[flrx];
    2668     flry := GAMMA_TABLE[flry];
     3048    celx := A * GAMMA_ENCODING_TABLE[flrx xor $FF];
     3049    cely := GAMMA_ENCODING_TABLE[flry xor $FF];
     3050    flrx := A * GAMMA_ENCODING_TABLE[flrx];
     3051    flry := GAMMA_ENCODING_TABLE[flry];
    26693052
    26703053    if (X >= FClipRect.Left) and (Y >= FClipRect.Top) and
     
    26873070  else
    26883071  begin
    2689     celx := GAMMA_TABLE[flrx xor 255];
    2690     cely := GAMMA_TABLE[flry xor 255];
    2691     flrx := GAMMA_TABLE[flrx];
    2692     flry := GAMMA_TABLE[flry];
     3072    celx := GAMMA_ENCODING_TABLE[flrx xor $FF];
     3073    cely := GAMMA_ENCODING_TABLE[flry xor $FF];
     3074    flrx := GAMMA_ENCODING_TABLE[flrx];
     3075    flry := GAMMA_ENCODING_TABLE[flry];
    26933076
    26943077    if (X >= FClipRect.Left) and (Y >= FClipRect.Top) and
     
    27893172begin
    27903173  Pos := (X shr 8) + (Y shr 8) * FWidth;
    2791   Result := Interpolator(GAMMA_TABLE[X and $FF xor 255],
    2792                          GAMMA_TABLE[Y and $FF xor 255],
     3174  Result := Interpolator(GAMMA_ENCODING_TABLE[X and $FF xor $FF],
     3175                         GAMMA_ENCODING_TABLE[Y and $FF xor $FF],
    27933176                         @Bits[Pos], @Bits[Pos + FWidth]);
    27943177end;
     
    28613244{$ELSE}
    28623245asm
     3246{$IFDEF TARGET_x64}
     3247          PUSH    RBP
     3248          SUB     RSP,$30
     3249{$ENDIF}
    28633250          ADD     X, $7F
    28643251          ADD     Y, $7F
     
    28733260{$ENDIF}
    28743261
     3262{$IFDEF TARGET_x64}
     3263          LEA     RSP,[RBP+$30]
     3264          POP     RBP
     3265{$ENDIF}
     3266
    28753267{$ENDIF}
    28763268end;
     
    29223314                       WordRec(TFixedRec(Y).Frac).Hi);
    29233315  EMMS;
     3316end;
     3317
     3318class function TCustomBitmap32.GetPlatformBackendClass: TCustomBackendClass;
     3319begin
     3320  Result := TMemoryBackend;
    29243321end;
    29253322
     
    29863383  end;
    29873384  FStippleCounter := Wrap(FStippleCounter, L);
     3385  {$IFDEF FPC}
     3386  PrevIndex := Trunc(FStippleCounter);
     3387  {$ELSE}
    29883388  PrevIndex := Round(FStippleCounter - 0.5);
    2989   PrevWeight := 255 - Round(255 * (FStippleCounter - PrevIndex));
     3389  {$ENDIF}
     3390  PrevWeight := $FF - Round($FF * (FStippleCounter - PrevIndex));
    29903391  if PrevIndex < 0 then FStippleCounter := L - 1;
    29913392  NextIndex := PrevIndex + 1;
    29923393  if NextIndex >= L then NextIndex := 0;
    2993   if PrevWeight = 255 then Result := FStipplePattern[PrevIndex]
     3394  if PrevWeight = $FF then Result := FStipplePattern[PrevIndex]
    29943395  else
    29953396  begin
     
    31283529    if Wy > 0 then
    31293530    begin
    3130       CombineMem(Value, PDst^, GAMMA_TABLE[(Wy * Wx1) shr 24]);
    3131       Wt := GAMMA_TABLE[Wy shr 8];
     3531      CombineMem(Value, PDst^, GAMMA_ENCODING_TABLE[(Wy * Wx1) shr 24]);
     3532      Wt := GAMMA_ENCODING_TABLE[Wy shr 8];
    31323533      Inc(PDst);
    31333534      for I := 0 to Count - 1 do
     
    31363537        Inc(PDst);
    31373538      end;
    3138       CombineMem(Value, PDst^, GAMMA_TABLE[(Wy * Wx2) shr 24]);
     3539      CombineMem(Value, PDst^, GAMMA_ENCODING_TABLE[(Wy * Wx2) shr 24]);
    31393540    end;
    31403541
     
    31443545    if Wy > 0 then
    31453546    begin
    3146       CombineMem(Value, PDst^, GAMMA_TABLE[(Wy * Wx1) shr 24]);
     3547      CombineMem(Value, PDst^, GAMMA_ENCODING_TABLE[(Wy * Wx1) shr 24]);
    31473548      Inc(PDst);
    3148       Wt := GAMMA_TABLE[Wy shr 8];
     3549      Wt := GAMMA_ENCODING_TABLE[Wy shr 8];
    31493550      for I := 0 to Count - 1 do
    31503551      begin
     
    31523553        Inc(PDst);
    31533554      end;
    3154       CombineMem(Value, PDst^, GAMMA_TABLE[(Wy * Wx2) shr 24]);
     3555      CombineMem(Value, PDst^, GAMMA_ENCODING_TABLE[(Wy * Wx2) shr 24]);
    31553556    end;
    31563557
     
    33223723    if Wx > 0 then
    33233724    begin
    3324       CombineMem(Value, PDst^, GAMMA_TABLE[(Wx * Wy1) shr 24]);
    3325       Wt := GAMMA_TABLE[Wx shr 8];
     3725      CombineMem(Value, PDst^, GAMMA_ENCODING_TABLE[(Wx * Wy1) shr 24]);
     3726      Wt := GAMMA_ENCODING_TABLE[Wx shr 8];
    33263727      Inc(PDst, FWidth);
    33273728      for I := 0 to Count - 1 do
     
    33303731        Inc(PDst, FWidth);
    33313732      end;
    3332       CombineMem(Value, PDst^, GAMMA_TABLE[(Wx * Wy2) shr 24]);
     3733      CombineMem(Value, PDst^, GAMMA_ENCODING_TABLE[(Wx * Wy2) shr 24]);
    33333734    end;
    33343735
     
    33383739    if Wx > 0 then
    33393740    begin
    3340       CombineMem(Value, PDst^, GAMMA_TABLE[(Wx * Wy1) shr 24]);
     3741      CombineMem(Value, PDst^, GAMMA_ENCODING_TABLE[(Wx * Wy1) shr 24]);
    33413742      Inc(PDst, FWidth);
    3342       Wt := GAMMA_TABLE[Wx shr 8];
     3743      Wt := GAMMA_ENCODING_TABLE[Wx shr 8];
    33433744      for I := 0 to Count - 1 do
    33443745      begin
     
    33463747        Inc(PDst, FWidth);
    33473748      end;
    3348       CombineMem(Value, PDst^, GAMMA_TABLE[(Wx * Wy2) shr 24]);
     3749      CombineMem(Value, PDst^, GAMMA_ENCODING_TABLE[(Wx * Wy2) shr 24]);
    33493750    end;
    33503751
     
    35453946          Inc(e, Dy2);
    35463947        end;
    3547         CheckAux := False; // to avoid ugly labels we set this to omit the next check
     3948        CheckAux := False; // to avoid ugly goto we set this to omit the next check
    35483949      end;
    35493950    end;
     
    35653966    end;
    35663967
    3567     // set auxiliary var to indicate that temp is not clipped, since
    3568     // temp still has the unclipped value assigned at setup.
     3968    // set auxiliary var to indicate that term is not clipped, since
     3969    // term still has the unclipped value assigned at setup.
    35693970    CheckAux := False;
    35703971
     
    35723973    if Y2 > Cy2 then
    35733974    begin
    3574       OC := Dx2 * (Cy2 - Y1) + Dx;
     3975      OC := Int64(Dx2) * (Cy2 - Y1) + Dx;
    35753976      term := X1 + OC div Dy2;
    35763977      rem := OC mod Dy2;
    35773978      if rem = 0 then Dec(term);
    3578       CheckAux := True; // set auxiliary var to indicate that temp is clipped
     3979      CheckAux := True; // set auxiliary var to indicate that term is clipped
    35793980    end;
    35803981
     
    35823983    begin
    35833984      term := Cx2;
    3584       CheckAux := True; // set auxiliary var to indicate that temp is clipped
     3985      CheckAux := True; // set auxiliary var to indicate that term is clipped
    35853986    end;
    35863987
     
    36104011    end;
    36114012
    3612     // do we need to skip the last pixel of the line and is temp not clipped?
     4013    // do we need to skip the last pixel of the line and is term not clipped?
    36134014    if not(L or CheckAux) then
    36144015    begin
     
    38144215          Inc(e, Dy2);
    38154216        end;
    3816         CheckAux := False; // to avoid ugly labels we set this to omit the next check
     4217        CheckAux := False; // to avoid ugly goto we set this to omit the next check
    38174218      end;
    38184219    end;
     
    38344235    end;
    38354236
    3836     // set auxiliary var to indicate that temp is not clipped, since
    3837     // temp still has the unclipped value assigned at setup.
     4237    // set auxiliary var to indicate that term is not clipped, since
     4238    // term still has the unclipped value assigned at setup.
    38384239    CheckAux := False;
    38394240
     
    38454246      rem := OC mod Dy2;
    38464247      if rem = 0 then Dec(term);
    3847       CheckAux := True; // set auxiliary var to indicate that temp is clipped
     4248      CheckAux := True; // set auxiliary var to indicate that term is clipped
    38484249    end;
    38494250
     
    38514252    begin
    38524253      term := Cx2;
    3853       CheckAux := True; // set auxiliary var to indicate that temp is clipped
     4254      CheckAux := True; // set auxiliary var to indicate that term is clipped
    38544255    end;
    38554256
     
    38794280    end;
    38804281
    3881     // do we need to skip the last pixel of the line and is temp not clipped?
     4282    // do we need to skip the last pixel of the line and is term not clipped?
    38824283    if not(L or CheckAux) then
    38834284    begin
     
    39154316var
    39164317  n, i: Integer;
    3917   nx, ny, hyp: Integer;
     4318  nx, ny, hyp, hypl: Integer;
    39184319  A: TColor32;
    39194320  h: Single;
     
    39254326    Inc(X1, 127); Inc(Y1, 127); Inc(X2, 127); Inc(Y2, 127);
    39264327    hyp := Hypot(nx, ny);
    3927     if L then Inc(hyp, 65536);
    3928     if hyp < 256 then Exit;
    3929     n := hyp shr 16;
     4328    if hyp = 0 then Exit;
     4329    hypl := hyp + (Integer(L) * FixedOne);
     4330    if (hypl < 256) then Exit;
     4331    n := hypl shr 16;
    39304332    if n > 0 then
    39314333    begin
     
    39404342    end;
    39414343    A := Value shr 24;
    3942     hyp := hyp - n shl 16;
     4344    hyp := hypl - n shl 16;
    39434345    A := A * Cardinal(hyp) shl 8 and $FF000000;
    39444346    SET_T256((X1 + X2 - nx) shr 9, (Y1 + Y2 - ny) shr 9, Value and $00FFFFFF + A);
     
    39574359var
    39584360  n, i: Integer;
    3959   ex, ey, nx, ny, hyp: Integer;
     4361  ex, ey, nx, ny, hyp, hypl: Integer;
    39604362  A: TColor32;
    39614363  h: Single;
     
    39704372    // Check for visibility and clip the coordinates
    39714373    if not ClipLine(Integer(X1), Integer(Y1), Integer(X2), Integer(Y2),
    3972       FFixedClipRect.Left - $10000, FFixedClipRect.Top - $10000,
     4374      FFixedClipRect.Left - $10000,
     4375      FFixedClipRect.Top - $10000,
    39734376      FFixedClipRect.Right, FFixedClipRect.Bottom) then Exit;
    39744377
     
    39884391    end;
    39894392
    3990     // If we are still here, it means that the line touches one or several bitmap
     4393    // if we are still here, it means that the line touches one or several bitmap
    39914394    // boundaries. Use the safe version of antialiased pixel routine
    39924395    try
     
    39944397      Inc(X1, 127); Inc(Y1, 127); Inc(X2, 127); Inc(Y2, 127);
    39954398      hyp := Hypot(nx, ny);
    3996       if L then Inc(Hyp, 65536);
    3997       if hyp < 256 then Exit;
    3998       n := hyp shr 16;
     4399      if hyp = 0 then Exit;
     4400      hypl := hyp + (Integer(L) * FixedOne);
     4401      if hypl < 256 then Exit;
     4402      n := hypl shr 16;
    39994403      if n > 0 then
    40004404      begin
     
    40094413      end;
    40104414      A := Value shr 24;
    4011       hyp := hyp - n shl 16;
    4012       A := A * Longword(hyp) shl 8 and $FF000000;
     4415      hyp := hypl - n shl 16;
     4416      A := A * Cardinal(hyp) shl 8 and $FF000000;
    40134417      SET_TS256(SAR_9(X1 + X2 - nx), SAR_9(Y1 + Y2 - ny), Value and $00FFFFFF + A);
    40144418    finally
     
    40274431var
    40284432  n, i: Integer;
    4029   nx, ny, hyp: Integer;
     4433  nx, ny, hyp, hypl: Integer;
    40304434  A, C: TColor32;
    40314435  ChangedRect: TRect;
     
    40364440    Inc(X1, 127); Inc(Y1, 127); Inc(X2, 127); Inc(Y2, 127);
    40374441    hyp := Hypot(nx, ny);
    4038     if L then Inc(hyp, 65536);
    4039     if hyp < 256 then Exit;
    4040     n := hyp shr 16;
     4442    if hyp = 0 then Exit;
     4443    hypl := hyp + (Integer(L) * FixedOne);
     4444    if hypl < 256 then Exit;
     4445    n := hypl shr 16;
    40414446    if n > 0 then
    40424447    begin
     
    40544459    C := GetStippleColor;
    40554460    A := C shr 24;
    4056     hyp := hyp - n shl 16;
     4461    hyp := hypl - n shl 16;
    40574462    A := A * Longword(hyp) shl 8 and $FF000000;
    40584463    SET_T256((X1 + X2 - nx) shr 9, (Y1 + Y2 - ny) shr 9, C and $00FFFFFF + A);
     
    40704475procedure TCustomBitmap32.LineXSP(X1, Y1, X2, Y2: TFixed; L: Boolean);
    40714476const
    4072   StippleInc: array [Boolean] of Single = (0, 1);
     4477  StippleInc: array [Boolean] of Integer = (0, 1);
    40734478var
    40744479  n, i: Integer;
    4075   sx, sy, ex, ey, nx, ny, hyp: Integer;
     4480  sx, sy, ex, ey, nx, ny, hyp, hypl: Integer;
    40764481  A, C: TColor32;
    40774482  ChangedRect: TRect;
     
    41104515        Integer((Y1 - sy) shr 16)));
    41114516
    4112     // If we are still here, it means that the line touches one or several bitmap
     4517    // if we are still here, it means that the line touches one or several bitmap
    41134518    // boundaries. Use the safe version of antialiased pixel routine
    41144519    nx := X2 - X1; ny := Y2 - Y1;
    41154520    Inc(X1, 127); Inc(Y1, 127); Inc(X2, 127); Inc(Y2, 127);
    41164521    hyp := GR32_Math.Hypot(nx, ny);
    4117     if L then Inc(hyp, 65536);
    4118     if hyp < 256 then Exit;
    4119     n := hyp shr 16;
     4522    if hyp = 0 then Exit;
     4523    hypl := hyp + (Integer(L) * FixedOne);
     4524    if hypl < 256 then Exit;
     4525    n := hypl shr 16;
    41204526    if n > 0 then
    41214527    begin
     
    41324538    C := GetStippleColor;
    41334539    A := C shr 24;
    4134     hyp := hyp - n shl 16;
     4540    hyp := hypl - n shl 16;
    41354541    A := A * Longword(hyp) shl 8 and $FF000000;
    41364542    SET_TS256(SAR_9(X1 + X2 - nx), SAR_9(Y1 + Y2 - ny), C and $00FFFFFF + A);
     
    41994605        CI := EC shr 8;
    42004606        P := @Bits[X1 + Y1 * Width];
    4201         BlendMemEx(Value, P^, GAMMA_TABLE[CI xor 255]);
     4607        BlendMemEx(Value, P^, GAMMA_ENCODING_TABLE[CI xor $FF]);
    42024608        Inc(P, Sx);
    4203         BlendMemEx(Value, P^, GAMMA_TABLE[CI]);
     4609        BlendMemEx(Value, P^, GAMMA_ENCODING_TABLE[CI]);
    42044610      end;
    42054611    end
     
    42174623        CI := EC shr 8;
    42184624        P := @Bits[X1 + Y1 * Width];
    4219         BlendMemEx(Value, P^, GAMMA_TABLE[CI xor 255]);
     4625        BlendMemEx(Value, P^, GAMMA_ENCODING_TABLE[CI xor $FF]);
    42204626        if Sy = 1 then Inc(P, Width) else Dec(P, Width);
    4221         BlendMemEx(Value, P^, GAMMA_TABLE[CI]);
     4627        BlendMemEx(Value, P^, GAMMA_ENCODING_TABLE[CI]);
    42224628      end;
    42234629    end;
     
    42314637var
    42324638  Cx1, Cx2, Cy1, Cy2, PI, Sx, Sy, Dx, Dy, xd, yd, rem, term, tmp: Integer;
    4233   CheckVert, CornerAA, TempClipped: Boolean;
     4639  CheckVert, CornerAA, TermClipped: Boolean;
    42344640  D1, D2: PInteger;
    42354641  EC, EA, ED, D: Word;
     
    43764782          begin
    43774783            Inc(xd, -Sx);
    4378             BlendMemEx(Value, Bits[D1^ + D2^ * Width], GAMMA_TABLE[ED shr 8]);
     4784            BlendMemEx(Value, Bits[D1^ + D2^ * Width], GAMMA_ENCODING_TABLE[ED shr 8]);
    43794785            Dec(ED, EA);
    43804786          end;
     
    43954801        if Sy = -1 then yd := -yd;  // negate back
    43964802        xd := rem;  // restore old xd
    4397         CheckVert := False; // to avoid ugly labels we set this to omit the next check
     4803        CheckVert := False; // to avoid ugly goto we set this to omit the next check
    43984804      end;
    43994805    end;
     
    44134819
    44144820    term := X2;
    4415     TempClipped := False;
     4821    TermClipped := False;
    44164822    CheckVert := False;
    44174823
     
    44364842      end;
    44374843
    4438       TempClipped := True;
     4844      TermClipped := True;
    44394845    end;
    44404846
     
    44424848    begin
    44434849      term := Cx2;
    4444       TempClipped := True;
     4850      TermClipped := True;
    44454851    end;
    44464852
     
    44584864    if not CornerAA then
    44594865    try
    4460       // do we need to skip the last pixel of the line and is temp not clipped?
    4461       if not(L or TempClipped) and not CheckVert then
     4866      // do we need to skip the last pixel of the line and is term not clipped?
     4867      if not(L or TermClipped) and not CheckVert then
    44624868      begin
    44634869        if xd < term then
     
    44674873      end;
    44684874
    4469       Assert(term >= 0);
    44704875      while xd <> term do
    44714876      begin
    44724877        CI := EC shr 8;
    44734878        P := @Bits[D1^ + D2^ * Width];
    4474         BlendMemEx(Value, P^, GAMMA_TABLE[CI xor 255]);
     4879        BlendMemEx(Value, P^, GAMMA_ENCODING_TABLE[CI xor $FF]);
    44754880        Inc(P, PI);
    4476         BlendMemEx(Value, P^, GAMMA_TABLE[CI]);
     4881        BlendMemEx(Value, P^, GAMMA_ENCODING_TABLE[CI]);
    44774882        // check for overflow and jump to next line...
    44784883        D := EC;
     
    44924897      while xd <> rem do
    44934898      begin
    4494         BlendMemEx(Value, Bits[D1^ + D2^ * Width], GAMMA_TABLE[EC shr 8 xor 255]);
     4899        BlendMemEx(Value, Bits[D1^ + D2^ * Width], GAMMA_ENCODING_TABLE[EC shr 8 xor $FF]);
    44954900        Inc(EC, EA);
    44964901        Inc(xd, Sx);
     
    47585163    begin
    47595164      C1 := SetAlpha(clWhite32, Clamp(Contrast * 512 div 100));
    4760       C2 := SetAlpha(clBlack32, Clamp(Contrast * 255 div 100));
     5165      C2 := SetAlpha(clBlack32, Clamp(Contrast * $FF div 100));
    47615166    end
    47625167    else if Contrast < 0 then
    47635168    begin
    47645169      Contrast := -Contrast;
    4765       C1 := SetAlpha(clBlack32, Clamp(Contrast * 255 div 100));
     5170      C1 := SetAlpha(clBlack32, Clamp(Contrast * $FF div 100));
    47665171      C2 := SetAlpha(clWhite32, Clamp(Contrast * 512 div 100));
    47675172    end
     
    48625267    W := Width shl 2;
    48635268    for I := Height - 1 downto 0 do
    4864       Stream.WriteBuffer(PixelPtr[0, I]^, W);
     5269      Stream.WriteBuffer(ScanLine[I]^, W);
    48655270  end
    48665271  else
     
    49915396procedure TCustomBitmap32.ReadData(Stream: TStream);
    49925397var
    4993   w, h: Integer;
     5398  Width, Height: Integer;
    49945399begin
    49955400  try
    4996     Stream.ReadBuffer(w, 4);
    4997     Stream.ReadBuffer(h, 4);
    4998     SetSize(w, h);
     5401    Stream.ReadBuffer(Width, 4);
     5402    Stream.ReadBuffer(Height, 4);
     5403    SetSize(Width, Height);
    49995404    Stream.ReadBuffer(Bits[0], FWidth * FHeight * 4);
    50005405  finally
     
    51015506    OffsetRect(R, Dx, Dy);
    51025507    IntersectRect(R, R, MakeRect(0, 0, Width, Height));
    5103     if R.Top > 0 then FillRect(0, 0, Width, R.Top, FillColor)
    5104     else if R.Top = 0 then FillRect(0, R.Bottom, Width, Height, FillColor);
    5105     if R.Left > 0 then FillRect(0, R.Top, R.Left, R.Bottom, FillColor)
    5106     else if R.Left = 0 then FillRect(R.Right, R.Top, Width, R.Bottom, FillColor);
     5508    if R.Top > 0 then
     5509      FillRect(0, 0, Width, R.Top, FillColor)
     5510    else
     5511    if R.Top = 0 then
     5512      FillRect(0, R.Bottom, Width, Height, FillColor);
     5513    if R.Left > 0 then
     5514      FillRect(0, R.Top, R.Left, R.Bottom, FillColor)
     5515    else
     5516    if R.Left = 0 then
     5517      FillRect(R.Right, R.Top, Width, R.Bottom, FillColor);
    51075518  end;
    51085519
     
    51765587    for J := 0 to Height div 2 - 1 do
    51775588    begin
    5178       P1 := PixelPtr[0, J];
    5179       P2 := PixelPtr[0, J2];
     5589      P1 := PColor32(ScanLine[J]);
     5590      P2 := PColor32(ScanLine[J2]);
    51805591      MoveLongword(P1^, Buffer^, Width);
    51815592      MoveLongword(P2^, P1^, Width);
     
    51925603    for J := 0 to Height - 1 do
    51935604    begin
    5194       MoveLongword(PixelPtr[0, J]^, Dst.PixelPtr[0, J2]^, Width);
     5605      MoveLongword(ScanLine[J]^, Dst.ScanLine[J2]^, Width);
    51955606      Dec(J2);
    51965607    end;
     
    53875798end;
    53885799
    5389 procedure TCustomBitmap32.SetResamplerClassName(Value: string);
     5800procedure TCustomBitmap32.SetResamplerClassName(const Value: string);
    53905801var
    53915802  ResamplerClass: TCustomResamplerClass;
     
    53995810
    54005811{ TBitmap32 }
    5401 
    5402 procedure TBitmap32.InitializeBackend;
    5403 begin
    5404   Backend := GetPlatformBackendClass.Create;
    5405 end;
    54065812
    54075813procedure TBitmap32.FinalizeBackend;
     
    54665872begin
    54675873  Result := (FBackend as IDeviceContextSupport).Handle;
     5874end;
     5875
     5876class function TBitmap32.GetPlatformBackendClass: TCustomBackendClass;
     5877begin
     5878{$IFDEF FPC}
     5879  Result := TLCLBackend;
     5880{$ELSE}
     5881  Result := TGDIBackend;
     5882{$ENDIF}
    54685883end;
    54695884
     
    55675982end;
    55685983
     5984{$IFDEF COMPILER2009_UP}
     5985procedure TBitmap32.DrawTo(Dst: TControlCanvas; DstX, DstY: Integer);
     5986begin
     5987  DrawTo(Dst.Handle, DstX, DstY);
     5988end;
     5989
     5990procedure TBitmap32.DrawTo(Dst: TControlCanvas; const DstRect, SrcRect: TRect);
     5991begin
     5992  DrawTo(Dst.Handle, DstRect, SrcRect);
     5993end;
     5994
     5995procedure TBitmap32.TileTo(Dst: TControlCanvas; const DstRect, SrcRect: TRect);
     5996begin
     5997  TileTo(Dst.Handle, DstRect, SrcRect);
     5998end;
     5999{$ENDIF}
     6000
    55696001procedure TBitmap32.UpdateFont;
    55706002begin
     
    55746006// Text and Fonts //
    55756007
    5576 function TBitmap32.TextExtent(const Text: String): TSize;
     6008function TBitmap32.TextExtent(const Text: string): TSize;
    55776009begin
    55786010  Result := (FBackend as ITextSupport).TextExtent(Text);
     
    55866018// -------------------------------------------------------------------
    55876019
    5588 procedure TBitmap32.Textout(X, Y: Integer; const Text: String);
     6020procedure TBitmap32.Textout(X, Y: Integer; const Text: string);
    55896021begin
    55906022  (FBackend as ITextSupport).Textout(X, Y, Text);
     
    55986030// -------------------------------------------------------------------
    55996031
    5600 procedure TBitmap32.Textout(X, Y: Integer; const ClipRect: TRect; const Text: String);
     6032procedure TBitmap32.Textout(X, Y: Integer; const ClipRect: TRect; const Text: string);
    56016033begin
    56026034  (FBackend as ITextSupport).Textout(X, Y, ClipRect, Text);
     
    56106042// -------------------------------------------------------------------
    56116043
    5612 procedure TBitmap32.Textout(DstRect: TRect; const Flags: Cardinal; const Text: String);
     6044procedure TBitmap32.Textout(var DstRect: TRect; const Flags: Cardinal; const Text: string);
    56136045begin
    56146046  (FBackend as ITextSupport).Textout(DstRect, Flags, Text);
    56156047end;
    56166048
    5617 procedure TBitmap32.TextoutW(DstRect: TRect; const Flags: Cardinal; const Text: Widestring);
     6049procedure TBitmap32.TextoutW(var DstRect: TRect; const Flags: Cardinal; const Text: Widestring);
    56186050begin
    56196051  (FBackend as ITextSupport).TextoutW(DstRect, Flags, Text);
     
    56226054// -------------------------------------------------------------------
    56236055
    5624 function TBitmap32.TextHeight(const Text: String): Integer;
     6056function TBitmap32.TextHeight(const Text: string): Integer;
    56256057begin
    56266058  Result := (FBackend as ITextSupport).TextExtent(Text).cY;
     
    56346066// -------------------------------------------------------------------
    56356067
    5636 function TBitmap32.TextWidth(const Text: String): Integer;
     6068function TBitmap32.TextWidth(const Text: string): Integer;
    56376069begin
    56386070  Result := (FBackend as ITextSupport).TextExtent(Text).cX;
     
    56746106    lfCharSet := Byte(Font.Charset);
    56756107
    5676     // TODO DVT Added cast to fix TFontDataName to String warning. Need to verify is OK
     6108    // TODO DVT Added cast to fix TFontDataName to string warning. Need to verify is OK
    56776109    if AnsiCompareText(Font.Name, 'Default') = 0 then  // do not localize
    56786110      StrPCopy(lfFaceName, string(DefFontData.Name))
     
    57466178begin
    57476179  Sz := 1 shl N - 1;
    5748   Dst := B.PixelPtr[0, 0];
     6180  Dst := PColor32(B.ScanLine[0]);
    57496181  for J := 0 to B.Height - 1 do
    57506182  begin
     
    57706202end;
    57716203
    5772 procedure TBitmap32.RenderText(X, Y: Integer; const Text: String; AALevel: Integer; Color: TColor32);
     6204procedure TBitmap32.RenderText(X, Y: Integer; const Text: string; AALevel: Integer; Color: TColor32);
    57736205var
    57746206  B, B2: TBitmap32;
    57756207  Sz: TSize;
    57766208  Alpha: TColor32;
    5777   PaddedText: String;
     6209  PaddedText: string;
    57786210begin
    57796211  if Empty then Exit;
     
    58356267    DrawMode := dmBlend;
    58366268    MasterAlpha := Alpha;
    5837     CombineMode := Self.CombineMode;
     6269    CombineMode := CombineMode;
    58386270
    58396271    DrawTo(Self, X, Y);
     
    58796311  B := TBitmap32.Create;
    58806312  try
    5881     if AALevel = 0 then
     6313    if AALevel <= 0 then
    58826314    begin
    58836315      Sz := TextExtentW(PaddedText);
     
    59976429{$ENDIF}
    59986430
    5999 procedure TCustomBackend.ChangeSize(var Width, Height: Integer; NewWidth, NewHeight: Integer; ClearBuffer: Boolean);
     6431procedure TCustomBackend.ChangeSize(out Width, Height: Integer; NewWidth, NewHeight: Integer; ClearBuffer: Boolean);
    60006432begin
    60016433  try
Note: See TracChangeset for help on using the changeset viewer.