Changeset 522 for GraphicTest/Packages/Graphics32/GR32.pas
- Timestamp:
- Apr 17, 2019, 10:42:18 AM (5 years ago)
- Location:
- GraphicTest/Packages/Graphics32
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
GraphicTest/Packages/Graphics32
-
Property svn:ignore
set to
lib
-
Property svn:ignore
set to
-
GraphicTest/Packages/Graphics32/GR32.pas
r450 r522 44 44 45 45 uses 46 {$IFDEF FPC} LCLIntf, LCLType, Types, Controls, Graphics,{$ELSE}47 Windows, Messages, Controls, Graphics,{$ENDIF}48 C lasses, 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 50 50 { Version Control } 51 51 52 52 const 53 Graphics32Version = ' 1.9.1';53 Graphics32Version = '2.0.0 alpha'; 54 54 55 55 { 32-bit Color } … … 63 63 TArrayOfColor32 = array of TColor32; 64 64 65 {$IFNDEF RGBA_FORMAT} 65 66 TColor32Component = (ccBlue, ccGreen, ccRed, ccAlpha); 67 {$ELSE} 68 TColor32Component = (ccRed, ccGreen, ccBlue, ccAlpha); 69 {$ENDIF} 66 70 TColor32Components = set of TColor32Component; 67 71 … … 69 73 TColor32Entry = packed record 70 74 case Integer of 75 {$IFNDEF RGBA_FORMAT} 71 76 0: (B, G, R, A: Byte); 77 {$ELSE} 78 0: (R, G, B, A: Byte); 79 {$ENDIF} 72 80 1: (ARGB: TColor32); 73 81 2: (Planes: array[0..3] of Byte); … … 236 244 // Some semi-transparent color constants 237 245 clTrWhite32 = TColor32($7FFFFFFF); 246 clTrGray32 = TColor32($7F7F7F7F); 238 247 clTrBlack32 = TColor32($7F000000); 239 248 clTrRed32 = TColor32($7FFF0000); … … 258 267 function AlphaComponent(Color32: TColor32): Integer; {$IFDEF USEINLINING} inline; {$ENDIF} 259 268 function Intensity(Color32: TColor32): Integer; {$IFDEF USEINLINING} inline; {$ENDIF} 269 function InvertColor(Color32: TColor32): TColor32; {$IFDEF USEINLINING} inline; {$ENDIF} 260 270 function SetAlpha(Color32: TColor32; NewAlpha: Integer): TColor32; {$IFDEF USEINLINING} inline; {$ENDIF} 271 procedure ModifyAlpha(var Color32: TColor32; NewAlpha: Byte); {$IFDEF USEINLINING} inline; {$ENDIF} 272 procedure ScaleAlpha(var Color32: TColor32; Scale: Single); {$IFDEF USEINLINING} inline; {$ENDIF} 261 273 262 274 // Color space conversion 263 275 function HSLtoRGB(H, S, L: Single): TColor32; overload; 264 276 procedure RGBtoHSL(RGB: TColor32; out H, S, L : Single); overload; 265 function HSLtoRGB(H, S, L: Integer ): TColor32; overload;277 function HSLtoRGB(H, S, L: Integer; A: Integer = $ff): TColor32; overload; 266 278 procedure RGBtoHSL(RGB: TColor32; out H, S, L: Byte); overload; 279 function HSVtoRGB(H, S, V: Single): TColor32; 280 procedure RGBToHSV(Color: TColor32; out H, S, V: Single); 267 281 268 282 {$IFNDEF PLATFORM_INDEPENDENT} … … 277 291 PFixed = ^TFixed; 278 292 TFixed = type Integer; 279 293 {$NODEFINE TFixed} 294 295 {$NODEFINE PFixedRec} 280 296 PFixedRec = ^TFixedRec; 297 {$NODEFINE TFixedRec} 281 298 TFixedRec = packed record 282 299 case Integer of … … 315 332 TArrayOfArrayOfInteger = array of TArrayOfInteger; 316 333 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 317 341 PSingleArray = ^TSingleArray; 318 342 TSingleArray = array [0..0] of Single; … … 330 354 FixedHalf = $7FFF; 331 355 FixedPI = Round(PI * FixedOne); 332 FixedToFloat = 1/FixedOne; 356 FixedToFloat = 1 / FixedOne; 357 358 COne255th = 1 / $FF; 333 359 334 360 function Fixed(S: Single): TFixed; overload; {$IFDEF USEINLINING} inline; {$ENDIF} … … 355 381 TFloatPoint = record 356 382 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} 357 406 end; 358 407 … … 367 416 TFixedPoint = record 368 417 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} 370 440 371 441 PFixedPointArray = ^TFixedPointArray; … … 397 467 398 468 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 '*) 399 483 TFloatRect = packed record 400 484 case Integer of … … 403 487 end; 404 488 489 {$NODEFINE PFixedRect} 405 490 PFixedRect = ^TFixedRect; 491 {$NODEFINE TFixedRect} 406 492 TFixedRect = packed record 407 493 case Integer of … … 417 503 function MakeRect(const FXR: TFixedRect; Rounding: TRectRounding = rrClosest): TRect; overload; 418 504 function FixedRect(const L, T, R, B: TFixed): TFixedRect; overload; {$IFDEF USEINLINING} inline; {$ENDIF} 505 function FixedRect(const TopLeft, BottomRight: TFixedPoint): TFixedRect; overload; {$IFDEF USEINLINING} inline; {$ENDIF} 419 506 function FixedRect(const ARect: TRect): TFixedRect; overload; {$IFDEF USEINLINING} inline; {$ENDIF} 420 507 function FixedRect(const FR: TFloatRect): TFixedRect; overload; {$IFDEF USEINLINING} inline; {$ENDIF} 421 508 function FloatRect(const L, T, R, B: TFloat): TFloatRect; overload; {$IFDEF USEINLINING} inline; {$ENDIF} 509 function FloatRect(const TopLeft, BottomRight: TFloatPoint): TFloatRect; overload; {$IFDEF USEINLINING} inline; {$ENDIF} 422 510 function FloatRect(const ARect: TRect): TFloatRect; overload; {$IFDEF USEINLINING} inline; {$ENDIF} 423 511 function FloatRect(const FXR: TFixedRect): TFloatRect; overload; {$IFDEF USEINLINING} inline; {$ENDIF} … … 458 546 {$ENDIF} 459 547 460 { Gamma bias for line/pixel antialiasing }461 462 var463 GAMMA_TABLE: array [Byte] of Byte;464 465 procedure SetGamma(Gamma: Single = 0.7);466 467 548 type 468 549 { TPlainInterfacedPersistent } … … 475 556 protected 476 557 { 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} 481 567 property RefCounted: Boolean read FRefCounted write FRefCounted; 482 568 public … … 535 621 procedure ChangeSize(var Width, Height: Integer; NewWidth, NewHeight: Integer); virtual; 536 622 public 623 constructor Create(Width, Height: Integer); reintroduce; overload; 624 537 625 procedure Delete; virtual; 538 626 function Empty: Boolean; virtual; … … 540 628 function SetSizeFrom(Source: TPersistent): Boolean; 541 629 function SetSize(NewWidth, NewHeight: Integer): Boolean; virtual; 630 542 631 property Height: Integer read FHeight write SetHeight; 543 632 property Width: Integer read FWidth write SetWidth; … … 602 691 603 692 {$IFDEF BITS_GETTER} 604 function GetBits: PColor32Array; 693 function GetBits: PColor32Array; {$IFDEF USEINLINING} inline; {$ENDIF} 605 694 {$ENDIF} 606 695 … … 618 707 procedure SetResampler(Resampler: TCustomResampler); 619 708 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); 621 714 protected 622 715 WrapProcHorz: TWrapProcEx; … … 638 731 procedure DefineProperties(Filer: TFiler); override; 639 732 640 procedure InitializeBackend ; virtual;733 procedure InitializeBackend(Backend: TCustomBackendClass); virtual; 641 734 procedure FinalizeBackend; virtual; 642 735 procedure SetBackend(const Backend: TCustomBackend); virtual; 643 736 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} 645 742 646 743 function GetPixel(X, Y: Integer): TColor32; {$IFDEF USEINLINING} inline; {$ENDIF} … … 673 770 procedure SetPixelXW(X, Y: TFixed; Value: TColor32); 674 771 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; 676 775 destructor Destroy; override; 776 777 class function GetPlatformBackendClass: TCustomBackendClass; virtual; 677 778 678 779 procedure Assign(Source: TPersistent); override; … … 713 814 714 815 procedure DrawTo(Dst: TCustomBitmap32); overload; 816 procedure DrawTo(Dst: TCustomBitmap32; DstX, DstY: Integer); overload; 715 817 procedure DrawTo(Dst: TCustomBitmap32; DstX, DstY: Integer; const SrcRect: TRect); overload; 716 procedure DrawTo(Dst: TCustomBitmap32; DstX, DstY: Integer); overload;717 818 procedure DrawTo(Dst: TCustomBitmap32; const DstRect: TRect); overload; 718 819 procedure DrawTo(Dst: TCustomBitmap32; const DstRect, SrcRect: TRect); overload; … … 765 866 procedure LineToXSP(X, Y: TFixed); 766 867 procedure LineToFSP(X, Y: Single); 868 property PenPos: TPoint read GetPenPos write SetPenPos; 869 property PenPosF: TFixedPoint read GetPenPosF write SetPenPosF; 767 870 768 871 procedure FillRect(X1, Y1, X2, Y2: Integer; Value: TColor32); … … 840 943 private 841 944 FOnHandleChanged: TNotifyEvent; 842 945 843 946 procedure BackendChangedHandler(Sender: TObject); override; 844 947 procedure BackendChangingHandler(Sender: TObject); override; … … 855 958 procedure SetFont(Value: TFont); 856 959 protected 857 procedure InitializeBackend; override;858 960 procedure FinalizeBackend; override; 859 961 procedure SetBackend(const Backend: TCustomBackend); override; 860 962 861 963 procedure HandleChanged; virtual; 862 964 procedure CopyPropertiesTo(Dst: TCustomBitmap32); override; 863 965 public 966 class function GetPlatformBackendClass: TCustomBackendClass; override; 967 864 968 {$IFDEF BCB} 865 969 procedure Draw(const DstRect, SrcRect: TRect; hSrc: Cardinal); overload; … … 871 975 procedure DrawTo(hDst: Cardinal; DstX, DstY: Integer); overload; 872 976 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; 874 978 {$ELSE} 875 procedure DrawTo(hDst: HDC; DstX , DstY: Integer); overload;979 procedure DrawTo(hDst: HDC; DstX: Integer = 0; DstY: Integer = 0); overload; 876 980 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; 878 982 {$ENDIF} 879 983 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 880 990 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); 888 998 procedure TextoutW(X, Y: Integer; const Text: Widestring); overload; 889 999 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; 891 1001 function TextExtentW(const Text: Widestring): TSize; 892 1002 function TextHeightW(const Text: Widestring): Integer; … … 936 1046 function Empty: Boolean; virtual; 937 1047 938 procedure ChangeSize( varWidth, Height: Integer; NewWidth, NewHeight: Integer; ClearBuffer: Boolean = True); virtual;1048 procedure ChangeSize(out Width, Height: Integer; NewWidth, NewHeight: Integer; ClearBuffer: Boolean = True); virtual; 939 1049 940 1050 {$IFDEF BITS_GETTER} … … 992 1102 TCustomResamplerClass = class of TCustomResampler; 993 1103 994 function GetPlatformBackendClass: TCustomBackendClass;995 996 1104 var 997 1105 StockBitmap: TBitmap; 998 1106 1107 resourcestring 1108 RCStrUnmatchedReferenceCounting = 'Unmatched reference counting.'; 1109 RCStrCannotSetSize = 'Can''t set size from ''%s'''; 1110 RCStrInpropriateBackend = 'Inappropriate Backend'; 1111 999 1112 implementation 1000 1113 1001 1114 uses 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, 1004 1117 {$IFDEF FPC} 1005 1118 Clipbrd, … … 1019 1132 Clipbrd, GR32_Backends_VCL, 1020 1133 {$ENDIF} 1021 GR32_ DrawingEx;1134 GR32_VectorUtils; 1022 1135 1023 1136 type … … 1045 1158 const 1046 1159 ZERO_RECT: TRect = (Left: 0; Top: 0; Right: 0; Bottom: 0); 1047 1048 resourcestring1049 RCStrUnmatchedReferenceCounting = 'Unmatched reference counting.';1050 RCStrCannotSetSize = 'Can''t set size from ''%s''';1051 RCStrInpropriateBackend = 'Inpropriate Backend';1052 1160 1053 1161 { Color construction and conversion functions } … … 1128 1236 {$ENDIF} 1129 1237 // the alpha channel byte is set to zero! 1130 ROL EAX, 8 // ABGR -> BGRA1238 ROL EAX, 8 // ABGR -> RGBA 1131 1239 XOR AL, AL // BGRA -> BGR0 1132 1240 BSWAP EAX // BGR0 -> 0RGB … … 1199 1307 end; 1200 1308 1309 function InvertColor(Color32: TColor32): TColor32; 1310 begin 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; 1315 end; 1316 1201 1317 function SetAlpha(Color32: TColor32; NewAlpha: Integer): TColor32; 1202 1318 begin 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; 1205 1323 Result := (Color32 and $00FFFFFF) or (TColor32(NewAlpha) shl 24); 1324 end; 1325 1326 procedure ModifyAlpha(var Color32: TColor32; NewAlpha: Byte); 1327 begin 1328 TColor32Entry(Color32).A := NewAlpha; 1329 end; 1330 1331 procedure ScaleAlpha(var Color32: TColor32; Scale: Single); 1332 begin 1333 TColor32Entry(Color32).A := Round(Scale * TColor32Entry(Color32).A); 1206 1334 end; 1207 1335 … … 1213 1341 var 1214 1342 M1, M2: Single; 1215 R, G, B: Byte;1216 1343 1217 1344 function HueToColor(Hue: Single): Byte; … … 1220 1347 begin 1221 1348 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 1225 1355 else V := M1; 1226 Result := Round( 255* V);1356 Result := Round($FF * V); 1227 1357 end; 1228 1358 … … 1230 1360 if S = 0 then 1231 1361 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) 1236 1368 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)); 1246 1375 end; 1247 1376 … … 1249 1378 const 1250 1379 // reciprocal mul. opt. 1251 R255 = 1 / 255;1252 1380 R6 = 1 / 6; 1253 1381 … … 1255 1383 R, G, B, D, Cmax, Cmin: Single; 1256 1384 begin 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; 1260 1388 Cmax := Max(R, Max(G, B)); 1261 1389 Cmin := Min(R, Min(G, B)); … … 1288 1416 end; 1289 1417 1290 function HSLtoRGB(H, S, L : Integer): TColor32;1418 function HSLtoRGB(H, S, L, A: Integer): TColor32; 1291 1419 var 1292 1420 V, M, M1, M2, VSF: Integer; … … 1306 1434 M2 := V - VSF; 1307 1435 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); 1314 1442 else 1315 1443 Result := 0; … … 1337 1465 else 1338 1466 begin 1339 D := (Cmax - Cmin) * 255;1467 D := (Cmax - Cmin) * $FF; 1340 1468 if L <= $7F then 1341 1469 S := D div (Cmax + Cmin) 1342 1470 else 1343 S := D div ( 255* 2 - Cmax - Cmin);1471 S := D div ($FF * 2 - Cmax - Cmin); 1344 1472 1345 1473 D := D * 6; 1346 1474 if R = Cmax then 1347 HL := (G - B) * 255 * 255div D1475 HL := (G - B) * $FF * $FF div D 1348 1476 else if G = Cmax then 1349 HL := 255 * 2 div 6 + (B - R) * 255 * 255div D1477 HL := $FF * 2 div 6 + (B - R) * $FF * $FF div D 1350 1478 else 1351 HL := 255 * 4 div 6 + (R - G) * 255 * 255div 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; 1354 1482 H := HL; 1483 end; 1484 end; 1485 1486 function HSVtoRGB(H, S, V: Single): TColor32; 1487 var 1488 Tmp: TFloat; 1489 Sel, Q, P: Integer; 1490 begin 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; 1524 end; 1525 1526 procedure RGBToHSV(Color: TColor32; out H, S, V: Single); 1527 var 1528 Delta, Min, Max: Single; 1529 R, G, B: Integer; 1530 const 1531 COneSixth = 1 / 6; 1532 begin 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; 1355 1560 end; 1356 1561 end; … … 1367 1572 L.palVersion := $300; 1368 1573 L.palNumEntries := 256; 1369 for I := 0 to 255do1574 for I := 0 to $FF do 1370 1575 begin 1371 1576 Cl := P[I]; … … 1386 1591 function Fixed(S: Single): TFixed; 1387 1592 begin 1388 Result := Round(S * 65536);1593 Result := Round(S * FixedOne); 1389 1594 end; 1390 1595 … … 1428 1633 1429 1634 function FloatPoint(const FXP: TFixedPoint): TFloatPoint; 1430 const1431 F = 1 / 65536;1432 1635 begin 1433 1636 with FXP do 1434 1637 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; 1641 end; 1642 1643 {$IFDEF SUPPORT_ENHANCED_RECORDS} 1644 {$IFNDEF FPC} 1645 constructor TFloatPoint.Create(P: TPoint); 1646 begin 1647 Self.X := P.X; 1648 Self.Y := P.Y; 1649 end; 1650 1651 {$IFDEF COMPILERXE2_UP} 1652 constructor TFloatPoint.Create(P: TPointF); 1653 begin 1654 Self.X := P.X; 1655 Self.Y := P.Y; 1656 end; 1657 {$ENDIF} 1658 1659 constructor TFloatPoint.Create(X, Y: Integer); 1660 begin 1661 Self.X := X; 1662 Self.Y := Y; 1663 end; 1664 1665 constructor TFloatPoint.Create(X, Y: TFloat); 1666 begin 1667 Self.X := X; 1668 Self.Y := Y; 1669 end; 1670 {$ENDIF} 1671 1672 // operator overloads 1673 class operator TFloatPoint.Equal(const Lhs, Rhs: TFloatPoint): Boolean; 1674 begin 1675 Result := (Lhs.X = Rhs.X) and (Lhs.Y = Rhs.Y); 1676 end; 1677 1678 class operator TFloatPoint.NotEqual(const Lhs, Rhs: TFloatPoint): Boolean; 1679 begin 1680 Result := (Lhs.X <> Rhs.X) or (Lhs.Y <> Rhs.Y); 1681 end; 1682 1683 class operator TFloatPoint.Add(const Lhs, Rhs: TFloatPoint): TFloatPoint; 1684 begin 1685 Result.X := Lhs.X + Rhs.X; 1686 Result.Y := Lhs.Y + Rhs.Y; 1687 end; 1688 1689 class operator TFloatPoint.Subtract(const Lhs, Rhs: TFloatPoint): TFloatPoint; 1690 begin 1691 Result.X := Lhs.X - Rhs.X; 1692 Result.Y := Lhs.Y - Rhs.Y; 1693 end; 1694 1695 {$IFDEF COMPILERXE2_UP} 1696 class operator TFloatPoint.Explicit(A: TPointF): TFloatPoint; 1697 begin 1698 Result.X := A.X; 1699 Result.Y := A.Y; 1700 end; 1701 1702 class operator TFloatPoint.Implicit(A: TPointF): TFloatPoint; 1703 begin 1704 Result.X := A.X; 1705 Result.Y := A.Y; 1706 end; 1707 {$ENDIF} 1708 1709 class function TFloatPoint.Zero: TFloatPoint; 1710 begin 1711 Result.X := 0; 1712 Result.Y := 0; 1713 end; 1714 1715 {$IFNDEF FPC} 1716 {$IFDEF COMPILERXE2_UP} 1717 constructor TFixedPoint.Create(P: TPointF); 1718 begin 1719 Self.X := Fixed(P.X); 1720 Self.Y := Fixed(P.Y); 1721 end; 1722 {$ENDIF} 1723 1724 constructor TFixedPoint.Create(P: TFloatPoint); 1725 begin 1726 Self.X := Fixed(P.X); 1727 Self.Y := Fixed(P.Y); 1728 end; 1729 1730 constructor TFixedPoint.Create(X, Y: TFixed); 1731 begin 1732 Self.X := X; 1733 Self.Y := Y; 1734 end; 1735 1736 constructor TFixedPoint.Create(X, Y: Integer); 1737 begin 1738 Self.X := Fixed(X); 1739 Self.Y := Fixed(Y); 1740 end; 1741 1742 constructor TFixedPoint.Create(X, Y: TFloat); 1743 begin 1744 Self.X := Fixed(X); 1745 Self.Y := Fixed(Y); 1746 end; 1747 {$ENDIF} 1748 1749 // operator overloads 1750 class operator TFixedPoint.Equal(const Lhs, Rhs: TFixedPoint): Boolean; 1751 begin 1752 Result := (Lhs.X = Rhs.X) and (Lhs.Y = Rhs.Y); 1753 end; 1754 1755 class operator TFixedPoint.NotEqual(const Lhs, Rhs: TFixedPoint): Boolean; 1756 begin 1757 Result := (Lhs.X <> Rhs.X) or (Lhs.Y <> Rhs.Y); 1758 end; 1759 1760 class operator TFixedPoint.Add(const Lhs, Rhs: TFixedPoint): TFixedPoint; 1761 begin 1762 Result.X := Lhs.X + Rhs.X; 1763 Result.Y := Lhs.Y + Rhs.Y; 1764 end; 1765 1766 class operator TFixedPoint.Subtract(const Lhs, Rhs: TFixedPoint): TFixedPoint; 1767 begin 1768 Result.X := Lhs.X - Rhs.X; 1769 Result.Y := Lhs.Y - Rhs.Y; 1770 end; 1771 1772 class function TFixedPoint.Zero: TFixedPoint; 1773 begin 1774 Result.X := 0; 1775 Result.Y := 0; 1776 end; 1777 {$ENDIF} 1439 1778 1440 1779 function FixedPoint(X, Y: Integer): TFixedPoint; overload; … … 1446 1785 function FixedPoint(X, Y: Single): TFixedPoint; overload; 1447 1786 begin 1448 Result.X := Round(X * 65536);1449 Result.Y := Round(Y * 65536);1787 Result.X := Round(X * FixedOne); 1788 Result.Y := Round(Y * FixedOne); 1450 1789 end; 1451 1790 … … 1458 1797 function FixedPoint(const FP: TFloatPoint): TFixedPoint; overload; 1459 1798 begin 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); 1462 1801 end; 1463 1802 … … 1551 1890 end; 1552 1891 1892 function FixedRect(const TopLeft, BottomRight: TFixedPoint): TFixedRect; 1893 begin 1894 Result.TopLeft := TopLeft; 1895 Result.BottomRight := BottomRight; 1896 end; 1897 1553 1898 function FixedRect(const ARect: TRect): TFixedRect; 1554 1899 begin … … 1582 1927 Bottom := B; 1583 1928 end; 1929 end; 1930 1931 function FloatRect(const TopLeft, BottomRight: TFloatPoint): TFloatRect; 1932 begin 1933 Result.TopLeft := TopLeft; 1934 Result.BottomRight := BottomRight; 1584 1935 end; 1585 1936 … … 1745 2096 end; 1746 2097 1747 { Gamma / Pixel Shape Correction table }1748 1749 procedure SetGamma(Gamma: Single);1750 var1751 i: Integer;1752 begin1753 for i := 0 to 255 do1754 GAMMA_TABLE[i] := Round(255 * Power(i / 255, Gamma));1755 end;1756 1757 function GetPlatformBackendClass: TCustomBackendClass;1758 begin1759 {$IFDEF FPC}1760 Result := TLCLBackend;1761 {$ELSE}1762 Result := TGDIBackend;1763 {$ENDIF}1764 end;1765 1766 2098 { TSimpleInterfacedPersistent } 1767 2099 … … 1869 2201 1870 2202 { TCustomMap } 2203 2204 constructor TCustomMap.Create(Width, Height: Integer); 2205 begin 2206 Create; 2207 SetSize(Width, Height); 2208 end; 1871 2209 1872 2210 procedure TCustomMap.ChangeSize(var Width, Height: Integer; NewWidth, NewHeight: Integer); … … 1931 2269 { TCustomBitmap32 } 1932 2270 1933 constructor TCustomBitmap32.Create ;1934 begin 1935 inherited ;1936 1937 InitializeBackend ;2271 constructor TCustomBitmap32.Create(Backend: TCustomBackendClass); 2272 begin 2273 inherited Create; 2274 2275 InitializeBackend(Backend); 1938 2276 1939 2277 FOuterColor := $00000000; // by default as full transparency black … … 1949 2287 end; 1950 2288 2289 constructor TCustomBitmap32.Create; 2290 begin 2291 Create(GetPlatformBackendClass); 2292 end; 2293 1951 2294 destructor TCustomBitmap32.Destroy; 1952 2295 begin … … 1963 2306 end; 1964 2307 1965 procedure TCustomBitmap32.InitializeBackend ;1966 begin 1967 TMemoryBackend.Create(Self);2308 procedure TCustomBitmap32.InitializeBackend(Backend: TCustomBackendClass); 2309 begin 2310 Backend.Create(Self); 1968 2311 end; 1969 2312 … … 1988 2331 http://qc.codegear.com/wc/qcmain.aspx?d=9500 1989 2332 1990 If any backend interface is used within the same procedure in which2333 if any backend interface is used within the same procedure in which 1991 2334 the owner bitmap is also freed, the magic procedure cleanup will 1992 2335 clear that particular interface long after the bitmap and its backend … … 2239 2582 // this checks for transparency by comparing the pixel-color of the 2240 2583 // temporary bitmap (red masked) with the pixel of our 2241 // bitmap (white masked). If they match, make that pixel opaque2584 // bitmap (white masked). if they match, make that pixel opaque 2242 2585 if DstColor = (SrcP^ and $00FFFFFF) then 2243 2586 DstP^ := DstColor or $FF000000 … … 2292 2635 2293 2636 // Check if the icon was painted with a merged alpha channel. 2294 // Th ehappens transparently for new-style 32-bit icons.2637 // That happens transparently for new-style 32-bit icons. 2295 2638 // For all other bit depths GDI will reset our alpha channel to opaque. 2296 2639 ReassignFromMasked := True; … … 2320 2663 else if SrcGraphic is TMetaFile then 2321 2664 AssignFromGraphicMasked(TargetBitmap, SrcGraphic) 2665 {$IFDEF COMPILER2005_UP} 2666 else if SrcGraphic is TWICImage then 2667 AssignFromGraphicPlain(TargetBitmap, SrcGraphic, 0, False) 2668 {$ENDIF} 2322 2669 {$ENDIF} 2323 2670 else … … 2385 2732 end; 2386 2733 2734 constructor TCustomBitmap32.Create(Width, Height: Integer); 2735 begin 2736 Create; 2737 SetSize(Width, Height); 2738 end; 2739 2387 2740 {$IFDEF BITS_GETTER} 2388 2741 function TCustomBitmap32.GetBits: PColor32Array; … … 2391 2744 end; 2392 2745 {$ENDIF} 2746 2747 procedure TCustomBitmap32.SetPenPos(const Value: TPoint); 2748 begin 2749 MoveTo(Value.X, Value.Y); 2750 end; 2751 2752 procedure TCustomBitmap32.SetPenPosF(const Value: TFixedPoint); 2753 begin 2754 MoveTo(Value.X, Value.Y); 2755 end; 2393 2756 2394 2757 procedure TCustomBitmap32.SetPixel(X, Y: Integer; Value: TColor32); … … 2412 2775 begin 2413 2776 Result := @Bits[Y * FWidth]; 2777 end; 2778 2779 function TCustomBitmap32.GetPenPos: TPoint; 2780 begin 2781 Result.X := RasterX; 2782 Result.Y := RasterY; 2783 end; 2784 2785 function TCustomBitmap32.GetPenPosF: TFixedPoint; 2786 begin 2787 Result.X := RasterXF; 2788 Result.Y := RasterYF; 2414 2789 end; 2415 2790 … … 2438 2813 end; 2439 2814 2440 procedure TCustomBitmap32.Draw(DstX, DstY: Integer; const SrcRect: TRect; Src: TCustomBitmap32); 2815 procedure TCustomBitmap32.Draw(DstX, DstY: Integer; const SrcRect: TRect; 2816 Src: TCustomBitmap32); 2441 2817 begin 2442 2818 if Assigned(Src) then Src.DrawTo(Self, DstX, DstY, SrcRect); … … 2450 2826 procedure TCustomBitmap32.DrawTo(Dst: TCustomBitmap32); 2451 2827 begin 2452 BlockTransfer(Dst, 0, 0, Dst.ClipRect, Self, BoundsRect, DrawMode, FOnPixelCombine); 2828 BlockTransfer(Dst, 0, 0, Dst.ClipRect, Self, BoundsRect, DrawMode, 2829 FOnPixelCombine); 2453 2830 end; 2454 2831 2455 2832 procedure TCustomBitmap32.DrawTo(Dst: TCustomBitmap32; DstX, DstY: Integer); 2456 2833 begin 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); 2836 end; 2837 2838 procedure TCustomBitmap32.DrawTo(Dst: TCustomBitmap32; DstX, DstY: Integer; 2839 const SrcRect: TRect); 2840 begin 2841 BlockTransfer(Dst, DstX, DstY, Dst.ClipRect, Self, SrcRect, 2842 DrawMode, FOnPixelCombine); 2463 2843 end; 2464 2844 2465 2845 procedure TCustomBitmap32.DrawTo(Dst: TCustomBitmap32; const DstRect: TRect); 2466 2846 begin 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); 2849 end; 2850 2851 procedure TCustomBitmap32.DrawTo(Dst: TCustomBitmap32; const DstRect, 2852 SrcRect: TRect); 2853 begin 2854 StretchTransfer(Dst, DstRect, Dst.ClipRect, Self, SrcRect, Resampler, 2855 DrawMode, FOnPixelCombine); 2473 2856 end; 2474 2857 … … 2610 2993 begin 2611 2994 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]; 2616 2999 2617 3000 CombineMem(C, P^, celx * cely shr 16); Inc(P); … … 2622 3005 else 2623 3006 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 2629 3012 CombineMem(MergeReg(C, P^), P^, celx * cely shr 8); Inc(P); 2630 3013 CombineMem(MergeReg(C, P^), P^, flrx * cely shr 8); Inc(P, FWidth); … … 2663 3046 begin 2664 3047 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]; 2669 3052 2670 3053 if (X >= FClipRect.Left) and (Y >= FClipRect.Top) and … … 2687 3070 else 2688 3071 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]; 2693 3076 2694 3077 if (X >= FClipRect.Left) and (Y >= FClipRect.Top) and … … 2789 3172 begin 2790 3173 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], 2793 3176 @Bits[Pos], @Bits[Pos + FWidth]); 2794 3177 end; … … 2861 3244 {$ELSE} 2862 3245 asm 3246 {$IFDEF TARGET_x64} 3247 PUSH RBP 3248 SUB RSP,$30 3249 {$ENDIF} 2863 3250 ADD X, $7F 2864 3251 ADD Y, $7F … … 2873 3260 {$ENDIF} 2874 3261 3262 {$IFDEF TARGET_x64} 3263 LEA RSP,[RBP+$30] 3264 POP RBP 3265 {$ENDIF} 3266 2875 3267 {$ENDIF} 2876 3268 end; … … 2922 3314 WordRec(TFixedRec(Y).Frac).Hi); 2923 3315 EMMS; 3316 end; 3317 3318 class function TCustomBitmap32.GetPlatformBackendClass: TCustomBackendClass; 3319 begin 3320 Result := TMemoryBackend; 2924 3321 end; 2925 3322 … … 2986 3383 end; 2987 3384 FStippleCounter := Wrap(FStippleCounter, L); 3385 {$IFDEF FPC} 3386 PrevIndex := Trunc(FStippleCounter); 3387 {$ELSE} 2988 3388 PrevIndex := Round(FStippleCounter - 0.5); 2989 PrevWeight := 255 - Round(255 * (FStippleCounter - PrevIndex)); 3389 {$ENDIF} 3390 PrevWeight := $FF - Round($FF * (FStippleCounter - PrevIndex)); 2990 3391 if PrevIndex < 0 then FStippleCounter := L - 1; 2991 3392 NextIndex := PrevIndex + 1; 2992 3393 if NextIndex >= L then NextIndex := 0; 2993 if PrevWeight = 255then Result := FStipplePattern[PrevIndex]3394 if PrevWeight = $FF then Result := FStipplePattern[PrevIndex] 2994 3395 else 2995 3396 begin … … 3128 3529 if Wy > 0 then 3129 3530 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]; 3132 3533 Inc(PDst); 3133 3534 for I := 0 to Count - 1 do … … 3136 3537 Inc(PDst); 3137 3538 end; 3138 CombineMem(Value, PDst^, GAMMA_ TABLE[(Wy * Wx2) shr 24]);3539 CombineMem(Value, PDst^, GAMMA_ENCODING_TABLE[(Wy * Wx2) shr 24]); 3139 3540 end; 3140 3541 … … 3144 3545 if Wy > 0 then 3145 3546 begin 3146 CombineMem(Value, PDst^, GAMMA_ TABLE[(Wy * Wx1) shr 24]);3547 CombineMem(Value, PDst^, GAMMA_ENCODING_TABLE[(Wy * Wx1) shr 24]); 3147 3548 Inc(PDst); 3148 Wt := GAMMA_ TABLE[Wy shr 8];3549 Wt := GAMMA_ENCODING_TABLE[Wy shr 8]; 3149 3550 for I := 0 to Count - 1 do 3150 3551 begin … … 3152 3553 Inc(PDst); 3153 3554 end; 3154 CombineMem(Value, PDst^, GAMMA_ TABLE[(Wy * Wx2) shr 24]);3555 CombineMem(Value, PDst^, GAMMA_ENCODING_TABLE[(Wy * Wx2) shr 24]); 3155 3556 end; 3156 3557 … … 3322 3723 if Wx > 0 then 3323 3724 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]; 3326 3727 Inc(PDst, FWidth); 3327 3728 for I := 0 to Count - 1 do … … 3330 3731 Inc(PDst, FWidth); 3331 3732 end; 3332 CombineMem(Value, PDst^, GAMMA_ TABLE[(Wx * Wy2) shr 24]);3733 CombineMem(Value, PDst^, GAMMA_ENCODING_TABLE[(Wx * Wy2) shr 24]); 3333 3734 end; 3334 3735 … … 3338 3739 if Wx > 0 then 3339 3740 begin 3340 CombineMem(Value, PDst^, GAMMA_ TABLE[(Wx * Wy1) shr 24]);3741 CombineMem(Value, PDst^, GAMMA_ENCODING_TABLE[(Wx * Wy1) shr 24]); 3341 3742 Inc(PDst, FWidth); 3342 Wt := GAMMA_ TABLE[Wx shr 8];3743 Wt := GAMMA_ENCODING_TABLE[Wx shr 8]; 3343 3744 for I := 0 to Count - 1 do 3344 3745 begin … … 3346 3747 Inc(PDst, FWidth); 3347 3748 end; 3348 CombineMem(Value, PDst^, GAMMA_ TABLE[(Wx * Wy2) shr 24]);3749 CombineMem(Value, PDst^, GAMMA_ENCODING_TABLE[(Wx * Wy2) shr 24]); 3349 3750 end; 3350 3751 … … 3545 3946 Inc(e, Dy2); 3546 3947 end; 3547 CheckAux := False; // to avoid ugly labelswe set this to omit the next check3948 CheckAux := False; // to avoid ugly goto we set this to omit the next check 3548 3949 end; 3549 3950 end; … … 3565 3966 end; 3566 3967 3567 // set auxiliary var to indicate that te mpis not clipped, since3568 // te mpstill 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. 3569 3970 CheckAux := False; 3570 3971 … … 3572 3973 if Y2 > Cy2 then 3573 3974 begin 3574 OC := Dx2* (Cy2 - Y1) + Dx;3975 OC := Int64(Dx2) * (Cy2 - Y1) + Dx; 3575 3976 term := X1 + OC div Dy2; 3576 3977 rem := OC mod Dy2; 3577 3978 if rem = 0 then Dec(term); 3578 CheckAux := True; // set auxiliary var to indicate that te mpis clipped3979 CheckAux := True; // set auxiliary var to indicate that term is clipped 3579 3980 end; 3580 3981 … … 3582 3983 begin 3583 3984 term := Cx2; 3584 CheckAux := True; // set auxiliary var to indicate that te mpis clipped3985 CheckAux := True; // set auxiliary var to indicate that term is clipped 3585 3986 end; 3586 3987 … … 3610 4011 end; 3611 4012 3612 // do we need to skip the last pixel of the line and is te mpnot clipped?4013 // do we need to skip the last pixel of the line and is term not clipped? 3613 4014 if not(L or CheckAux) then 3614 4015 begin … … 3814 4215 Inc(e, Dy2); 3815 4216 end; 3816 CheckAux := False; // to avoid ugly labelswe set this to omit the next check4217 CheckAux := False; // to avoid ugly goto we set this to omit the next check 3817 4218 end; 3818 4219 end; … … 3834 4235 end; 3835 4236 3836 // set auxiliary var to indicate that te mpis not clipped, since3837 // te mpstill 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. 3838 4239 CheckAux := False; 3839 4240 … … 3845 4246 rem := OC mod Dy2; 3846 4247 if rem = 0 then Dec(term); 3847 CheckAux := True; // set auxiliary var to indicate that te mpis clipped4248 CheckAux := True; // set auxiliary var to indicate that term is clipped 3848 4249 end; 3849 4250 … … 3851 4252 begin 3852 4253 term := Cx2; 3853 CheckAux := True; // set auxiliary var to indicate that te mpis clipped4254 CheckAux := True; // set auxiliary var to indicate that term is clipped 3854 4255 end; 3855 4256 … … 3879 4280 end; 3880 4281 3881 // do we need to skip the last pixel of the line and is te mpnot clipped?4282 // do we need to skip the last pixel of the line and is term not clipped? 3882 4283 if not(L or CheckAux) then 3883 4284 begin … … 3915 4316 var 3916 4317 n, i: Integer; 3917 nx, ny, hyp : Integer;4318 nx, ny, hyp, hypl: Integer; 3918 4319 A: TColor32; 3919 4320 h: Single; … … 3925 4326 Inc(X1, 127); Inc(Y1, 127); Inc(X2, 127); Inc(Y2, 127); 3926 4327 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; 3930 4332 if n > 0 then 3931 4333 begin … … 3940 4342 end; 3941 4343 A := Value shr 24; 3942 hyp := hyp - n shl 16;4344 hyp := hypl - n shl 16; 3943 4345 A := A * Cardinal(hyp) shl 8 and $FF000000; 3944 4346 SET_T256((X1 + X2 - nx) shr 9, (Y1 + Y2 - ny) shr 9, Value and $00FFFFFF + A); … … 3957 4359 var 3958 4360 n, i: Integer; 3959 ex, ey, nx, ny, hyp : Integer;4361 ex, ey, nx, ny, hyp, hypl: Integer; 3960 4362 A: TColor32; 3961 4363 h: Single; … … 3970 4372 // Check for visibility and clip the coordinates 3971 4373 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, 3973 4376 FFixedClipRect.Right, FFixedClipRect.Bottom) then Exit; 3974 4377 … … 3988 4391 end; 3989 4392 3990 // If we are still here, it means that the line touches one or several bitmap4393 // if we are still here, it means that the line touches one or several bitmap 3991 4394 // boundaries. Use the safe version of antialiased pixel routine 3992 4395 try … … 3994 4397 Inc(X1, 127); Inc(Y1, 127); Inc(X2, 127); Inc(Y2, 127); 3995 4398 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; 3999 4403 if n > 0 then 4000 4404 begin … … 4009 4413 end; 4010 4414 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; 4013 4417 SET_TS256(SAR_9(X1 + X2 - nx), SAR_9(Y1 + Y2 - ny), Value and $00FFFFFF + A); 4014 4418 finally … … 4027 4431 var 4028 4432 n, i: Integer; 4029 nx, ny, hyp : Integer;4433 nx, ny, hyp, hypl: Integer; 4030 4434 A, C: TColor32; 4031 4435 ChangedRect: TRect; … … 4036 4440 Inc(X1, 127); Inc(Y1, 127); Inc(X2, 127); Inc(Y2, 127); 4037 4441 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; 4041 4446 if n > 0 then 4042 4447 begin … … 4054 4459 C := GetStippleColor; 4055 4460 A := C shr 24; 4056 hyp := hyp - n shl 16;4461 hyp := hypl - n shl 16; 4057 4462 A := A * Longword(hyp) shl 8 and $FF000000; 4058 4463 SET_T256((X1 + X2 - nx) shr 9, (Y1 + Y2 - ny) shr 9, C and $00FFFFFF + A); … … 4070 4475 procedure TCustomBitmap32.LineXSP(X1, Y1, X2, Y2: TFixed; L: Boolean); 4071 4476 const 4072 StippleInc: array [Boolean] of Single= (0, 1);4477 StippleInc: array [Boolean] of Integer = (0, 1); 4073 4478 var 4074 4479 n, i: Integer; 4075 sx, sy, ex, ey, nx, ny, hyp : Integer;4480 sx, sy, ex, ey, nx, ny, hyp, hypl: Integer; 4076 4481 A, C: TColor32; 4077 4482 ChangedRect: TRect; … … 4110 4515 Integer((Y1 - sy) shr 16))); 4111 4516 4112 // If we are still here, it means that the line touches one or several bitmap4517 // if we are still here, it means that the line touches one or several bitmap 4113 4518 // boundaries. Use the safe version of antialiased pixel routine 4114 4519 nx := X2 - X1; ny := Y2 - Y1; 4115 4520 Inc(X1, 127); Inc(Y1, 127); Inc(X2, 127); Inc(Y2, 127); 4116 4521 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; 4120 4526 if n > 0 then 4121 4527 begin … … 4132 4538 C := GetStippleColor; 4133 4539 A := C shr 24; 4134 hyp := hyp - n shl 16;4540 hyp := hypl - n shl 16; 4135 4541 A := A * Longword(hyp) shl 8 and $FF000000; 4136 4542 SET_TS256(SAR_9(X1 + X2 - nx), SAR_9(Y1 + Y2 - ny), C and $00FFFFFF + A); … … 4199 4605 CI := EC shr 8; 4200 4606 P := @Bits[X1 + Y1 * Width]; 4201 BlendMemEx(Value, P^, GAMMA_ TABLE[CI xor 255]);4607 BlendMemEx(Value, P^, GAMMA_ENCODING_TABLE[CI xor $FF]); 4202 4608 Inc(P, Sx); 4203 BlendMemEx(Value, P^, GAMMA_ TABLE[CI]);4609 BlendMemEx(Value, P^, GAMMA_ENCODING_TABLE[CI]); 4204 4610 end; 4205 4611 end … … 4217 4623 CI := EC shr 8; 4218 4624 P := @Bits[X1 + Y1 * Width]; 4219 BlendMemEx(Value, P^, GAMMA_ TABLE[CI xor 255]);4625 BlendMemEx(Value, P^, GAMMA_ENCODING_TABLE[CI xor $FF]); 4220 4626 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]); 4222 4628 end; 4223 4629 end; … … 4231 4637 var 4232 4638 Cx1, Cx2, Cy1, Cy2, PI, Sx, Sy, Dx, Dy, xd, yd, rem, term, tmp: Integer; 4233 CheckVert, CornerAA, Te mpClipped: Boolean;4639 CheckVert, CornerAA, TermClipped: Boolean; 4234 4640 D1, D2: PInteger; 4235 4641 EC, EA, ED, D: Word; … … 4376 4782 begin 4377 4783 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]); 4379 4785 Dec(ED, EA); 4380 4786 end; … … 4395 4801 if Sy = -1 then yd := -yd; // negate back 4396 4802 xd := rem; // restore old xd 4397 CheckVert := False; // to avoid ugly labelswe set this to omit the next check4803 CheckVert := False; // to avoid ugly goto we set this to omit the next check 4398 4804 end; 4399 4805 end; … … 4413 4819 4414 4820 term := X2; 4415 Te mpClipped := False;4821 TermClipped := False; 4416 4822 CheckVert := False; 4417 4823 … … 4436 4842 end; 4437 4843 4438 Te mpClipped := True;4844 TermClipped := True; 4439 4845 end; 4440 4846 … … 4442 4848 begin 4443 4849 term := Cx2; 4444 Te mpClipped := True;4850 TermClipped := True; 4445 4851 end; 4446 4852 … … 4458 4864 if not CornerAA then 4459 4865 try 4460 // do we need to skip the last pixel of the line and is te mpnot clipped?4461 if not(L or Te mpClipped) and not CheckVert then4866 // 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 4462 4868 begin 4463 4869 if xd < term then … … 4467 4873 end; 4468 4874 4469 Assert(term >= 0);4470 4875 while xd <> term do 4471 4876 begin 4472 4877 CI := EC shr 8; 4473 4878 P := @Bits[D1^ + D2^ * Width]; 4474 BlendMemEx(Value, P^, GAMMA_ TABLE[CI xor 255]);4879 BlendMemEx(Value, P^, GAMMA_ENCODING_TABLE[CI xor $FF]); 4475 4880 Inc(P, PI); 4476 BlendMemEx(Value, P^, GAMMA_ TABLE[CI]);4881 BlendMemEx(Value, P^, GAMMA_ENCODING_TABLE[CI]); 4477 4882 // check for overflow and jump to next line... 4478 4883 D := EC; … … 4492 4897 while xd <> rem do 4493 4898 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]); 4495 4900 Inc(EC, EA); 4496 4901 Inc(xd, Sx); … … 4758 5163 begin 4759 5164 C1 := SetAlpha(clWhite32, Clamp(Contrast * 512 div 100)); 4760 C2 := SetAlpha(clBlack32, Clamp(Contrast * 255div 100));5165 C2 := SetAlpha(clBlack32, Clamp(Contrast * $FF div 100)); 4761 5166 end 4762 5167 else if Contrast < 0 then 4763 5168 begin 4764 5169 Contrast := -Contrast; 4765 C1 := SetAlpha(clBlack32, Clamp(Contrast * 255div 100));5170 C1 := SetAlpha(clBlack32, Clamp(Contrast * $FF div 100)); 4766 5171 C2 := SetAlpha(clWhite32, Clamp(Contrast * 512 div 100)); 4767 5172 end … … 4862 5267 W := Width shl 2; 4863 5268 for I := Height - 1 downto 0 do 4864 Stream.WriteBuffer( PixelPtr[0,I]^, W);5269 Stream.WriteBuffer(ScanLine[I]^, W); 4865 5270 end 4866 5271 else … … 4991 5396 procedure TCustomBitmap32.ReadData(Stream: TStream); 4992 5397 var 4993 w, h: Integer;5398 Width, Height: Integer; 4994 5399 begin 4995 5400 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); 4999 5404 Stream.ReadBuffer(Bits[0], FWidth * FHeight * 4); 5000 5405 finally … … 5101 5506 OffsetRect(R, Dx, Dy); 5102 5507 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); 5107 5518 end; 5108 5519 … … 5176 5587 for J := 0 to Height div 2 - 1 do 5177 5588 begin 5178 P1 := P ixelPtr[0, J];5179 P2 := P ixelPtr[0, J2];5589 P1 := PColor32(ScanLine[J]); 5590 P2 := PColor32(ScanLine[J2]); 5180 5591 MoveLongword(P1^, Buffer^, Width); 5181 5592 MoveLongword(P2^, P1^, Width); … … 5192 5603 for J := 0 to Height - 1 do 5193 5604 begin 5194 MoveLongword( PixelPtr[0, J]^, Dst.PixelPtr[0,J2]^, Width);5605 MoveLongword(ScanLine[J]^, Dst.ScanLine[J2]^, Width); 5195 5606 Dec(J2); 5196 5607 end; … … 5387 5798 end; 5388 5799 5389 procedure TCustomBitmap32.SetResamplerClassName( Value: string);5800 procedure TCustomBitmap32.SetResamplerClassName(const Value: string); 5390 5801 var 5391 5802 ResamplerClass: TCustomResamplerClass; … … 5399 5810 5400 5811 { TBitmap32 } 5401 5402 procedure TBitmap32.InitializeBackend;5403 begin5404 Backend := GetPlatformBackendClass.Create;5405 end;5406 5812 5407 5813 procedure TBitmap32.FinalizeBackend; … … 5466 5872 begin 5467 5873 Result := (FBackend as IDeviceContextSupport).Handle; 5874 end; 5875 5876 class function TBitmap32.GetPlatformBackendClass: TCustomBackendClass; 5877 begin 5878 {$IFDEF FPC} 5879 Result := TLCLBackend; 5880 {$ELSE} 5881 Result := TGDIBackend; 5882 {$ENDIF} 5468 5883 end; 5469 5884 … … 5567 5982 end; 5568 5983 5984 {$IFDEF COMPILER2009_UP} 5985 procedure TBitmap32.DrawTo(Dst: TControlCanvas; DstX, DstY: Integer); 5986 begin 5987 DrawTo(Dst.Handle, DstX, DstY); 5988 end; 5989 5990 procedure TBitmap32.DrawTo(Dst: TControlCanvas; const DstRect, SrcRect: TRect); 5991 begin 5992 DrawTo(Dst.Handle, DstRect, SrcRect); 5993 end; 5994 5995 procedure TBitmap32.TileTo(Dst: TControlCanvas; const DstRect, SrcRect: TRect); 5996 begin 5997 TileTo(Dst.Handle, DstRect, SrcRect); 5998 end; 5999 {$ENDIF} 6000 5569 6001 procedure TBitmap32.UpdateFont; 5570 6002 begin … … 5574 6006 // Text and Fonts // 5575 6007 5576 function TBitmap32.TextExtent(const Text: String): TSize;6008 function TBitmap32.TextExtent(const Text: string): TSize; 5577 6009 begin 5578 6010 Result := (FBackend as ITextSupport).TextExtent(Text); … … 5586 6018 // ------------------------------------------------------------------- 5587 6019 5588 procedure TBitmap32.Textout(X, Y: Integer; const Text: String);6020 procedure TBitmap32.Textout(X, Y: Integer; const Text: string); 5589 6021 begin 5590 6022 (FBackend as ITextSupport).Textout(X, Y, Text); … … 5598 6030 // ------------------------------------------------------------------- 5599 6031 5600 procedure TBitmap32.Textout(X, Y: Integer; const ClipRect: TRect; const Text: String);6032 procedure TBitmap32.Textout(X, Y: Integer; const ClipRect: TRect; const Text: string); 5601 6033 begin 5602 6034 (FBackend as ITextSupport).Textout(X, Y, ClipRect, Text); … … 5610 6042 // ------------------------------------------------------------------- 5611 6043 5612 procedure TBitmap32.Textout( DstRect: TRect; const Flags: Cardinal; const Text: String);6044 procedure TBitmap32.Textout(var DstRect: TRect; const Flags: Cardinal; const Text: string); 5613 6045 begin 5614 6046 (FBackend as ITextSupport).Textout(DstRect, Flags, Text); 5615 6047 end; 5616 6048 5617 procedure TBitmap32.TextoutW( DstRect: TRect; const Flags: Cardinal; const Text: Widestring);6049 procedure TBitmap32.TextoutW(var DstRect: TRect; const Flags: Cardinal; const Text: Widestring); 5618 6050 begin 5619 6051 (FBackend as ITextSupport).TextoutW(DstRect, Flags, Text); … … 5622 6054 // ------------------------------------------------------------------- 5623 6055 5624 function TBitmap32.TextHeight(const Text: String): Integer;6056 function TBitmap32.TextHeight(const Text: string): Integer; 5625 6057 begin 5626 6058 Result := (FBackend as ITextSupport).TextExtent(Text).cY; … … 5634 6066 // ------------------------------------------------------------------- 5635 6067 5636 function TBitmap32.TextWidth(const Text: String): Integer;6068 function TBitmap32.TextWidth(const Text: string): Integer; 5637 6069 begin 5638 6070 Result := (FBackend as ITextSupport).TextExtent(Text).cX; … … 5674 6106 lfCharSet := Byte(Font.Charset); 5675 6107 5676 // TODO DVT Added cast to fix TFontDataName to String warning. Need to verify is OK6108 // TODO DVT Added cast to fix TFontDataName to string warning. Need to verify is OK 5677 6109 if AnsiCompareText(Font.Name, 'Default') = 0 then // do not localize 5678 6110 StrPCopy(lfFaceName, string(DefFontData.Name)) … … 5746 6178 begin 5747 6179 Sz := 1 shl N - 1; 5748 Dst := B.PixelPtr[0, 0];6180 Dst := PColor32(B.ScanLine[0]); 5749 6181 for J := 0 to B.Height - 1 do 5750 6182 begin … … 5770 6202 end; 5771 6203 5772 procedure TBitmap32.RenderText(X, Y: Integer; const Text: String; AALevel: Integer; Color: TColor32);6204 procedure TBitmap32.RenderText(X, Y: Integer; const Text: string; AALevel: Integer; Color: TColor32); 5773 6205 var 5774 6206 B, B2: TBitmap32; 5775 6207 Sz: TSize; 5776 6208 Alpha: TColor32; 5777 PaddedText: String;6209 PaddedText: string; 5778 6210 begin 5779 6211 if Empty then Exit; … … 5835 6267 DrawMode := dmBlend; 5836 6268 MasterAlpha := Alpha; 5837 CombineMode := Self.CombineMode;6269 CombineMode := CombineMode; 5838 6270 5839 6271 DrawTo(Self, X, Y); … … 5879 6311 B := TBitmap32.Create; 5880 6312 try 5881 if AALevel = 0 then6313 if AALevel <= 0 then 5882 6314 begin 5883 6315 Sz := TextExtentW(PaddedText); … … 5997 6429 {$ENDIF} 5998 6430 5999 procedure TCustomBackend.ChangeSize( varWidth, Height: Integer; NewWidth, NewHeight: Integer; ClearBuffer: Boolean);6431 procedure TCustomBackend.ChangeSize(out Width, Height: Integer; NewWidth, NewHeight: Integer; ClearBuffer: Boolean); 6000 6432 begin 6001 6433 try
Note:
See TracChangeset
for help on using the changeset viewer.