-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathGDIPlus API.bas
More file actions
2644 lines (2439 loc) · 162 KB
/
Copy pathGDIPlus API.bas
File metadata and controls
2644 lines (2439 loc) · 162 KB
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
Attribute VB_Name = "GDIPlusAPI"
Option Explicit
' Translated by Avery P. - 7/29/2002
' NOTES:
' - All GDI+ Strings expect and return ONLY Unicode - you'll need to use StrConv when using them or convert the APIs to use StrPtr.
' As always, there are a few exceptions to a rule, and ImageTitles are one string that uses only ANSI strings.
' - Functions with an I (i) at the end are non-floating point declarations.
' - If a function without the I (i) at the end doesn't work, try the one with (if any).
' If neither version worked, then you did something wrong, or the API *may* be misdeclared.
' - The word (ALL) next to an API set mean all of the functions are declared. (ALL GDI+ functions are now declared 8/12/2002)
' - Search for "TODO:" (no quotes) to see what still needs done within the file. If there is no TODO, there is nothing to do!
' - If you want to get all of the encoder or decoder file extensions, MIME type, or other values, try to use the Get__Clsid functions as a base.
' - If you don't like the idea of converting strings to and from Unicode, change all As String occurances in the API declarations
' to As Long, and pass the StrPtr() result there instead. I opted to use the As String for clarity, especially since the GDI+ docs are
' geared toward how to use the C++ classes.
' - I may have misdeclared the IStream functions as I'm not too familiar with them. Do a "TODO:" or "IStream" search (no quotes) to see the
' IStream functions. All parameters except one where declared as 'IStream* stream' in C++. The exception has a comment above it. The possible
' problem is that the IStream parameters should be passed ByRef instead of ByVal. If they are wrong, please tell me!
' - APIs are in ordered groups, just like the C++ header, but the groups themselves are not in the same order as in the C++ headers.
'
' WARNINGS:
' - Some of the structs may not work, though I didn't test them all fully.
' - If a function causes a GPF or performs unexpectedly, make sure you are passing correct arguments.
' It also couldn't hurt to double-check the declarations as there is a chance they could be a bit off and looking in the MSDN can't hurt either.
' - Some APIs that have a ByRef parameter may expect an array; check the MSDN to find out if unsure.
'
'-----------------------------------------------
' 2/6/2003
' - I suppose I should put change notifications here in case you missed them on PSC.
' - Altered the ColorPalette to have 256 color palette entries regardless and the flags member is mapped to the PaletteFlags enum.
' - ImageCodecInfo now has the flags member mapped to the ImageCodecFlags enum.
' - GdipBitmapLockBits flags parameter changed to the ImageLockMode enum instead of a Long.
' - Altered the LOGFONTW lfFaceName member to be a String, which is twice as long as the ANSI to adjust for unicode.
' You'll want to use a StrConv on it to get the ANSI text. Also introduced a new constant to ease maintainance: LF_FACESIZEW
'-----------------------------------------------
'-----------------------------------------------
' String Pointer Related APIs (For the String Utilities)
'-----------------------------------------------
Public Declare Function CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (Dest As Any, Src As Any, ByVal cb As Long) As Long
Private Declare Function lstrlenW Lib "kernel32" (ByVal psString As Any) As Long
Private Declare Function lstrlenA Lib "kernel32" (ByVal psString As Any) As Long
'-----------------------------------------------
' CLSID Generation Related APIs
'-----------------------------------------------
Private Declare Function CLSIDFromString Lib "ole32.dll" (ByVal lpszProgID As Long, pCLSID As CLSID) As Long
'-----------------------------------------------
' GDI+ Constants
'-----------------------------------------------
Public Const LF_FACESIZE As Long = 32
Public Const LF_FACESIZEW As Long = LF_FACESIZE * 2
Public Const FlatnessDefault As Single = 1# / 4#
'Shift count and bit mask for A, R, G, B components
Public Const AlphaShift = 24
Public Const RedShift = 16
Public Const GreenShift = 8
Public Const BlueShift = 0
Public Const AlphaMask = &HFF000000
Public Const RedMask = &HFF0000
Public Const GreenMask = &HFF00
Public Const BlueMask = &HFF
' In-memory pixel data formats:
' bits 0-7 = format index
' bits 8-15 = pixel size (in bits)
' bits 16-23 = flags
' bits 24-31 = reserved
Public Const PixelFormatIndexed = &H10000 ' Indexes into a palette
Public Const PixelFormatGDI = &H20000 ' Is a GDI-supported format
Public Const PixelFormatAlpha = &H40000 ' Has an alpha component
Public Const PixelFormatPAlpha = &H80000 ' Pre-multiplied alpha
Public Const PixelFormatExtended = &H100000 ' Extended color 16 bits/channel
Public Const PixelFormatCanonical = &H200000
Public Const PixelFormatUndefined = 0
Public Const PixelFormatDontCare = 0
Public Const PixelFormat1bppIndexed = &H30101
Public Const PixelFormat4bppIndexed = &H30402
Public Const PixelFormat8bppIndexed = &H30803
Public Const PixelFormat16bppGreyScale = &H101004
Public Const PixelFormat16bppRGB555 = &H21005
Public Const PixelFormat16bppRGB565 = &H21006
Public Const PixelFormat16bppARGB1555 = &H61007
Public Const PixelFormat24bppRGB = &H21808
Public Const PixelFormat32bppRGB = &H22009
Public Const PixelFormat32bppARGB = &H26200A
Public Const PixelFormat32bppPARGB = &HE200B
Public Const PixelFormat48bppRGB = &H10300C
Public Const PixelFormat64bppARGB = &H34400D
Public Const PixelFormat64bppPARGB = &H1C400E
Public Const PixelFormatMax = 15 '&HF
' Image property types
Public Const PropertyTagTypeByte = 1
Public Const PropertyTagTypeASCII = 2
Public Const PropertyTagTypeShort = 3
Public Const PropertyTagTypeLong = 4
Public Const PropertyTagTypeRational = 5
Public Const PropertyTagTypeUndefined = 7
Public Const PropertyTagTypeSLONG = 9
Public Const PropertyTagTypeSRational = 10
' Image property ID tags
Public Const PropertyTagExifIFD = &H8769
Public Const PropertyTagGpsIFD = &H8825
Public Const PropertyTagNewSubfileType = &HFE
Public Const PropertyTagSubfileType = &HFF
Public Const PropertyTagImageWidth = &H100
Public Const PropertyTagImageHeight = &H101
Public Const PropertyTagBitsPerSample = &H102
Public Const PropertyTagCompression = &H103
Public Const PropertyTagPhotometricInterp = &H106
Public Const PropertyTagThreshHolding = &H107
Public Const PropertyTagCellWidth = &H108
Public Const PropertyTagCellHeight = &H109
Public Const PropertyTagFillOrder = &H10A
Public Const PropertyTagDocumentName = &H10D
Public Const PropertyTagImageDescription = &H10E
Public Const PropertyTagEquipMake = &H10F
Public Const PropertyTagEquipModel = &H110
Public Const PropertyTagStripOffsets = &H111
Public Const PropertyTagOrientation = &H112
Public Const PropertyTagSamplesPerPixel = &H115
Public Const PropertyTagRowsPerStrip = &H116
Public Const PropertyTagStripBytesCount = &H117
Public Const PropertyTagMinSampleValue = &H118
Public Const PropertyTagMaxSampleValue = &H119
Public Const PropertyTagXResolution = &H11A ' Image resolution in width direction
Public Const PropertyTagYResolution = &H11B ' Image resolution in height direction
Public Const PropertyTagPlanarConfig = &H11C ' Image data arrangement
Public Const PropertyTagPageName = &H11D
Public Const PropertyTagXPosition = &H11E
Public Const PropertyTagYPosition = &H11F
Public Const PropertyTagFreeOffset = &H120
Public Const PropertyTagFreeByteCounts = &H121
Public Const PropertyTagGrayResponseUnit = &H122
Public Const PropertyTagGrayResponseCurve = &H123
Public Const PropertyTagT4Option = &H124
Public Const PropertyTagT6Option = &H125
Public Const PropertyTagResolutionUnit = &H128 ' Unit of X and Y resolution
Public Const PropertyTagPageNumber = &H129
Public Const PropertyTagTransferFuncition = &H12D
Public Const PropertyTagSoftwareUsed = &H131
Public Const PropertyTagDateTime = &H132
Public Const PropertyTagArtist = &H13B
Public Const PropertyTagHostComputer = &H13C
Public Const PropertyTagPredictor = &H13D
Public Const PropertyTagWhitePoint = &H13E
Public Const PropertyTagPrimaryChromaticities = &H13F
Public Const PropertyTagColorMap = &H140
Public Const PropertyTagHalftoneHints = &H141
Public Const PropertyTagTileWidth = &H142
Public Const PropertyTagTileLength = &H143
Public Const PropertyTagTileOffset = &H144
Public Const PropertyTagTileByteCounts = &H145
Public Const PropertyTagInkSet = &H14C
Public Const PropertyTagInkNames = &H14D
Public Const PropertyTagNumberOfInks = &H14E
Public Const PropertyTagDotRange = &H150
Public Const PropertyTagTargetPrinter = &H151
Public Const PropertyTagExtraSamples = &H152
Public Const PropertyTagSampleFormat = &H153
Public Const PropertyTagSMinSampleValue = &H154
Public Const PropertyTagSMaxSampleValue = &H155
Public Const PropertyTagTransferRange = &H156
Public Const PropertyTagJPEGProc = &H200
Public Const PropertyTagJPEGInterFormat = &H201
Public Const PropertyTagJPEGInterLength = &H202
Public Const PropertyTagJPEGRestartInterval = &H203
Public Const PropertyTagJPEGLosslessPredictors = &H205
Public Const PropertyTagJPEGPointTransforms = &H206
Public Const PropertyTagJPEGQTables = &H207
Public Const PropertyTagJPEGDCTables = &H208
Public Const PropertyTagJPEGACTables = &H209
Public Const PropertyTagYCbCrCoefficients = &H211
Public Const PropertyTagYCbCrSubsampling = &H212
Public Const PropertyTagYCbCrPositioning = &H213
Public Const PropertyTagREFBlackWhite = &H214
Public Const PropertyTagICCProfile = &H8773 ' This TAG is defined by ICC
' for embedded ICC in TIFF
Public Const PropertyTagGamma = &H301
Public Const PropertyTagICCProfileDescriptor = &H302
Public Const PropertyTagSRGBRenderingIntent = &H303
Public Const PropertyTagImageTitle = &H320
Public Const PropertyTagCopyright = &H8298
' Extra TAGs (Like Adobe Image Information tags etc.)
Public Const PropertyTagResolutionXUnit = &H5001
Public Const PropertyTagResolutionYUnit = &H5002
Public Const PropertyTagResolutionXLengthUnit = &H5003
Public Const PropertyTagResolutionYLengthUnit = &H5004
Public Const PropertyTagPrintFlags = &H5005
Public Const PropertyTagPrintFlagsVersion = &H5006
Public Const PropertyTagPrintFlagsCrop = &H5007
Public Const PropertyTagPrintFlagsBleedWidth = &H5008
Public Const PropertyTagPrintFlagsBleedWidthScale = &H5009
Public Const PropertyTagHalftoneLPI = &H500A
Public Const PropertyTagHalftoneLPIUnit = &H500B
Public Const PropertyTagHalftoneDegree = &H500C
Public Const PropertyTagHalftoneShape = &H500D
Public Const PropertyTagHalftoneMisc = &H500E
Public Const PropertyTagHalftoneScreen = &H500F
Public Const PropertyTagJPEGQuality = &H5010
Public Const PropertyTagGridSize = &H5011
Public Const PropertyTagThumbnailFormat = &H5012 ' 1 = JPEG, 0 = RAW RGB
Public Const PropertyTagThumbnailWidth = &H5013
Public Const PropertyTagThumbnailHeight = &H5014
Public Const PropertyTagThumbnailColorDepth = &H5015
Public Const PropertyTagThumbnailPlanes = &H5016
Public Const PropertyTagThumbnailRawBytes = &H5017
Public Const PropertyTagThumbnailSize = &H5018
Public Const PropertyTagThumbnailCompressedSize = &H5019
Public Const PropertyTagColorTransferFunction = &H501A
Public Const PropertyTagThumbnailData = &H501B ' RAW thumbnail bits in
' JPEG format or RGB format
' depends on
' PropertyTagThumbnailFormat
' Thumbnail related TAGs
Public Const PropertyTagThumbnailImageWidth = &H5020 ' Thumbnail width
Public Const PropertyTagThumbnailImageHeight = &H5021 ' Thumbnail height
Public Const PropertyTagThumbnailBitsPerSample = &H5022 ' Number of bits per
' component
Public Const PropertyTagThumbnailCompression = &H5023 ' Compression Scheme
Public Const PropertyTagThumbnailPhotometricInterp = &H5024 ' Pixel composition
Public Const PropertyTagThumbnailImageDescription = &H5025 ' Image Tile
Public Const PropertyTagThumbnailEquipMake = &H5026 ' Manufacturer of Image
' Input equipment
Public Const PropertyTagThumbnailEquipModel = &H5027 ' Model of Image input
' equipment
Public Const PropertyTagThumbnailStripOffsets = &H5028 ' Image data location
Public Const PropertyTagThumbnailOrientation = &H5029 ' Orientation of image
Public Const PropertyTagThumbnailSamplesPerPixel = &H502A ' Number of components
Public Const PropertyTagThumbnailRowsPerStrip = &H502B ' Number of rows per strip
Public Const PropertyTagThumbnailStripBytesCount = &H502C ' Bytes per compressed
' strip
Public Const PropertyTagThumbnailResolutionX = &H502D ' Resolution in width
' direction
Public Const PropertyTagThumbnailResolutionY = &H502E ' Resolution in height
' direction
Public Const PropertyTagThumbnailPlanarConfig = &H502F ' Image data arrangement
Public Const PropertyTagThumbnailResolutionUnit = &H5030 ' Unit of X and Y
' Resolution
Public Const PropertyTagThumbnailTransferFunction = &H5031 ' Transfer function
Public Const PropertyTagThumbnailSoftwareUsed = &H5032 ' Software used
Public Const PropertyTagThumbnailDateTime = &H5033 ' File change date and
' time
Public Const PropertyTagThumbnailArtist = &H5034 ' Person who created the
' image
Public Const PropertyTagThumbnailWhitePoint = &H5035 ' White point chromaticity
Public Const PropertyTagThumbnailPrimaryChromaticities = &H5036
' Chromaticities of
' primaries
Public Const PropertyTagThumbnailYCbCrCoefficients = &H5037 ' Color space transforma-
' tion coefficients
Public Const PropertyTagThumbnailYCbCrSubsampling = &H5038 ' Subsampling ratio of Y
' to C
Public Const PropertyTagThumbnailYCbCrPositioning = &H5039 ' Y and C position
Public Const PropertyTagThumbnailRefBlackWhite = &H503A ' Pair of black and white
' reference values
Public Const PropertyTagThumbnailCopyRight = &H503B ' CopyRight holder
Public Const PropertyTagLuminanceTable = &H5090
Public Const PropertyTagChrominanceTable = &H5091
Public Const PropertyTagFrameDelay = &H5100
Public Const PropertyTagLoopCount = &H5101
Public Const PropertyTagPixelUnit = &H5110 ' Unit specifier for pixel/unit
Public Const PropertyTagPixelPerUnitX = &H5111 ' Pixels per unit in X
Public Const PropertyTagPixelPerUnitY = &H5112 ' Pixels per unit in Y
Public Const PropertyTagPaletteHistogram = &H5113 ' Palette histogram
' EXIF specific tag
Public Const PropertyTagExifExposureTime = &H829A
Public Const PropertyTagExifFNumber = &H829D
Public Const PropertyTagExifExposureProg = &H8822
Public Const PropertyTagExifSpectralSense = &H8824
Public Const PropertyTagExifISOSpeed = &H8827
Public Const PropertyTagExifOECF = &H8828
Public Const PropertyTagExifVer = &H9000
Public Const PropertyTagExifDTOrig = &H9003 ' Date & time of original
Public Const PropertyTagExifDTDigitized = &H9004 ' Date & time of digital data generation
Public Const PropertyTagExifCompConfig = &H9101
Public Const PropertyTagExifCompBPP = &H9102
Public Const PropertyTagExifShutterSpeed = &H9201
Public Const PropertyTagExifAperture = &H9202
Public Const PropertyTagExifBrightness = &H9203
Public Const PropertyTagExifExposureBias = &H9204
Public Const PropertyTagExifMaxAperture = &H9205
Public Const PropertyTagExifSubjectDist = &H9206
Public Const PropertyTagExifMeteringMode = &H9207
Public Const PropertyTagExifLightSource = &H9208
Public Const PropertyTagExifFlash = &H9209
Public Const PropertyTagExifFocalLength = &H920A
Public Const PropertyTagExifMakerNote = &H927C
Public Const PropertyTagExifUserComment = &H9286
Public Const PropertyTagExifDTSubsec = &H9290 ' Date & Time subseconds
Public Const PropertyTagExifDTOrigSS = &H9291 ' Date & Time original subseconds
Public Const PropertyTagExifDTDigSS = &H9292 ' Date & TIme digitized subseconds
Public Const PropertyTagExifFPXVer = &HA000
Public Const PropertyTagExifColorSpace = &HA001
Public Const PropertyTagExifPixXDim = &HA002
Public Const PropertyTagExifPixYDim = &HA003
Public Const PropertyTagExifRelatedWav = &HA004 ' related sound file
Public Const PropertyTagExifInterop = &HA005
Public Const PropertyTagExifFlashEnergy = &HA20B
Public Const PropertyTagExifSpatialFR = &HA20C ' Spatial Frequency Response
Public Const PropertyTagExifFocalXRes = &HA20E ' Focal Plane X Resolution
Public Const PropertyTagExifFocalYRes = &HA20F ' Focal Plane Y Resolution
Public Const PropertyTagExifFocalResUnit = &HA210 ' Focal Plane Resolution Unit
Public Const PropertyTagExifSubjectLoc = &HA214
Public Const PropertyTagExifExposureIndex = &HA215
Public Const PropertyTagExifSensingMethod = &HA217
Public Const PropertyTagExifFileSource = &HA300
Public Const PropertyTagExifSceneType = &HA301
Public Const PropertyTagExifCfaPattern = &HA302
Public Const PropertyTagGpsVer = &H0
Public Const PropertyTagGpsLatitudeRef = &H1
Public Const PropertyTagGpsLatitude = &H2
Public Const PropertyTagGpsLongitudeRef = &H3
Public Const PropertyTagGpsLongitude = &H4
Public Const PropertyTagGpsAltitudeRef = &H5
Public Const PropertyTagGpsAltitude = &H6
Public Const PropertyTagGpsGpsTime = &H7
Public Const PropertyTagGpsGpsSatellites = &H8
Public Const PropertyTagGpsGpsStatus = &H9
Public Const PropertyTagGpsGpsMeasureMode = &HA
Public Const PropertyTagGpsGpsDop = &HB ' Measurement precision
Public Const PropertyTagGpsSpeedRef = &HC
Public Const PropertyTagGpsSpeed = &HD
Public Const PropertyTagGpsTrackRef = &HE
Public Const PropertyTagGpsTrack = &HF
Public Const PropertyTagGpsImgDirRef = &H10
Public Const PropertyTagGpsImgDir = &H11
Public Const PropertyTagGpsMapDatum = &H12
Public Const PropertyTagGpsDestLatRef = &H13
Public Const PropertyTagGpsDestLat = &H14
Public Const PropertyTagGpsDestLongRef = &H15
Public Const PropertyTagGpsDestLong = &H16
Public Const PropertyTagGpsDestBearRef = &H17
Public Const PropertyTagGpsDestBear = &H18
Public Const PropertyTagGpsDestDistRef = &H19
Public Const PropertyTagGpsDestDist = &H1A
'//---------------------------------------------------------------------------
'// Image file format identifiers
'//---------------------------------------------------------------------------
Public Const ImageFormatSuffix As String = "-0728-11D3-9D7B-0000F81EF32E}"
Public Const ImageFormatUndefined As String = "{B96B3CA9" & ImageFormatSuffix
Public Const ImageFormatMemoryBMP As String = "{B96B3CAA" & ImageFormatSuffix
Public Const ImageFormatBMP As String = "{B96B3CAB" & ImageFormatSuffix
Public Const ImageFormatEMF As String = "{B96B3CAC" & ImageFormatSuffix
Public Const ImageFormatWMF As String = "{B96B3CAD" & ImageFormatSuffix
Public Const ImageFormatJPEG As String = "{B96B3CAE" & ImageFormatSuffix
Public Const ImageFormatPNG As String = "{B96B3CAF" & ImageFormatSuffix
Public Const ImageFormatGIF As String = "{B96B3CB0" & ImageFormatSuffix
Public Const ImageFormatTIFF As String = "{B96B3CB1" & ImageFormatSuffix
Public Const ImageFormatEXIF As String = "{B96B3CB2" & ImageFormatSuffix
Public Const ImageFormatIcon As String = "{B96B3CB5" & ImageFormatSuffix
'//---------------------------------------------------------------------------
'// Predefined multi-frame dimension IDs
'//---------------------------------------------------------------------------
Public Const FrameDimensionTime As String = "{6AEDBD6D-3FB5-418A-83A6-7F45229DC872}"
Public Const FrameDimensionResolution As String = "{84236F7B-3BD3-428F-8DAB-4EA1439CA315}"
Public Const FrameDimensionPage As String = "{7462DC86-6180-4C7E-8E3F-EE7333A7A483}"
'//---------------------------------------------------------------------------
'// Property sets
'//---------------------------------------------------------------------------
Public Const FormatIDImageInformation As String = "{E5836CBE-5EEF-0F1D-ACDE-AE4C43B608CE}"
Public Const FormatIDJpegAppHeaders As String = "{1C4AFDCD-6177-43CF-ABC7-5F51AF39EE85}"
'//---------------------------------------------------------------------------
'// Encoder parameter sets
'//---------------------------------------------------------------------------
Public Const EncoderCompression As String = "{E09D739D-CCD4-44EE-8EBA-3FBF8BE4FC58}"
Public Const EncoderColorDepth As String = "{66087055-AD66-4C7C-9A18-38A2310B8337}"
Public Const EncoderScanMethod As String = "{3A4E2661-3109-4E56-8536-42C156E7DCFA}"
Public Const EncoderVersion As String = "{24D18C76-814A-41A4-BF53-1C219CCCF797}"
Public Const EncoderRenderMethod As String = "{6D42C53A-229A-4825-8BB7-5C99E2B9A8B8}"
Public Const EncoderQuality As String = "{1D5BE4B5-FA4A-452D-9CDD-5DB35105E7EB}"
Public Const EncoderTransformation As String = "{8D0EB2D1-A58E-4EA8-AA14-108074B7B6F9}"
Public Const EncoderLuminanceTable As String = "{EDB33BCE-0266-4A77-B904-27216099E717}"
Public Const EncoderChrominanceTable As String = "{F2E455DC-09B3-4316-8260-676ADA32481C}"
Public Const EncoderSaveFlag As String = "{292266FC-AC40-47BF-8CFC-A85B89A655DE}"
Public Const CodecIImageBytes As String = "{025D1823-6C7D-447B-BBDB-A3CBC3DFA2FC}"
'-----------------------------------------------
' The following types are NOT in the GDI+ docs, per se
'-----------------------------------------------
Public Type POINTL ' aka Point
x As Long
y As Long
End Type
Public Type POINTF ' aka PointF
x As Single
y As Single
End Type
Public Type RECTL ' aka Rect
Left As Long
Top As Long
Right As Long
Bottom As Long
End Type
Public Type RECTF ' aka RectF
Left As Single
Top As Single
Right As Single
Bottom As Single
End Type
Public Type SIZEL ' aka Size
cx As Long
cy As Long
End Type
Public Type SIZEF ' aka SizeF
cx As Single
cy As Single
End Type
' Custom types
Public Type COLORBYTES
BlueByte As Byte
GreenByte As Byte
RedByte As Byte
AlphaByte As Byte
End Type
Public Type COLORLONG
longval As Long
End Type
'-----------------------------------------------
' GDI+ Structs/Types
'-----------------------------------------------
Public Type GdiplusStartupInput
GdiplusVersion As Long ' Must be 1 for GDI+ v1.0, the current version as of this writing.
DebugEventCallback As Long ' Ignored on free builds
SuppressBackgroundThread As Long ' FALSE unless you're prepared to call
' the hook/unhook functions properly
SuppressExternalCodecs As Long ' FALSE unless you want GDI+ only to use
' its internal image codecs.
End Type
Public Type CLSID
Data1 As Long
Data2 As Integer
Data3 As Integer
Data4(0 To 7) As Byte
End Type
Public Type ImageCodecInfo
ClassID As CLSID
FormatID As CLSID
CodecName As Long ' String Pointer; const WCHAR*
DllName As Long ' String Pointer; const WCHAR*
FormatDescription As Long ' String Pointer; const WCHAR*
FilenameExtension As Long ' String Pointer; const WCHAR*
MimeType As Long ' String Pointer; const WCHAR*
flags As ImageCodecFlags ' Should be a Long equivalent
Version As Long
SigCount As Long
SigSize As Long
SigPattern As Long ' Byte Array Pointer; BYTE*
SigMask As Long ' Byte Array Pointer; BYTE*
End Type
' Encoder Parameter structure
Public Type EncoderParameter
GUID As CLSID ' GUID of the parameter
NumberOfValues As Long ' Number of the parameter values; usually 1
type As EncoderParameterValueType ' Value type, like ValueTypeLONG etc.
value As Long ' A pointer to the parameter values
End Type
' Encoder Parameters structure
Public Type EncoderParameters
count As Long ' Number of parameters in this structure; Should be 1
Parameter As EncoderParameter ' Parameter values; this CAN be an array!!!! (Use CopyMemory and a string or byte array as workaround)
End Type
Public Type ColorPalette
flags As PaletteFlags ' Palette flags; should be a Long equivalent
count As Long ' Number of color entries used
Entries(0 To 255) As Long ' Palette color entries. WARNING: SDK defines as 1 entry, but I made it
' contain 256 (a reasonable amount) for use with any palette count 256 or less
' since VB can't malloc and do type casting like C/C++.
End Type
Public Type ColorMap
oldColor As Long ' Color oldColor;
newColor As Long ' Color newColor;
End Type
Public Type ColorMatrix
m(0 To 4, 0 To 4) As Single
End Type
' Information about image pixel data
Public Type BitmapData
Width As Long
Height As Long
stride As Long
PixelFormat As Long
scan0 As Long
Reserved As Long
End Type
Public Type RGBQUAD
rgbBlue As Byte
rgbGreen As Byte
rgbRed As Byte
rgbReserved As Byte
End Type
Public Type BITMAPINFOHEADER '40 bytes
biSize As Long
biWidth As Long
biHeight As Long
biPlanes As Integer
biBitCount As Integer
biCompression As Long
biSizeImage As Long
biXPelsPerMeter As Long
biYPelsPerMeter As Long
biClrUsed As Long
biClrImportant As Long
End Type
Public Type BITMAPINFO
bmiHeader As BITMAPINFOHEADER
bmiColors As RGBQUAD
End Type
Public Type PathData
count As Long
Points As Long ' Pointer to POINTF array
types As Long ' Pointer to BYTE array
End Type
Public Type PropertyItem
propId As Long ' ID of this property
length As Long ' Length of the property value, in bytes
type As Integer ' Type of the value, as one of TAG_TYPE_XXX
' defined above
value As Long ' property value
End Type
Public Type LOGFONTA
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName As String * LF_FACESIZE
End Type
Public Type LOGFONTW
lfHeight As Long
lfWidth As Long
lfEscapement As Long
lfOrientation As Long
lfWeight As Long
lfItalic As Byte
lfUnderline As Byte
lfStrikeOut As Byte
lfCharSet As Byte
lfOutPrecision As Byte
lfClipPrecision As Byte
lfQuality As Byte
lfPitchAndFamily As Byte
lfFaceName As String * LF_FACESIZEW
End Type
Public Type CharacterRange
First As Long
length As Long
End Type
Public Type PWMFRect16
Left As Integer
Top As Integer
Right As Integer
Bottom As Integer
End Type
Public Type WmfPlaceableFileHeader
Key As Long ' GDIP_WMF_PLACEABLEKEY
Hmf As Integer ' Metafile HANDLE number (always 0)
boundingBox As PWMFRect16 ' Coordinates in metafile units
Inch As Integer ' Number of metafile units per inch
Reserved As Long ' Reserved (always 0)
Checksum As Integer ' Checksum value for previous 10 WORDs
End Type
Public Type ENHMETAHEADER3
itype As Long ' Record type EMR_HEADER
nSize As Long ' Record size in bytes. This may be greater
' than the sizeof(ENHMETAHEADER).
rclBounds As RECTL ' Inclusive-inclusive bounds in device units
rclFrame As RECTL ' Inclusive-inclusive Picture Frame .01mm unit
dSignature As Long ' Signature. Must be ENHMETA_SIGNATURE.
nVersion As Long ' Version number
nBytes As Long ' Size of the metafile in bytes
nRecords As Long ' Number of records in the metafile
nHandles As Integer ' Number of handles in the handle table
' Handle index zero is reserved.
sReserved As Integer ' Reserved. Must be zero.
nDescription As Long ' Number of chars in the unicode desc string
' This is 0 if there is no description string
offDescription As Long ' Offset to the metafile description record.
' This is 0 if there is no description string
nPalEntries As Long ' Number of entries in the metafile palette.
szlDevice As SIZEL ' Size of the reference device in pels
szlMillimeters As SIZEL ' Size of the reference device in millimeters
End Type
Public Type METAHEADER
mtType As Integer
mtHeaderSize As Integer
mtVersion As Integer
mtSize As Long
mtNoObjects As Integer
mtMaxRecord As Long
mtNoParameters As Integer
End Type
Public Type MetafileHeader
mType As MetafileType
size As Long ' Size of the metafile (in bytes)
Version As Long ' EMF+, EMF, or WMF version
EmfPlusFlags As Long
DpiX As Single
DpiY As Single
x As Long ' Bounds in device units
y As Long
Width As Long
Height As Long
'Union
'{
' METAHEADER WmfHeader
' ENHMETAHEADER3 EmfHeader
'}
EmfHeader As ENHMETAHEADER3 ' NOTE: You'll have to use CopyMemory to view the METAHEADER type
EmfPlusHeaderSize As Long ' size of the EMF+ header in file
LogicalDpiX As Long ' Logical Dpi of reference Hdc
LogicalDpiY As Long ' usually valid only for EMF+
End Type
'-----------------------------------------------
' GDI+ Enums
'-----------------------------------------------
Public Enum PaletteFlags
PaletteFlagsHasAlpha = &H1
PaletteFlagsGrayScale = &H2
PaletteFlagsHalftone = &H4
End Enum
Public Enum GpUnit ' aka Unit
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.
End Enum
' Common color constants
' NOTE: Oringinal enum was unnamed
Public Enum Colors
AliceBlue = &HFFF0F8FF
AntiqueWhite = &HFFFAEBD7
Aqua = &HFF00FFFF
Aquamarine = &HFF7FFFD4
Azure = &HFFF0FFFF
Beige = &HFFF5F5DC
Bisque = &HFFFFE4C4
Black = &HFF000000
BlanchedAlmond = &HFFFFEBCD
Blue = &HFF0000FF
BlueViolet = &HFF8A2BE2
Brown = &HFFA52A2A
BurlyWood = &HFFDEB887
CadetBlue = &HFF5F9EA0
Chartreuse = &HFF7FFF00
Chocolate = &HFFD2691E
Coral = &HFFFF7F50
CornflowerBlue = &HFF6495ED
Cornsilk = &HFFFFF8DC
Crimson = &HFFDC143C
Cyan = &HFF00FFFF
DarkBlue = &HFF00008B
DarkCyan = &HFF008B8B
DarkGoldenrod = &HFFB8860B
DarkGray = &HFFA9A9A9
DarkGreen = &HFF006400
DarkKhaki = &HFFBDB76B
DarkMagenta = &HFF8B008B
DarkOliveGreen = &HFF556B2F
DarkOrange = &HFFFF8C00
DarkOrchid = &HFF9932CC
DarkRed = &HFF8B0000
DarkSalmon = &HFFE9967A
DarkSeaGreen = &HFF8FBC8B
DarkSlateBlue = &HFF483D8B
DarkSlateGray = &HFF2F4F4F
DarkTurquoise = &HFF00CED1
DarkViolet = &HFF9400D3
DeepPink = &HFFFF1493
DeepSkyBlue = &HFF00BFFF
DimGray = &HFF696969
DodgerBlue = &HFF1E90FF
Firebrick = &HFFB22222
FloralWhite = &HFFFFFAF0
ForestGreen = &HFF228B22
Fuchsia = &HFFFF00FF
Gainsboro = &HFFDCDCDC
GhostWhite = &HFFF8F8FF
Gold = &HFFFFD700
Goldenrod = &HFFDAA520
Gray = &HFF808080
Green = &HFF008000
GreenYellow = &HFFADFF2F
Honeydew = &HFFF0FFF0
HotPink = &HFFFF69B4
IndianRed = &HFFCD5C5C
Indigo = &HFF4B0082
Ivory = &HFFFFFFF0
Khaki = &HFFF0E68C
Lavender = &HFFE6E6FA
LavenderBlush = &HFFFFF0F5
LawnGreen = &HFF7CFC00
LemonChiffon = &HFFFFFACD
LightBlue = &HFFADD8E6
LightCoral = &HFFF08080
LightCyan = &HFFE0FFFF
LightGoldenrodYellow = &HFFFAFAD2
LightGray = &HFFD3D3D3
LightGreen = &HFF90EE90
LightPink = &HFFFFB6C1
LightSalmon = &HFFFFA07A
LightSeaGreen = &HFF20B2AA
LightSkyBlue = &HFF87CEFA
LightSlateGray = &HFF778899
LightSteelBlue = &HFFB0C4DE
LightYellow = &HFFFFFFE0
Lime = &HFF00FF00
LimeGreen = &HFF32CD32
Linen = &HFFFAF0E6
Magenta = &HFFFF00FF
Maroon = &HFF800000
MediumAquamarine = &HFF66CDAA
MediumBlue = &HFF0000CD
MediumOrchid = &HFFBA55D3
MediumPurple = &HFF9370DB
MediumSeaGreen = &HFF3CB371
MediumSlateBlue = &HFF7B68EE
MediumSpringGreen = &HFF00FA9A
MediumTurquoise = &HFF48D1CC
MediumVioletRed = &HFFC71585
MidnightBlue = &HFF191970
MintCream = &HFFF5FFFA
MistyRose = &HFFFFE4E1
Moccasin = &HFFFFE4B5
NavajoWhite = &HFFFFDEAD
Navy = &HFF000080
OldLace = &HFFFDF5E6
Olive = &HFF808000
OliveDrab = &HFF6B8E23
Orange = &HFFFFA500
OrangeRed = &HFFFF4500
Orchid = &HFFDA70D6
PaleGoldenrod = &HFFEEE8AA
PaleGreen = &HFF98FB98
PaleTurquoise = &HFFAFEEEE
PaleVioletRed = &HFFDB7093
PapayaWhip = &HFFFFEFD5
PeachPuff = &HFFFFDAB9
Peru = &HFFCD853F
Pink = &HFFFFC0CB
Plum = &HFFDDA0DD
PowderBlue = &HFFB0E0E6
Purple = &HFF800080
Red = &HFFFF0000
RosyBrown = &HFFBC8F8F
RoyalBlue = &HFF4169E1
SaddleBrown = &HFF8B4513
Salmon = &HFFFA8072
SandyBrown = &HFFF4A460
SeaGreen = &HFF2E8B57
SeaShell = &HFFFFF5EE
Sienna = &HFFA0522D
Silver = &HFFC0C0C0
SkyBlue = &HFF87CEEB
SlateBlue = &HFF6A5ACD
SlateGray = &HFF708090
Snow = &HFFFFFAFA
SpringGreen = &HFF00FF7F
SteelBlue = &HFF4682B4
Tan = &HFFD2B48C
Teal = &HFF008080
Thistle = &HFFD8BFD8
Tomato = &HFFFF6347
Transparent = &HFFFFFF
Turquoise = &HFF40E0D0
Violet = &HFFEE82EE
Wheat = &HFFF5DEB3
White = &HFFFFFFFF
WhiteSmoke = &HFFF5F5F5
Yellow = &HFFFFFF00
YellowGreen = &HFF9ACD32
End Enum
' NOTE: Enums evaluate to a Long
Public Enum GpStatus ' aka Status
Ok = 0
GenericError = 1
InvalidParameter = 2
OutOfMemory = 3
ObjectBusy = 4
InsufficientBuffer = 5
NotImplemented = 6
Win32Error = 7
WrongState = 8
Aborted = 9
FileNotFound = 10
ValueOverflow = 11
AccessDenied = 12
UnknownImageFormat = 13
FontFamilyNotFound = 14
FontStyleNotFound = 15
NotTrueTypeFont = 16
UnsupportedGdiplusVersion = 17
GdiplusNotInitialized = 18
PropertyNotFound = 19
PropertyNotSupported = 20
End Enum
' Quality mode constants
Public Enum QualityMode
QualityModeInvalid = -1
QualityModeDefault = 0
QualityModeLow = 1 ' Best performance
QualityModeHigh = 2 ' Best rendering quality
End Enum
' Alpha Compositing mode constants
Public Enum CompositingMode
CompositingModeSourceOver ' 0
CompositingModeSourceCopy ' 1
End Enum
' Alpha Compositing quality constants
Public Enum CompositingQuality
CompositingQualityInvalid = QualityModeInvalid
CompositingQualityDefault = QualityModeDefault
CompositingQualityHighSpeed = QualityModeLow
CompositingQualityHighQuality = QualityModeHigh
CompositingQualityGammaCorrected
CompositingQualityAssumeLinear
End Enum
' Generic font families
Public Enum GenericFontFamily
GenericFontFamilySerif
GenericFontFamilySansSerif
GenericFontFamilyMonospace
End Enum
' FontStyle: face types and common styles
Public Enum FontStyle
FontStyleRegular = 0
FontStyleBold = 1
FontStyleItalic = 2
FontStyleBoldItalic = 3
FontStyleUnderline = 4
FontStyleStrikeout = 8
End Enum
Public Enum SmoothingMode
SmoothingModeInvalid = QualityModeInvalid
SmoothingModeDefault = QualityModeDefault
SmoothingModeHighSpeed = QualityModeLow
SmoothingModeHighQuality = QualityModeHigh
SmoothingModeNone
SmoothingModeAntiAlias
End Enum
Public Enum FillMode
FillModeAlternate ' 0
FillModeWinding ' 1
End Enum
Public Enum InterpolationMode
InterpolationModeInvalid = QualityModeInvalid
InterpolationModeDefault = QualityModeDefault
InterpolationModeLowQuality = QualityModeLow
InterpolationModeHighQuality = QualityModeHigh
InterpolationModeBilinear
InterpolationModeBicubic
InterpolationModeNearestNeighbor
InterpolationModeHighQualityBilinear
InterpolationModeHighQualityBicubic
End Enum
' Various wrap modes for brushes
Public Enum WrapMode
WrapModeTile ' 0
WrapModeTileFlipX ' 1
WrapModeTileFlipY ' 2
WrapModeTileFlipXY ' 3
WrapModeClamp ' 4
End Enum
Public Enum LinearGradientMode
LinearGradientModeHorizontal ' 0
LinearGradientModeVertical ' 1
LinearGradientModeForwardDiagonal ' 2
LinearGradientModeBackwardDiagonal ' 3
End Enum
Public Enum ImageType
ImageTypeUnknown ' 0
ImageTypeBitmap ' 1
ImageTypeMetafile ' 2
End Enum
' Various Hatch Styles
Public Enum HatchStyle
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