-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathWinGDIPlus.pas
16433 lines (13062 loc) · 635 KB
/
WinGDIPlus.pas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
{-------------------------------------------------------------------------------
This Source Code Form is subject to the terms of the Mozilla Public
License, v. 2.0. If a copy of the MPL was not distributed with this
file, You can obtain one at http://mozilla.org/MPL/2.0/.
-------------------------------------------------------------------------------}
{===============================================================================
Windows GDI+ reimplementation in object pascal
This is just a naive reimplemntation of original sources (*.h files)
provided with Windows SDK. This is NOT, and was never intended to be,
a comprehensive implementation that wraps entire subsystem into a neat
package (like Graphics unit is doing with GDI).
Almost no attempt was made to change the interface to be more pascal-like,
so expect things like frequent use of pointers (eg. for output or array
arguments), enum values without prefixes, use of windows types instead of
native ones, ... the list continues.
Translation notes:
- sources used for this translation were taken from Windows SDK of
version 10.0.22000.0
- everything was moved into one unit (obviously)
- all commens were copied from original sources with no change, comments
that start with double exclamation character (!!) were added during
translation
- lot of code was moved to different places, mainly to avoid circular
referencing
- macros were either expanded in-situ or replaced by functions
- all type identifiers were prepended with capital T (eg. TGraphics,
TRect), pointers to them with capital P (PGraphics, PRect)
- most enumerated types were translated as that, an enum, but some were
changed to a pair of type (usually INT) and a set of constants, this is
because values of these enums are expected to be combined (eg. using
bitwise OR), and this would be problematic (though possible) in pascal
- some methods, functions and arguments were renamed, ususally to deal
with conflicts with reserved words or clashing identifiers
- library initialization was reworked, see further [1]
- all provided classes implement functions that are not part of the GDI+,
these are there to simplify translation of some peculiar constructs
(eg. ternary operators - see declaration of TGdiPlusWrapper class for
more info)
- classes intended only as data containers (eg. Point, RectF, ...) were
reworked into records and their methods were implemented as normal
functions (note that some were renamed to avoid conflicts and ambiguous
overloads), this was done because of fundamental incompatibility of
object pascal and C++ classes/objects
- all constructors (with exceptions in TGraphics, see there for
explanation) are named Create, therefore are named differently than in
the original (C++ constructors are just named after the class)
- some class methods that originally returned references to "global"
objects were reworked to return unique instances, requiring explicit
freeing of the returned objects, see further for details [2]
- where declaration and implementation were separate and something was
not matching (argument name, order of methods, ...), the declaration
part was used as a template and the implementation was only consulted
- where required, new method overloads were added (eg. because the
declaration called for a default value for structure/record, which is
not allowed in pascal)
- if method accepted PWideChar, an overload accepting default type String
was added, the same goes for arguments of type IStream, they were
supplemented with TStream-accepting overloads
- remember to free any object you create, be it explicitly or implicitly,
as these are usual objects, not interfaces
- number of helper functions was implemented, more might be added in the
future
- I have found parts in the original code that seemed to be erroneous or
incomplete, some were marked, but all of them were translated as found,
with the probable errors
- code that could be simplified without changing its behavior was
simplified (this was mainly due to a fact that pascal can work with
function result anywhere in the function's body, C++ code sets returned
value and exits as one operation, necessitating a temporary variables)
- given the extent of GDI+ library, only small part of this translation
was tested, please report any errors and bugs you may find
[1] Functions GdiplusStartup and GdiplusShutdown are no longer pointing to
imported GDI+ functions of the same name. They are instead locally
implemented and are managing dynamic symbol resolving of functions
provided by highed versions of GDI+ (for details, see description of
symbol NewGDIPStatic). They also call the imported init and final
functions as required by the documentation, so it is not necessary to
call them explicitly.
Simply put, call functions GdiplusStartup and GdiplusShutdown as
described by GDI+ documentation, just be aware that you are not calling
directly to imports.
The imported functions are still available under names LibGdiplusStartup
and LibGdiplusShutdown.
[2] If I understand it correctly, following five functions are, in the
original code, returning instances of objects that are stored in global
static buffers.
TFontFamily.GenericSansSerif
TFontFamily.GenericSerif
TFontFamily.GenericMonospace
TStringFormat.GenericDefault
TStringFormat.GenericTypographic
These objects are, at least in the case of TFontFamily methods,
instantiated only once and then they exist the entire lifetime of the
program (they should not be destroyed). This saves memory and might
increase performance.
It is, in theory, possible to emulate this in pascal, but it would be
somewhat complex and problematic in multithread environment.
Therefore, I have decided to replace this by just returning new unique
instance of the particular object every time it is requested.
This all means one important thing - you have to free the returned object
after use to prevent memory leak!
version 1.0.2 (2024-10-14)
Last change 2024-10-14
©2023-2024 František Milt
Contacts:
František Milt: [email protected]
Support:
If you find this code useful, please consider supporting its author(s) by
making a small donation using the following link(s):
https://www.paypal.me/FMilt
Changelog:
For detailed changelog and history please refer to this git repository:
github.com/TheLazyTomcat/Bnd.WinGDIPlus
Dependencies:
* AuxExceptions - github.com/TheLazyTomcat/Lib.AuxExceptions
AuxTypes - github.com/TheLazyTomcat/Lib.AuxTypes
DynLibUtils - github.com/TheLazyTomcat/Lib.DynLibUtils
StrRect - github.com/TheLazyTomcat/Lib.StrRect
Library AuxExceptions is required only when rebasing local exception classes
(see symbol WinGDIPlus_UseAuxExceptions for details).
Library AuxExceptions might also be required as an indirect dependency.
Indirect dependencies:
InterlockedOps - github.com/TheLazyTomcat/Lib.InterlockedOps
SimpleCPUID - github.com/TheLazyTomcat/Lib.SimpleCPUID
UInt64Utils - github.com/TheLazyTomcat/Lib.UInt64Utils
WindowsVersion - github.com/TheLazyTomcat/Lib.WindowsVersion
WinFileInfo - github.com/TheLazyTomcat/Lib.WinFileInfo
===============================================================================}
unit WinGDIPlus;
{
WinGDIPlus_UseAuxExceptions
If you want library-specific exceptions to be based on more advanced classes
provided by AuxExceptions library instead of basic Exception class, and don't
want to or cannot change code in this unit, you can define global symbol
WinGDIPlus_UseAuxExceptions to achieve this.
}
{$IF Defined(WinGDIPlus_UseAuxExceptions)}
{$DEFINE UseAuxExceptions}
{$IFEND}
//------------------------------------------------------------------------------
{$IF not(defined(MSWINDOWS) or defined(WINDOWS))}
{$MESSAGE FATAL 'Unsupported operating system.'}
{$IFEND}
{$IFDEF FPC}
{$MODE ObjFPC}
{$MODESWITCH DuplicateLocals+}
{$MODESWITCH ClassicProcVars+}
{$INLINE ON}
{$DEFINE CanInline}
{$DEFINE FPC_DisableWarns}
{$MACRO ON}
{$ELSE}
{$IF CompilerVersion >= 17} //!! Delphi 2005+
{$DEFINE CanInline}
{$ELSE}
{$UNDEF CanInline}
{$IFEND}
{$ENDIF}
{$H+}
{$MINENUMSIZE 4}
{$ALIGN 8} //!! this should be default, but to be sure
//!!----------------------------------------------------------------------------
{!!
NewGDIP
When this symbol is defined, then types, constants, functions, classes and
methods from GDI+ version 1.1 are made accessible. When it is not defined,
these objects are inccessible and are completely removed from compilation
and only objects from GDI+ version 1.0 are provided.
Defined by default.
To disable/undefine this symbol in a project without changing this library,
define project-wide symbol WinGDIPlus_NewGDIP_Off.
}
{$DEFINE NewGDIP}
{$IFDEF WinGDIPlus_NewGDIP_Off}
{$UNDEF NewGDIP}
{$ENDIF}
{!!
NewGDIPStatic
When defined, the external functions from newer GDI+ versions (currently
version 1.1) are statically bound/resolved.
When not defined (the default state), then these functions are resolved
dynamically and only if new GDI+ version is requested when initializing
(calling GdiplusStartup).
This is here to allow use of code that is calling these functions on older
systems not supporting new GDI+ versions. There, the initialization and used
code can be selected at runtime based on supported version (use provided
helper function VersionSupported).
If the symbols were resolved statically, it would lead to fatal error even if
they would not be called.
NOTE - this symbol has effect only when symbol NewGDIP is defined.
Not defined by default.
To enable/define this symbol in a project without changing this library,
define project-wide symbol WinGDIPlus_NewGDIPStatic_ON.
}
{$UNDEF NewGDIPStatic}
{$IFDEF WinGDIPlus_NewGDIPStatic_ON}
{$DEFINE NewGDIPStatic}
{$ENDIF}
interface
{$IFDEF FPC_DisableWarns}
{$DEFINE FPCDWM}
{$DEFINE W3018:={$WARN 3018 OFF}} //!! Constructor should be public
{$DEFINE W3031:={$WARN 3031 OFF}} //!! Values in enumeration types have to be ascending
{$ENDIF}
uses
Windows, SysUtils, Classes, ActiveX{!! for IStream}, Math,
{$IFDEF FPC} jwawingdi,{$ENDIF}
AuxTypes{$IFDEF UseAuxExceptions}, AuxExceptions{$ENDIF};
{!!-----------------------------------------------------------------------------
Library-specific exceptions
-------------------------------------------------------------------------------}
type
EGDIPlusException = class({$IFDEF UseAuxExceptions}EAEGeneralException{$ELSE}Exception{$ENDIF});
EGDIPlusError = class(EGDIPlusException);
EGDIPlusIndexOutOfBounds = class(EGDIPlusException);
EGDIPlusObjectNotAssigned = class(EGDIPlusException);
EGDIPlusCodecNotFound = class(EGDIPlusException);
{!!-----------------------------------------------------------------------------
Constants and types
-------------------------------------------------------------------------------}
const
GDIPLIB = 'gdiplus.dll';
type
// integer types
INT = Int32; PINT = ^INT;
DWORDLONG = UInt64;
size_t = PtrUInt;
ULONG_PTR = PtrUInt; PULONG_PTR = ^ULONG_PTR;
UINT_PTR = PtrUInt;
PROPID = ULONG;
// handle types
HINSTANCE = THandle;
HANDLE = THandle;
// floating-point types
float = Single;
// pointer types
PHRGN = ^HRGN;
PHBITMAP = ^HBITMAP;
PHICON = ^HICON;
PHDC = ^HDC;
PIStream = ^IStream;
PLANGID = ^LANGID;
LPBYTE = PByte;
PHENHMETAFILE = ^HENHMETAFILE;
// structured types
RECTL = Windows.TRect;
SIZEL = Windows.TSize;
TCLSID = TGUID;
(**************************************************************************\
*
* Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved.
*
* Module Name:
*
* Gdiplus.h
*
* Abstract:
*
* GDI+ public header file
*
\**************************************************************************)
const
GDIPVER = {$IFDEF NewGDIP}$0110{$ELSE}$0100{$ENDIF}; //!! for conditional compilation
type
//!! just some placeholder I assume
IDirectDrawSurface7 = IUnknown;
(**************************************************************************\
*
* Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved.
*
* Module Name:
*
* GdiplusMem.h
*
* Abstract:
*
* GDI+ Private Memory Management APIs
*
\**************************************************************************)
//----------------------------------------------------------------------------
// Memory Allocation APIs
//----------------------------------------------------------------------------
Function GdipAlloc(size: size_t): Pointer; stdcall; external GDIPLIB;
procedure GdipFree(ptr: Pointer); stdcall; external GDIPLIB;
(**************************************************************************\
*
* Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved.
*
* Module Name:
*
* GdiplusBase.h
*
* Abstract:
*
* GDI+ base memory allocation class
*
\**************************************************************************)
{!!=============================================================================
TGdiPlusWrapper - class declaration
===============================================================================}
{!!
This class defines interface used when replacing some ternary operators used
in the original source, namely operators of style...
If Assigned(Obj) then
Var := Obj.NativeObjectField
else
Var := nil;
...which might in the original look something like:
Obj ? Obj->NativeObjectField : NULL
}
type
TGdiPlusWrapper = class(TObject)
protected
Function GetNativeObject: Pointer; virtual; abstract;
Function GetNativeObjectAddr: Pointer; virtual; abstract;
public
Function NativeObject: Pointer;
Function NativeObjectAddr: Pointer;
end;
type
TGdiPlusBase = class(TGdiPlusWrapper); //!! common ancestor for "big" objects
(**************************************************************************\
*
* Copyright (c) 1998-2001, Microsoft Corp. All Rights Reserved.
*
* Module Name:
*
* GdiplusEnums.h
*
* Abstract:
*
* GDI+ Enumeration Types
*
\**************************************************************************)
//--------------------------------------------------------------------------
// Default bezier flattening tolerance in device pixels.
//--------------------------------------------------------------------------
const
FlatnessDefault: Single = 1.0/4.0;
//--------------------------------------------------------------------------
// Graphics and Container State cookies
//--------------------------------------------------------------------------
type
TGraphicsState = UINT; PGraphicsState = ^TGraphicsState;
TGraphicsContainer = UINT; PGraphicsContainer = ^TGraphicsContainer;
//--------------------------------------------------------------------------
// Fill mode constants
//--------------------------------------------------------------------------
type
TFillMode = (
FillModeAlternate, // 0
FillModeWinding // 1
);
PFillMode = ^TFillMode;
//--------------------------------------------------------------------------
// Quality mode constants
//--------------------------------------------------------------------------
type
TQualityMode = (
QualityModeInvalid = -1,
QualityModeDefault = 0,
QualityModeLow = 1, // Best performance
QualityModeHigh = 2 // Best rendering quality
);
PQualityMode = ^TQualityMode;
//--------------------------------------------------------------------------
// Alpha Compositing mode constants
//--------------------------------------------------------------------------
type
TCompositingMode = (
CompositingModeSourceOver, // 0
CompositingModeSourceCopy // 1
);
PCompositingMode = ^TCompositingMode;
//--------------------------------------------------------------------------
// Alpha Compositing quality constants
//--------------------------------------------------------------------------
type
TCompositingQuality = (
CompositingQualityInvalid = Ord(QualityModeInvalid),
CompositingQualityDefault = Ord(QualityModeDefault),
CompositingQualityHighSpeed = Ord(QualityModeLow),
CompositingQualityHighQuality = Ord(QualityModeHigh),
CompositingQualityGammaCorrected,
CompositingQualityAssumeLinear
);
PCompositingQuality = ^TCompositingQuality;
//--------------------------------------------------------------------------
// Unit constants
//--------------------------------------------------------------------------
type
TUnit = (
UnitWorld, // 0 -- World coordinate (non-physical unit)
UnitDisplay, // 1 -- Variable -- for PageTransform only
UnitPixel, // 2 -- Each unit is one device pixel.
UnitPoint, // 3 -- Each unit is a printer's point, or 1/72 inch.
UnitInch, // 4 -- Each unit is 1 inch.
UnitDocument, // 5 -- Each unit is 1/300 inch.
UnitMillimeter // 6 -- Each unit is 1 millimeter.
);
PUnit = ^TUnit;
//--------------------------------------------------------------------------
// MetafileFrameUnit
//
// The frameRect for creating a metafile can be specified in any of these
// units. There is an extra frame unit value (MetafileFrameUnitGdi) so
// that units can be supplied in the same units that GDI expects for
// frame rects -- these units are in .01 (1/100ths) millimeter units
// as defined by GDI.
//--------------------------------------------------------------------------
type
TMetafileFrameUnit =(
MetafileFrameUnitPixel = Ord(UnitPixel),
MetafileFrameUnitPoint = Ord(UnitPoint),
MetafileFrameUnitInch = Ord(UnitInch),
MetafileFrameUnitDocument = Ord(UnitDocument),
MetafileFrameUnitMillimeter = Ord(UnitMillimeter),
MetafileFrameUnitGdi // GDI compatible .01 MM units
);
PMetafileFrameUnit = ^TMetafileFrameUnit;
//--------------------------------------------------------------------------
// Coordinate space identifiers
//--------------------------------------------------------------------------
type
TCoordinateSpace = (
CoordinateSpaceWorld, // 0
CoordinateSpacePage, // 1
CoordinateSpaceDevice // 2
);
PCoordinateSpace = ^TCoordinateSpace;
//--------------------------------------------------------------------------
// Various wrap modes for brushes
//--------------------------------------------------------------------------
type
TWrapMode = (
WrapModeTile, // 0
WrapModeTileFlipX, // 1
WrapModeTileFlipY, // 2
WrapModeTileFlipXY, // 3
WrapModeClamp // 4
);
PWrapMode = ^TWrapMode;
//--------------------------------------------------------------------------
// Various hatch styles
//--------------------------------------------------------------------------
type
THatchStyle = (
HatchStyleHorizontal, // 0
HatchStyleVertical, // 1
HatchStyleForwardDiagonal, // 2
HatchStyleBackwardDiagonal, // 3
HatchStyleCross, // 4
HatchStyleDiagonalCross, // 5
HatchStyle05Percent, // 6
HatchStyle10Percent, // 7
HatchStyle20Percent, // 8
HatchStyle25Percent, // 9
HatchStyle30Percent, // 10
HatchStyle40Percent, // 11
HatchStyle50Percent, // 12
HatchStyle60Percent, // 13
HatchStyle70Percent, // 14
HatchStyle75Percent, // 15
HatchStyle80Percent, // 16
HatchStyle90Percent, // 17
HatchStyleLightDownwardDiagonal, // 18
HatchStyleLightUpwardDiagonal, // 19
HatchStyleDarkDownwardDiagonal, // 20
HatchStyleDarkUpwardDiagonal, // 21
HatchStyleWideDownwardDiagonal, // 22
HatchStyleWideUpwardDiagonal, // 23
HatchStyleLightVertical, // 24
HatchStyleLightHorizontal, // 25
HatchStyleNarrowVertical, // 26
HatchStyleNarrowHorizontal, // 27
HatchStyleDarkVertical, // 28
HatchStyleDarkHorizontal, // 29
HatchStyleDashedDownwardDiagonal, // 30
HatchStyleDashedUpwardDiagonal, // 31
HatchStyleDashedHorizontal, // 32
HatchStyleDashedVertical, // 33
HatchStyleSmallConfetti, // 34
HatchStyleLargeConfetti, // 35
HatchStyleZigZag, // 36
HatchStyleWave, // 37
HatchStyleDiagonalBrick, // 38
HatchStyleHorizontalBrick, // 39
HatchStyleWeave, // 40
HatchStylePlaid, // 41
HatchStyleDivot, // 42
HatchStyleDottedGrid, // 43
HatchStyleDottedDiamond, // 44
HatchStyleShingle, // 45
HatchStyleTrellis, // 46
HatchStyleSphere, // 47
HatchStyleSmallGrid, // 48
HatchStyleSmallCheckerBoard, // 49
HatchStyleLargeCheckerBoard, // 50
HatchStyleOutlinedDiamond, // 51
HatchStyleSolidDiamond, // 52
HatchStyleTotal,
{$IFDEF FPCDWM}{$PUSH}W3031{$ENDIF}
HatchStyleLargeGrid = HatchStyleCross, // 4
{$IFDEF FPCDWM}{$POP}{$ENDIF}
HatchStyleMin = HatchStyleHorizontal,
HatchStyleMax = Ord(HatchStyleTotal) - 1
);
PHatchStyle = ^THatchStyle;
//--------------------------------------------------------------------------
// Dash style constants
//--------------------------------------------------------------------------
type
TDashStyle = (
DashStyleSolid, // 0
DashStyleDash, // 1
DashStyleDot, // 2
DashStyleDashDot, // 3
DashStyleDashDotDot, // 4
DashStyleCustom // 5
);
PDashStyle = ^TDashStyle;
//--------------------------------------------------------------------------
// Dash cap constants
//--------------------------------------------------------------------------
type
TDashCap = (
DashCapFlat = 0,
DashCapRound = 2,
DashCapTriangle = 3
);
PDashCap = ^TDashCap;
//--------------------------------------------------------------------------
// Line cap constants (only the lowest 8 bits are used).
//--------------------------------------------------------------------------
type
TLineCap = (
LineCapFlat = 0,
LineCapSquare = 1,
LineCapRound = 2,
LineCapTriangle = 3,
LineCapNoAnchor = $10, // corresponds to flat cap
LineCapSquareAnchor = $11, // corresponds to square cap
LineCapRoundAnchor = $12, // corresponds to round cap
LineCapDiamondAnchor = $13, // corresponds to triangle cap
LineCapArrowAnchor = $14, // no correspondence
LineCapCustom = $ff, // custom cap
{$IFDEF FPCDWM}{$PUSH}W3031{$ENDIF}
LineCapAnchorMask = $f0 // mask to check for anchor or not.
);
{$IFDEF FPCDWM}{$POP}{$ENDIF}
PLineCap = ^TLineCap;
//--------------------------------------------------------------------------
// Custom Line cap type constants
//--------------------------------------------------------------------------
type
TCustomLineCapType =(
CustomLineCapTypeDefault = 0,
CustomLineCapTypeAdjustableArrow = 1
);
PCustomLineCapType = ^TCustomLineCapType;
//--------------------------------------------------------------------------
// Line join constants
//--------------------------------------------------------------------------
type
TLineJoin = (
LineJoinMiter = 0,
LineJoinBevel = 1,
LineJoinRound = 2,
LineJoinMiterClipped = 3
);
PLineJoin = ^TLineJoin;
//--------------------------------------------------------------------------
// Path point types (only the lowest 8 bits are used.)
// The lowest 3 bits are interpreted as point type
// The higher 5 bits are reserved for flags.
//--------------------------------------------------------------------------
type
TPathPointType = (
PathPointTypeStart = 0, // move
PathPointTypeLine = 1, // line
PathPointTypeBezier = 3, // default Bezier (= cubic Bezier)
PathPointTypePathTypeMask = $07, // type mask (lowest 3 bits).
PathPointTypeDashMode = $10, // currently in dash mode.
PathPointTypePathMarker = $20, // a marker for the path.
PathPointTypeCloseSubpath = $80, // closed flag
// Path types used for advanced path.
{$IFDEF FPCDWM}{$PUSH}W3031{$ENDIF}
PathPointTypeBezier3 = 3 // cubic Bezier
);
{$IFDEF FPCDWM}{$POP}{$ENDIF}
PPathPointType = ^TPathPointType;
//--------------------------------------------------------------------------
// WarpMode constants
//--------------------------------------------------------------------------
type
TWarpMode = (
WarpModePerspective, // 0
WarpModeBilinear // 1
);
PWarpMode = ^TWarpMode;
//--------------------------------------------------------------------------
// LineGradient Mode
//--------------------------------------------------------------------------
type
TLinearGradientMode = (
LinearGradientModeHorizontal, // 0
LinearGradientModeVertical, // 1
LinearGradientModeForwardDiagonal, // 2
LinearGradientModeBackwardDiagonal // 3
);
PLinearGradientMode = ^TLinearGradientMode;
//--------------------------------------------------------------------------
// Region Comine Modes
//--------------------------------------------------------------------------
type
TCombineMode = (
CombineModeReplace, // 0
CombineModeIntersect, // 1
CombineModeUnion, // 2
CombineModeXor, // 3
CombineModeExclude, // 4
CombineModeComplement // 5 (Exclude From)
);
PCombineMode = ^TCombineMode;
//--------------------------------------------------------------------------
// Image types
//--------------------------------------------------------------------------
type
TImageType = (
ImageTypeUnknown, // 0
ImageTypeBitmap, // 1
ImageTypeMetafile // 2
);
PImageType = ^TImageType;
//--------------------------------------------------------------------------
// Interpolation modes
//--------------------------------------------------------------------------
type
TInterpolationMode = (
InterpolationModeInvalid = Ord(QualityModeInvalid),
InterpolationModeDefault = Ord(QualityModeDefault),
InterpolationModeLowQuality = Ord(QualityModeLow),
InterpolationModeHighQuality = Ord(QualityModeHigh),
InterpolationModeBilinear,
InterpolationModeBicubic,
InterpolationModeNearestNeighbor,
InterpolationModeHighQualityBilinear,
InterpolationModeHighQualityBicubic
);
PInterpolationMode = ^TInterpolationMode;
//--------------------------------------------------------------------------
// Pen types
//--------------------------------------------------------------------------
type
TPenAlignment = (
PenAlignmentCenter = 0,
PenAlignmentInset = 1
);
PPenAlignment = ^TPenAlignment;
//--------------------------------------------------------------------------
// Brush types
//--------------------------------------------------------------------------
type
TBrushType = (
BrushTypeSolidColor = 0,
BrushTypeHatchFill = 1,
BrushTypeTextureFill = 2,
BrushTypePathGradient = 3,
BrushTypeLinearGradient = 4
);
PBrushType = ^TBrushType;
//--------------------------------------------------------------------------
// Pen's Fill types
//--------------------------------------------------------------------------
type
TPenType = (
PenTypeSolidColor = Ord(BrushTypeSolidColor),
PenTypeHatchFill = Ord(BrushTypeHatchFill),
PenTypeTextureFill = Ord(BrushTypeTextureFill),
PenTypePathGradient = Ord(BrushTypePathGradient),
PenTypeLinearGradient = Ord(BrushTypeLinearGradient),
{$IFDEF FPCDWM}{$PUSH}W3031{$ENDIF}
PenTypeUnknown = -1
);
{$IFDEF FPCDWM}{$POP}{$ENDIF}
PPenType = ^TPenType;
//--------------------------------------------------------------------------
// Matrix Order
//--------------------------------------------------------------------------
type
TMatrixOrder = (
MatrixOrderPrepend = 0,
MatrixOrderAppend = 1
);
PMatrixOrder = ^TMatrixOrder;
//--------------------------------------------------------------------------
// Generic font families
//--------------------------------------------------------------------------
type
TGenericFontFamily = (
GenericFontFamilySerif,
GenericFontFamilySansSerif,
GenericFontFamilyMonospace
);
PGenericFontFamily = ^TGenericFontFamily;
//--------------------------------------------------------------------------
// FontStyle: face types and common styles
//--------------------------------------------------------------------------
type
TFontStyle = INT; PFontStyle = ^TFontStyle;
const
FontStyleRegular = 0;
FontStyleBold = 1;
FontStyleItalic = 2;
FontStyleBoldItalic = 3;
FontStyleUnderline = 4;
FontStyleStrikeout = 8;
//---------------------------------------------------------------------------
// Smoothing Mode
//---------------------------------------------------------------------------
type
TSmoothingMode = (
SmoothingModeInvalid = Ord(QualityModeInvalid),
SmoothingModeDefault = Ord(QualityModeDefault),
SmoothingModeHighSpeed = Ord(QualityModeLow),
SmoothingModeHighQuality = Ord(QualityModeHigh),
SmoothingModeNone,
SmoothingModeAntiAlias
{$IF GDIPVER >= $0110},
{$IFDEF FPCDWM}{$PUSH}W3031{$ENDIF}
SmoothingModeAntiAlias8x4 = Ord(SmoothingModeAntiAlias),
{$IFDEF FPCDWM}{$POP}{$ENDIF}
SmoothingModeAntiAlias8x8
{$IFEND}
);
PSmoothingMode = ^TSmoothingMode;
//---------------------------------------------------------------------------
// Pixel Format Mode
//---------------------------------------------------------------------------
type
TPixelOffsetMode = (
PixelOffsetModeInvalid = Ord(QualityModeInvalid),
PixelOffsetModeDefault = Ord(QualityModeDefault),
PixelOffsetModeHighSpeed = Ord(QualityModeLow),
PixelOffsetModeHighQuality = Ord(QualityModeHigh),
PixelOffsetModeNone, // No pixel offset
PixelOffsetModeHalf // Offset by -0.5, -0.5 for fast anti-alias perf
);
PPixelOffsetMode = ^TPixelOffsetMode;
//---------------------------------------------------------------------------
// Text Rendering Hint
//---------------------------------------------------------------------------
type
TTextRenderingHint = (
TextRenderingHintSystemDefault = 0, // Glyph with system default rendering hint
TextRenderingHintSingleBitPerPixelGridFit, // Glyph bitmap with hinting
TextRenderingHintSingleBitPerPixel, // Glyph bitmap without hinting
TextRenderingHintAntiAliasGridFit, // Glyph anti-alias bitmap with hinting
TextRenderingHintAntiAlias, // Glyph anti-alias bitmap without hinting
TextRenderingHintClearTypeGridFit // Glyph CT bitmap with hinting
);
PTextRenderingHint = ^TTextRenderingHint;
//---------------------------------------------------------------------------
// Metafile Types
//---------------------------------------------------------------------------
type
TMetafileType = (
MetafileTypeInvalid, // Invalid metafile
MetafileTypeWmf, // Standard WMF
MetafileTypeWmfPlaceable, // Placeable WMF
MetafileTypeEmf, // EMF (not EMF+)
MetafileTypeEmfPlusOnly, // EMF+ without dual, down-level records
MetafileTypeEmfPlusDual // EMF+ with dual, down-level records
);
PMetafileType = ^TMetafileType;
//---------------------------------------------------------------------------
// Specifies the type of EMF to record
//---------------------------------------------------------------------------
type
TEmfType = (
EmfTypeEmfOnly = Ord(MetafileTypeEmf), // no EMF+, only EMF
EmfTypeEmfPlusOnly = Ord(MetafileTypeEmfPlusOnly), // no EMF, only EMF+
EmfTypeEmfPlusDual = Ord(MetafileTypeEmfPlusDual) // both EMF+ and EMF
);
PEmfType = ^TEmfType;
//---------------------------------------------------------------------------
// EMF+ Persistent object types
//---------------------------------------------------------------------------
type
TObjectType = (
ObjectTypeInvalid,
ObjectTypeBrush,
ObjectTypePen,
ObjectTypePath,
ObjectTypeRegion,
ObjectTypeImage,
ObjectTypeFont,
ObjectTypeStringFormat,
ObjectTypeImageAttributes,
ObjectTypeCustomLineCap,
{$IF GDIPVER >= $0110}
ObjectTypeGraphics,
{$IFDEF FPCDWM}{$PUSH}W3031{$ENDIF}
ObjectTypeMax = ObjectTypeGraphics,
{$IFDEF FPCDWM}{$POP}{$ENDIF}
{$ELSE}
ObjectTypeMax = ObjectTypeCustomLineCap,
{$IFEND}
ObjectTypeMin = ObjectTypeBrush
);
PObjectType = ^TObjectType;
Function ObjectTypeIsValid(type_: TObjectType): BOOL;{$IFDEF CanInline} inline;{$ENDIF}
//---------------------------------------------------------------------------
// EMF+ Records
//---------------------------------------------------------------------------
// We have to change the WMF record numbers so that they don't conflict with
// the EMF and EMF+ record numbers.
const
GDIP_EMFPLUS_RECORD_BASE = $00004000;
GDIP_WMF_RECORD_BASE = $00010000;
type
TEmfPlusRecordType = (
// Since we have to enumerate GDI records right along with GDI+ records,
// We list all the GDI records here so that they can be part of the
// same enumeration type which is used in the enumeration callback.
WmfRecordTypeSetBkColor = (META_SETBKCOLOR or GDIP_WMF_RECORD_BASE),
{$IFDEF FPCDWM}{$PUSH}W3031{$ENDIF}
WmfRecordTypeSetBkMode = (META_SETBKMODE or GDIP_WMF_RECORD_BASE),
{$IFDEF FPCDWM}{$POP}{$ENDIF}
WmfRecordTypeSetMapMode = (META_SETMAPMODE or GDIP_WMF_RECORD_BASE),
WmfRecordTypeSetROP2 = (META_SETROP2 or GDIP_WMF_RECORD_BASE),
WmfRecordTypeSetRelAbs = (META_SETRELABS or GDIP_WMF_RECORD_BASE),
WmfRecordTypeSetPolyFillMode = (META_SETPOLYFILLMODE or GDIP_WMF_RECORD_BASE),
WmfRecordTypeSetStretchBltMode = (META_SETSTRETCHBLTMODE or GDIP_WMF_RECORD_BASE),
WmfRecordTypeSetTextCharExtra = (META_SETTEXTCHAREXTRA or GDIP_WMF_RECORD_BASE),
WmfRecordTypeSetTextColor = (META_SETTEXTCOLOR or GDIP_WMF_RECORD_BASE),
WmfRecordTypeSetTextJustification = (META_SETTEXTJUSTIFICATION or GDIP_WMF_RECORD_BASE),
WmfRecordTypeSetWindowOrg = (META_SETWINDOWORG or GDIP_WMF_RECORD_BASE),
WmfRecordTypeSetWindowExt = (META_SETWINDOWEXT or GDIP_WMF_RECORD_BASE),
WmfRecordTypeSetViewportOrg = (META_SETVIEWPORTORG or GDIP_WMF_RECORD_BASE),
WmfRecordTypeSetViewportExt = (META_SETVIEWPORTEXT or GDIP_WMF_RECORD_BASE),
WmfRecordTypeOffsetWindowOrg = (META_OFFSETWINDOWORG or GDIP_WMF_RECORD_BASE),
WmfRecordTypeScaleWindowExt = (META_SCALEWINDOWEXT or GDIP_WMF_RECORD_BASE),
WmfRecordTypeOffsetViewportOrg = (META_OFFSETVIEWPORTORG or GDIP_WMF_RECORD_BASE),
WmfRecordTypeScaleViewportExt = (META_SCALEVIEWPORTEXT or GDIP_WMF_RECORD_BASE),
WmfRecordTypeLineTo = (META_LINETO or GDIP_WMF_RECORD_BASE),
WmfRecordTypeMoveTo = (META_MOVETO or GDIP_WMF_RECORD_BASE),
WmfRecordTypeExcludeClipRect = (META_EXCLUDECLIPRECT or GDIP_WMF_RECORD_BASE),
WmfRecordTypeIntersectClipRect = (META_INTERSECTCLIPRECT or GDIP_WMF_RECORD_BASE),
WmfRecordTypeArc = (META_ARC or GDIP_WMF_RECORD_BASE),
WmfRecordTypeEllipse = (META_ELLIPSE or GDIP_WMF_RECORD_BASE),
WmfRecordTypeFloodFill = (META_FLOODFILL or GDIP_WMF_RECORD_BASE),
WmfRecordTypePie = (META_PIE or GDIP_WMF_RECORD_BASE),
WmfRecordTypeRectangle = (META_RECTANGLE or GDIP_WMF_RECORD_BASE),
WmfRecordTypeRoundRect = (META_ROUNDRECT or GDIP_WMF_RECORD_BASE),
WmfRecordTypePatBlt = (META_PATBLT or GDIP_WMF_RECORD_BASE),
WmfRecordTypeSaveDC = (META_SAVEDC or GDIP_WMF_RECORD_BASE),
WmfRecordTypeSetPixel = (META_SETPIXEL or GDIP_WMF_RECORD_BASE),
WmfRecordTypeOffsetClipRgn = (META_OFFSETCLIPRGN or GDIP_WMF_RECORD_BASE),
WmfRecordTypeTextOut = (META_TEXTOUT or GDIP_WMF_RECORD_BASE),
WmfRecordTypeBitBlt = (META_BITBLT or GDIP_WMF_RECORD_BASE),
WmfRecordTypeStretchBlt = (META_STRETCHBLT or GDIP_WMF_RECORD_BASE),
WmfRecordTypePolygon = (META_POLYGON or GDIP_WMF_RECORD_BASE),
WmfRecordTypePolyline = (META_POLYLINE or GDIP_WMF_RECORD_BASE),