/
gdip.h
1309 lines (1148 loc) · 49.2 KB
/
gdip.h
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
/*
* gdip.h
*
* Authors:
* Alexandre Pigolkine (pigolkine@gmx.de)
* Duncan Mak (duncan@ximian.com)
* Miguel de Icaza (miguel@ximian.com)
* Ravindra (rkumar@novell.com)
* Sanjay Gupta (gsanjay@novell.com)
* Vladimir Vukicevic (vladimir@pobox.com)
* Geoff Norton (gnorton@customerdna.com)
* Jonathan Gilbert (logic@deltaq.org)
*
* Copyright (C) Novell, Inc. 2003-2005. http://www.novell.com
*/
#ifndef _GDIP_H
#define _GDIP_H
#include <stdlib.h>
#include <stdio.h>
#include <glib.h>
#include <unistd.h>
#include "config.h"
#include "pixman.h"
#ifdef USE_INCLUDED_CAIRO
#include <cairo.h>
#else
#include <cairo/cairo.h>
#endif
#include <X11/Xlib.h>
#ifdef CAIRO_HAS_FT_FONT
#ifdef USE_INCLUDED_CAIRO
#include <cairo-ft.h>
#else
#include <cairo/cairo-ft.h>
#endif
#endif
#define gdip_cairo_matrix_copy(m1, m2) memcpy (m1, m2, sizeof (cairo_matrix_t))
#ifdef WORDS_BIGENDIAN
#define set_pixel_bgra(pixel,index,b,g,r,a) do { \
((unsigned char *)(pixel))[index+0] = a; \
((unsigned char *)(pixel))[index+1] = r; \
((unsigned char *)(pixel))[index+2] = g; \
((unsigned char *)(pixel))[index+3] = b; \
} while (0)
#define get_pixel_bgra(color, b, g, r, a) do { \
a = (color & 0x000000ff); \
r = (color & 0x0000ff00) >> 8; \
g = (color & 0x00ff0000) >> 16; \
b = (color & 0xff000000) >> 24; \
} while (0)
#else
#define set_pixel_bgra(pixel,index,b,g,r,a) do { \
((unsigned char *)(pixel))[index+0] = b; \
((unsigned char *)(pixel))[index+1] = g; \
((unsigned char *)(pixel))[index+2] = r; \
((unsigned char *)(pixel))[index+3] = a; \
} while (0)
#define get_pixel_bgra(color, b, g, r, a) do { \
a = ((color & 0xff000000) >> 24); \
r = ((color & 0x00ff0000) >> 16); \
g = ((color & 0x0000ff00) >> 8); \
b = (color & 0x000000ff); \
} while(0)
#endif
#ifdef CAIRO_HAS_XLIB_SURFACE
#ifdef USE_INCLUDED_CAIRO
#include <cairo-xlib.h>
#else
#include <cairo/cairo-xlib.h>
#endif
#endif
/* mono/io-layer/uglify.h also has these typedefs.
* To avoid a dependency on mono we have copied all
* the required stuff here. We don't include our defs
* if uglify.h is included somehow.
*/
#ifndef _WAPI_UGLIFY_H_ /* to avoid conflict with uglify.h */
typedef const gunichar2 *LPCTSTR;
typedef gunichar2 *LPTSTR;
typedef guint8 BYTE;
typedef guint8 *LPBYTE;
typedef guint16 WORD;
typedef guint32 DWORD;
typedef gpointer PVOID;
typedef gpointer LPVOID;
typedef gboolean BOOL;
typedef guint32 *LPDWORD;
typedef gint32 LONG;
typedef guint32 ULONG;
typedef gint32 *PLONG;
typedef guint64 LONGLONG;
typedef gunichar2 TCHAR;
typedef size_t SIZE_T;
typedef gpointer HANDLE;
typedef gpointer *LPHANDLE;
typedef guint32 SOCKET;
typedef gpointer HMODULE;
#define CONST const
#define VOID void
#define IN
#define OUT
#define WINAPI
#endif /* to avoid conflict with uglify.h */
/* Cairo internal extructures and defines*/
#define DOUBLE_TO_26_6(d) ((FT_F26Dot6)((d) * 64.0))
#define DOUBLE_FROM_26_6(t) ((double)(t) / 64.0)
#define DOUBLE_TO_16_16(d) ((FT_Fixed)((d) * 65536.0))
#define DOUBLE_FROM_16_16(t) ((double)(t) / 65536.0)
struct cairo_matrix {
double m[3][2];
};
/*
* Callbacks
*/
typedef int (*ImageAbort) (void *);
typedef ImageAbort DrawImageAbort;
typedef ImageAbort GetThumbnailImageAbort;
/*
* Constants
*
*/
#define PI 3.14159265358979323846
#define DEGTORAD PI / 180.0
#define LF_FACESIZE 32
#define GDIPCONST const
#define CURVE_MIN_TERMS 1
#define CURVE_MAX_TERMS 7
typedef unsigned char byte;
typedef int bool;
typedef guint16 WCHAR; /* 16-bits unicode */
typedef guint32 UINT;
typedef guint32 ARGB;
typedef gint32 PROPID;
#define MAKE_ARGB_RGB(r,g,b) (((r&0xff) << 16) | ((g&0xff) << 8) | (b&0xff))
#define MAKE_ARGB_ARGB(a,r,g,b) (((a&0xff) << 24) | ((r&0xff) << 16) | ((g&0xff) << 8) | (b&0xff))
#define ARGB_RED(argb) ((argb>>16)&0xff)
#define ARGB_GREEN(argb) ((argb>>8)&0xff)
#define ARGB_BLUE(argb) ((argb>>0)&0xff)
#define ARGB_ALPHA(argb) ((argb>>24)&0xff)
/* _N: normalize to 0.0 .. 1.0 */
#define ARGB_RED_N(argb) ((double)((argb>>16)&0xff)/255.0)
#define ARGB_GREEN_N(argb) ((double)((argb>>8)&0xff)/255.0)
#define ARGB_BLUE_N(argb) ((double)((argb>>0)&0xff)/255.0)
#define ARGB_ALPHA_N(argb) ((double)((argb>>24)&0xff)/255.0)
/*
* Enums
*
*/
typedef enum {
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
} GpStatus;
typedef enum {
MatrixOrderPrepend = 0,
MatrixOrderAppend = 1
} MatrixOrder, GpMatrixOrder;
typedef enum {
UnitWorld = 0,
UnitDisplay = 1,
UnitPixel = 2,
UnitPoint = 3,
UnitInch = 4,
UnitDocument = 5,
UnitMillimeter = 6
} GpUnit, Unit;
typedef enum {
DigitSubstituteUser = 0,
DigitSubstituteNone = 1,
DigitSubstituteNational = 2,
DigitSubstituteTraditional = 3
} DigitSubstitute;
/* The pixel format spec is:
* [0-7 format index] [8-15 pixel size, bits] [16-23 flags] [24-31 reserved]
* so,
* (ID | (bpp << 8) | flags)
*/
typedef enum {
PixelFormatAlpha = 0x00040000, /* flag: format has alpha */
PixelFormatCanonical = 0x00200000, /* flag: unknown */
PixelFormatExtended = 0x00100000, /* flag: 16 bits per channel (16bpp grayscale and 48/64bpp rgb) */
PixelFormatGDI = 0x00020000, /* flag: supported by GDI */
PixelFormatIndexed = 0x00010000, /* flag: is palette-indexed */
PixelFormatPAlpha = 0x00080000, /* flag: alpha is pre-multiplied */
Format16bppArgb1555 = 0x00061007,
Format16bppGrayScale = 0x00101004,
Format16bppRgb555 = 0x00021005,
Format16bppRgb565 = 0x00021006,
Format1bppIndexed = 0x0030101,
Format24bppRgb = 0x00021808,
Format32bppArgb = 0x0026200a,
Format32bppPArgb = 0x000e200b,
Format32bppRgb = 0x00022009,
Format48bppRgb = 0x0010300c,
Format4bppIndexed = 0x00030402,
Format64bppArgb = 0x0034400d,
Format64bppPArgb = 0x001c400e,
Format8bppIndexed = 0x00030803,
PixelFormatUndefined = 0,
PixelFormatDontCare = 0
} PixelFormat;
typedef enum {
ImageLockModeRead = 1,
ImageLockModeWrite = 2,
ImageLockModeUserInputBuf = 4
} ImageLockMode;
typedef enum {
FillModeAlternate,
FillModeWinding
} GpFillMode;
typedef enum {
BrushTypeSolidColor = 0, /* Solid Brush */
BrushTypeHatchFill = 1, /* Hatch Brush */
BrushTypeTextureFill = 2, /* Texture Brush */
BrushTypePathGradient = 3, /* PathGradient Brush */
BrushTypeLinearGradient = 4 /* LinearGradient Brush */
} GpBrushType, BrushType;
typedef enum {
PenTypeSolidColor = BrushTypeSolidColor,
PenTypeHatchFill = BrushTypeHatchFill,
PenTypeTextureFill = BrushTypeTextureFill,
PenTypePathGradient = BrushTypePathGradient,
PenTypeLinearGradient = BrushTypeLinearGradient,
PenTypeUnknown = -1
} GpPenType, PenType;
typedef enum {
PenAlignmentCenter = 0,
PenAlignmentInset = 1
} GpPenAlignment, PenAlignment;
typedef enum {
DashStyleSolid = 0, /* solid line */
DashStyleDash = 1, /* dashed line */
DashStyleDot = 2, /* dotted line */
DashStyleDashDot = 3, /* alt. dash-dot */
DashStyleDashDotDot = 4, /* alt. dash-dot-dot */
DashStyleCustom = 5 /* user-defined */
} GpDashStyle;
typedef enum {
DashCapFlat = 0,
DashCapRound = 2,
DashCapTriangle = 3
} GpDashCap;
typedef enum {
LineJoinMiter = 0, /* sharp corner */
LineJoinBevel = 1, /* round corner */
LineJoinRound = 2, /* circular, smooth, circular arc */
LineJoinMiterClipped = 3 /* miter, sharp or beveled corner */
} GpLineJoin;
typedef enum {
LineCapFlat = 0,
LineCapSquare = 1,
LineCapRound = 2,
LineCapTriangle = 3,
LineCapNoAnchor = 0x10,
LineCapSquareAnchor = 0x11,
LineCapRoundAnchor = 0x12,
LineCapDiamondAnchor = 0x13,
LineCapArrowAnchor = 0x14,
LineCapCustom = 0xff
} GpLineCap;
typedef enum {
CustomLineCapTypeDefault = 0,
CustomLineCapTypeAdjustableArrow = 1
} CustomLineCapType;
typedef enum {
imageUndefined,
imageBitmap,
imageMetafile
} ImageType;
typedef enum {
BMP,
TIF,
GIF,
PNG,
JPEG,
EXIF,
WMF,
EMF,
ICON,
INVALID
} ImageFormat;
typedef enum {
gtUndefined,
gtX11Drawable,
gtMemoryBitmap,
gtOSXDrawable
} GraphicsType;
typedef enum{
FontStyleRegular = 0,
FontStyleBold = 1,
FontStyleItalic = 2,
FontStyleUnderline = 4,
FontStyleStrikeout = 8
} GpFontStyle;
typedef enum {
PathPointTypeStart = 0x00,
PathPointTypeLine = 0x01,
PathPointTypeBezier = 0x03,
PathPointTypePathTypeMask = 0x07,
PathPointTypePathDashMode = 0x10,
PathPointTypePathMarker = 0x20,
PathPointTypeCloseSubpath = 0x80,
PathPointTypeBezier3 = 0x03
} GpPathPointType, PathPointType;
typedef enum {
WarpModePerspective = 0,
WarpModeBilinear = 1
} GpWarpMode, WarpMode;
typedef enum {
WrapModeTile = 0,
WrapModeTileFlipX = 1,
WrapModeTileFlipY = 2,
WrapModeTileFlipXY = 3,
WrapModeClamp = 4
} GpWrapMode, WrapMode;
typedef enum {
StringFormatFlagsDirectionRightToLeft = 0x00000001,
StringFormatFlagsDirectionVertical = 0x00000002,
StringFormatFlagsNoFitBlackBox = 0x00000004,
StringFormatFlagsDisplayFormatControl = 0x00000020,
StringFormatFlagsNoFontFallback = 0x00000400,
StringFormatFlagsMeasureTrailingSpaces = 0x00000800,
StringFormatFlagsNoWrap = 0x00001000,
StringFormatFlagsLineLimit = 0x00002000,
StringFormatFlagsNoClip = 0x00004000
} StringFormatFlags;
typedef enum {
StringTrimmingNone = 0,
StringTrimmingCharacter = 1,
StringTrimmingWord = 2,
StringTrimmingEllipsisCharacter = 3,
StringTrimmingEllipsisWord = 4,
StringTrimmingEllipsisPath = 5
} StringTrimming;
typedef enum {
HotkeyPrefixNone = 0,
HotkeyPrefixShow = 1,
HotkeyPrefixHide = 2
} HotkeyPrefix;
typedef enum {
StringAlignmentNear = 0,
StringAlignmentCenter = 1,
StringAlignmentFar = 2
} StringAlignment;
/* Flags and Support structure for MeasureOrDrawString */
#define STRING_DETAIL_TAB (1<<0)
#define STRING_DETAIL_LF (1<<1)
#define STRING_DETAIL_HOTKEY (1<<2)
#define STRING_DETAIL_BREAK (1<<3)
#define STRING_DETAIL_HIDDEN (1<<4)
#define STRING_DETAIL_LINESTART (1<<5)
typedef struct {
unsigned long Flags;
unsigned long Linefeeds;
float PosX; /* We call it X, even though it might become Y for vertical drawing */
float PosY; /* We call it Y, even though it might become X for vertical drawing */
float Width; /* Width of the character; height is defined in font structure */
int LineLen; /* If LineStart how many chars is the line long? */
} GpStringDetailStruct;
typedef enum {
ImageFlagsNone = 0,
ImageFlagsScalable = 1,
ImageFlagsHasAlpha = 2,
ImageFlagsHasTranslucent = 4,
ImageFlagsPartiallyScalable = 8,
ImageFlagsColorSpaceRGB = 16,
ImageFlagsColorSpaceCMYK = 32,
ImageFlagsColorSpaceGRAY = 64,
ImageFlagsColorSpaceYCBCR = 128,
ImageFlagsColorSpaceYCCK = 256,
ImageFlagsHasRealDPI = 4096,
ImageFlagsHasRealPixelSize = 8192,
ImageFlagsReadOnly = 65536,
ImageFlagsCaching = 131072
} ImageFlags;
typedef enum
{
ColorAdjustTypeDefault,
ColorAdjustTypeBitmap,
ColorAdjustTypeBrush,
ColorAdjustTypePen,
ColorAdjustTypeText,
ColorAdjustTypeCount,
ColorAdjustTypeAny
} ColorAdjustType;
typedef enum
{
CombineModeReplace = 0,
CombineModeIntersect = 1,
CombineModeUnion = 2,
CombineModeXor = 3,
CombineModeExclude = 4,
CombineModeComplement = 5
} CombineMode;
typedef enum
{
QualityModeInvalid = -1,
QualityModeDefault = 0,
QualityModeLow = 1,
QualityModeHigh = 2
} QualityMode;
typedef enum
{
InterpolationModeInvalid = QualityModeInvalid,
InterpolationModeDefault = QualityModeDefault,
InterpolationModeLowQuality = QualityModeLow,
InterpolationModeHighQuality = QualityModeHigh,
InterpolationModeBilinear,
InterpolationModeBicubic,
InterpolationModeNearestNeighbor,
InterpolationModeHighQualityBilinear,
InterpolationModeHighQualityBicubic
} InterpolationMode;
typedef enum
{
TextRenderingHintSystemDefault = 0,
TextRenderingHintSingleBitPerPixelGridFit,
TextRenderingHintSingleBitPerPixel,
TextRenderingHintAntiAliasGridFit,
TextRenderingHintAntiAlias,
TextRenderingHintClearTypeGridFit
} TextRenderingHint;
typedef enum
{
PixelOffsetModeInvalid = QualityModeInvalid,
PixelOffsetModeDefault = QualityModeDefault,
PixelOffsetModeHighSpeed = QualityModeLow,
PixelOffsetModeHighQuality = QualityModeHigh,
PixelOffsetModeNone,
PixelOffsetModeHalf
} PixelOffsetMode;
typedef enum
{
SmoothingModeInvalid = QualityModeInvalid,
SmoothingModeDefault = QualityModeDefault,
SmoothingModeHighSpeed = QualityModeLow,
SmoothingModeHighQuality = QualityModeHigh,
SmoothingModeNone,
SmoothingModeAntiAlias
} SmoothingMode;
typedef enum
{
EncoderParameterValueTypeByte = 1,
EncoderParameterValueTypeASCII = 2,
EncoderParameterValueTypeShort = 3,
EncoderParameterValueTypeLong = 4,
EncoderParameterValueTypeRational = 5,
EncoderParameterValueTypeLongRange = 6,
EncoderParameterValueTypeUndefined = 7,
EncoderParameterValueTypeRationalRange = 8
} EncoderParameterValueType;
typedef enum
{
BlockingDecode = 32,
Builtin = 65536,
Decoder = 2,
Encoder = 1,
SeekableEncode = 16,
SupportBitmap = 4,
SupportVector = 8,
System = 131072,
User = 262144
} ImageCodecFlags;
typedef enum {
CoordinateSpaceWorld,
CoordinateSpacePage,
CoordinateSpaceDevice
} GpCoordinateSpace;
typedef enum {
FlushIntentionFlush=0,
FlushIntentionSync=1
} GpFlushIntention;
typedef enum {
CompositingModeSourceOver,
CompositingModeSourceCopy
} GpCompositingMode;
typedef enum {
CompositingQualityInvalid = QualityModeInvalid,
CompositingQualityDefault = QualityModeDefault,
CompositingQualityHighSpeed = QualityModeLow,
CompositingQualityHighQuality = QualityModeHigh,
CompositingQualityGammaCorrected,
CompositingQualityAssumeLinear
} GpCompositingQuality;
typedef enum {
ColorMatrixFlagsDefault = 0,
ColorMatrixFlagsSkipGrays = 1,
ColorMatrixFlagsAltGray = 2
} GpColorMatrixFlags;
typedef struct {
float m[5][5];
} GpColorMatrix;
/* FIXME - This should match the GdiPlus color object */
typedef struct {
ARGB Color;
} GpColor;
typedef struct {
GpColor oldColor;
GpColor newColor;
} GpColorMap;
typedef enum {
ColorChannelFlagsC = 0,
ColorChannelFlagsM,
ColorChannelFlagsY,
ColorChannelFlagsK,
ColorChannelFlagsLast
} GpColorChannelFlags;
typedef struct {
int unused;
} GpGraphicsContainer;
/* private enum */
typedef enum {
CURVE_OPEN,
CURVE_CLOSE
} _CurveType;
typedef enum {
RegionTypeEmpty = 0,
RegionTypeRect = 1,
RegionTypeRectF = 2,
RegionTypePath = 3
} RegionType;
typedef enum {
X11DRV_GET_DISPLAY, /* get X11 display for a DC */
X11DRV_GET_DRAWABLE, /* get current drawable for a DC */
X11DRV_GET_FONT /* get current X font for a DC */
} x11drv_escape_codes;
/*
* Structures
*
*/
#define GBD_OWN_SCAN0 (1<<8)
#define GBD_READ_ONLY (1<<9)
#define GBD_LOCKED (1<<10)
typedef struct { /* Keep in sync with BitmapData.cs */
unsigned int Width;
unsigned int Height;
int Stride;
int PixelFormat;
byte* Scan0;
unsigned int Reserved;
/*Added to keep track of position for displaying next frame
in a gif*/
unsigned int Top;
unsigned int Left;
int ByteCount;
char* Bytes;
} GdipBitmapData, BitmapData;
typedef struct {
int X, Y, Width, Height;
} GpRect, Rect;
typedef struct {
float X, Y, Width, Height;
} GpRectF, RectF;
typedef struct {
int X, Y;
} GpPoint, Point;
typedef struct {
float X, Y;
} GpPointF, PointF;
typedef struct {
GpRectF* rects;
int cnt;
} GpRegion;
typedef struct {
int first, length;
} CharacterRange;
typedef struct _CustomLineCap GpCustomLineCap;
typedef struct _AdjustableArrowCap GpAdjustableArrowCap;
typedef struct _Brush GpBrush;
typedef cairo_matrix_t GpMatrix;
typedef struct {
int color;
GpBrush *brush;
BOOL own_brush;
float width;
float miter_limit;
GpLineJoin line_join;
GpDashStyle dash_style;
GpLineCap line_cap; /* Cairo supports only same kind of end caps for both the ends. */
GpLineCap end_cap;
int compound_count;
float *compound_array;
GpPenAlignment mode;
float dash_offset;
int dash_count;
BOOL own_dash_array; /* flag to mark if pen maintains its own array or global array */
float *dash_array;
GpUnit unit; /* Always set to UnitWorld. */
GpMatrix *matrix;
BOOL changed; /* flag to mark if pen is changed and needs setup */
} GpPen;
typedef struct {
cairo_matrix_t matrix;
GpRegion* clip;
GpCompositingMode composite_mode;
GpCompositingQuality composite_quality;
InterpolationMode interpolation;
GpUnit page_unit;
float scale;
SmoothingMode draw_mode;
TextRenderingHint text_mode;
PixelOffsetMode pixel_mode;
int org_x;
int org_y;
} GpState;
typedef struct {
cairo_t *ct;
GpMatrix *copy_of_ctm;
Display *display;
Drawable drawable;
void *image;
int type;
GpRegion* clip;
GpRect bounds;
GpUnit page_unit;
float scale;
InterpolationMode interpolation;
GpPen* last_pen; /* caching pen and brush to avoid unnecessary sets */
GpBrush* last_brush;
SmoothingMode draw_mode;
TextRenderingHint text_mode;
GpState* saved_status;
int saved_status_pos;
GpCompositingMode composite_mode;
GpCompositingQuality composite_quality;
PixelOffsetMode pixel_mode;
} GpGraphics;
typedef struct {
UINT Flags;
UINT Count;
ARGB Entries[1];
} ColorPalette;
typedef struct {
DWORD Data1;
WORD Data2;
WORD Data3;
byte Data4 [8];
} GUID, Guid, CLSID;
typedef struct {
GUID Guid;
ULONG NumberOfValues;
EncoderParameterValueType Type;
VOID* Value;
} EncoderParameter;
typedef struct {
UINT Count;
EncoderParameter Parameter[1];
} EncoderParameters;
typedef struct {
PROPID id;
ULONG length;
WORD type;
VOID* value;
} PropertyItem;
typedef struct {
GUID frameDimension;
int count;
BitmapData *frames;
} FrameInfo;
typedef struct {
ImageType type;
cairo_surface_t *surface;
int imageFlags;
int height;
int width;
float horizontalResolution;
ColorPalette *palette;
int pixFormat;
PropertyItem *propItems;
float verticalResolution;
ImageFormat format;
int frameDimensionCount;
FrameInfo *frameDimensionList;
} GpImage;
typedef struct {
GpImage image;
int cairo_format;
BitmapData data;
void *hBitmapDC;
void *hInitialBitmap;
void *hBitmap;
} GpBitmap;
typedef struct {
GpFillMode fill_mode;
int count;
GByteArray *types;
GArray *points;
BOOL start_new_fig; /* Flag to keep track if we need to start a new figure */
} GpPath;
typedef struct {
int Count;
PointF *Points;
byte *Types;
} GpPathData;
typedef struct {
GpPath *path;
int markerPosition; /* The start position of next marker, index of (marker type) + 1 */
int subpathPosition; /* The start position of next subpath, index of (start type) */
int pathTypePosition; /* The position to get the next path type inside a subpath */
} GpPathIterator;
typedef struct {
FcFontSet* fontset;
/* Only for private collections */
FcConfig* config;
} GpFontCollection;
typedef struct {
FcPattern* pattern;
bool allocated;
short height;
short linespacing;
short celldescent;
short cellascent;
} GpFontFamily;
typedef struct {
cairo_font_face_t* cairofnt;
float sizeInPixels;
GpFontStyle style;
void *wineHfont;
} GpFont;
typedef struct
{
char szFamily [128];
float sizeInPixels;
GpFontStyle style;
GpFont * font;
int refcount;
} GpCachedFont;
typedef struct {
StringAlignment alignment;
StringAlignment lineAlignment;
HotkeyPrefix hotkeyPrefix;
StringFormatFlags formatFlags;
StringTrimming trimming;
DigitSubstitute substitute;
CharacterRange *charRanges;
float firstTabOffset;
float *tabStops;
int numtabStops;
int charRangeCount;
} GpStringFormat;
typedef struct {
float X, Y;
float width;
} GpLinePointF;
typedef struct {
GpColorMap *colormap;
int colormap_elem;
float gamma_correction;
ARGB key_colorlow;
ARGB key_colorhigh;
BOOL key_enabled;
BOOL no_op;
GpColorMatrix *colormatrix;
BOOL colormatrix_enabled;
} GpImageAttribute;
typedef struct {
GpImageAttribute def;
GpImageAttribute bitmap;
GpImageAttribute brush;
GpImageAttribute pen;
GpImageAttribute text;
/* Globals */
WrapMode wrapmode;
ARGB color;
} GpImageAttributes;
typedef struct {
CLSID Clsid;
GUID FormatID;
const WCHAR* CodecName;
const WCHAR* DllName;
const WCHAR* FormatDescription;
const WCHAR* FilenameExtension;
const WCHAR* MimeType;
DWORD Flags;
DWORD Version;
DWORD SigCount;
DWORD SigSize;
const BYTE* SigPattern;
const BYTE* SigMask;
} ImageCodecInfo;
/*
* Functions
*
*/
void gdip_image_init (GpImage *image);
void gdip_bitmap_init (GpBitmap *bitmap);
GpBitmap *gdip_bitmap_new (void);
void gdip_bitmap_dispose (GpBitmap *bitmap);
void gdip_bitmap_clone (GpBitmap *bitmap, GpBitmap **clonedbitmap);
void gdip_graphics_init (GpGraphics *graphics, cairo_surface_t *surface);
GpGraphics *gdip_graphics_new (cairo_surface_t *surface);
GpStatus gdip_bitmap_clone_data_rect (GdipBitmapData *srcData, Rect *srcRect, GdipBitmapData *destData, Rect *destRect);
GpStatus gdip_bitmap_change_rect_pixel_format (GdipBitmapData *srcData, Rect *srcRect, GdipBitmapData *destData, Rect *destRect);
int gdip_from_RGB_to_ARGB (BYTE *src, int width, int height, int stride, BYTE **dest, int* dest_stride);
int gdip_from_ARGB_to_RGB (BYTE *src, int width, int height, int stride, BYTE **dest, int* dest_stride);
/* Pen */
void gdip_pen_init (GpPen *pen);
GpPen *gdip_pen_new (void);
GpStatus gdip_pen_setup (GpGraphics *graphics, GpPen *pen);
void initCodecList (void);
void releaseCodecList (void);
void gdip_process_bitmap_attributes (GpBitmap *bitmap, void **dest, GpImageAttributes* attr, bool *allocated);
/* Bitmap */
GpStatus GdipCreateBitmapFromFile(GDIPCONST WCHAR* filename, GpBitmap **bitmap);
GpStatus GdipCreateBitmapFromFileICM(GDIPCONST WCHAR* filename, GpBitmap **bitmap);
GpStatus GdipCreateBitmapFromScan0 (int width, int height, int strideIn, int format, void *scan0, GpBitmap **bitmap);
GpStatus GdipCreateBitmapFromGraphics (int width, int height, GpGraphics *graphics, GpBitmap **bitmap);
GpStatus GdipBitmapLockBits (GpBitmap *bmp, Rect *rc, int flags, int format, GdipBitmapData *result);
GpStatus GdipBitmapUnlockBits (GpBitmap *bmp, GdipBitmapData *bmpData);
GpStatus GdipBitmapSetPixel ( GpBitmap *bmp, int x, int y, ARGB color);
GpStatus GdipBitmapGetPixel ( GpBitmap *bmp, int x, int y, ARGB *color);
/* Graphics */
GpStatus GdipCreateFromHDC (void *hDC, GpGraphics **graphics);
GpStatus GdipDeleteGraphics (GpGraphics *graphics);
GpStatus GdipGetDC (GpGraphics *graphics, void **hDC);
GpStatus GdipReleaseDC (GpGraphics *graphics, void *hDC);
GpStatus GdipRestoreGraphics (GpGraphics *graphics, unsigned int graphicsState);
GpStatus GdipSaveGraphics(GpGraphics *graphics, unsigned int * state);
GpStatus GdipRotateWorldTransform (GpGraphics *graphics, float angle, GpMatrixOrder order);
GpStatus GdipTranslateWorldTransform (GpGraphics *graphics, float dx, float dy, GpMatrixOrder order);
GpStatus GdipDrawBezier (GpGraphics *graphics, GpPen *pen, float x1, float y1, float x2, float y2, float x3, float y3, float x4, float y4);
GpStatus GdipDrawBezierI (GpGraphics *graphics, GpPen *pen, int x1, int y1, int x2, int y2, int x3, int y3, int x4, int y4);
GpStatus GdipDrawBeziers (GpGraphics *graphics, GpPen *pen, GpPointF *points, int count);
GpStatus GdipDrawBeziersI (GpGraphics *graphics, GpPen *pen, GpPoint *points, int count);
GpStatus GdipDrawCurve (GpGraphics *graphics, GpPen *pen, GpPointF *points, int count);
GpStatus GdipDrawCurveI (GpGraphics *graphics, GpPen *pen, GpPoint *points, int count);
GpStatus GdipDrawCurve2 (GpGraphics *graphics, GpPen *pen, GpPointF *points, int count, float tension);
GpStatus GdipDrawCurve2I (GpGraphics *graphics, GpPen *pen, GpPoint *points, int count, float tension);
GpStatus GdipDrawCurve3 (GpGraphics *graphics, GpPen *pen, GpPointF *points, int count, int offset, float numOfSegments, float tension);
GpStatus GdipDrawCurve3I (GpGraphics *graphics, GpPen *pen, GpPoint *points, int count, int offset, float numOfSegments, float tension);
GpStatus GdipDrawClosedCurve (GpGraphics *graphics, GpPen *pen, GpPointF *points, int count);
GpStatus GdipDrawClosedCurveI (GpGraphics *graphics, GpPen *pen, GpPoint *points, int count);
GpStatus GdipDrawClosedCurve2 (GpGraphics *graphics, GpPen *pen, GpPointF *points, int count, float tension);
GpStatus GdipDrawClosedCurve2I (GpGraphics *graphics, GpPen *pen, GpPoint *points, int count, float tension);
GpStatus GdipDrawEllipse (GpGraphics *graphics, GpPen *pen, float x, float y, float width, float height);
GpStatus GdipDrawImage (GpGraphics *graphics, GpImage *image, float x, float y);
GpStatus GdipDrawImageI (GpGraphics *graphics, GpImage *image, int x, int y);
GpStatus GdipDrawImageRect (GpGraphics *graphics, GpImage *image, float x, float y, float width, float height);
GpStatus GdipDrawImageRectI (GpGraphics *graphics, GpImage *image, int x, int y, int width, int height);
GpStatus GdipDrawImagePoints (GpGraphics *graphics, GpImage *image, GDIPCONST GpPointF *dstPoints, int count);
GpStatus GdipDrawImagePointsI (GpGraphics *graphics, GpImage *image, GDIPCONST GpPoint *dstPoints, int count);
GpStatus GdipDrawImagePointRect (GpGraphics *graphics, GpImage *image, float x, float y, float srcx, float srcy, float srcwidth, float srcheight, GpUnit srcUnit);
GpStatus GdipDrawImagePointRectI (GpGraphics *graphics, GpImage *image, int x, int y, int srcx, int srcy, int srcwidth, int srcheight, GpUnit srcUnit);
GpStatus GdipDrawImageRectRect (GpGraphics *graphics, GpImage *image, float dstx, float dsty, float dstwidth, float dstheight, float srcx, float srcy, float srcwidth, float srcheight, GpUnit srcUnit, GDIPCONST GpImageAttributes *imageAttributes, DrawImageAbort callback, void *callbackData);
GpStatus GdipDrawImageRectRectI (GpGraphics *graphics, GpImage *image, int dstx, int dsty, int dstwidth, int dstheight, int srcx, int srcy, int srcwidth, int srcheight, GpUnit srcUnit, GDIPCONST GpImageAttributes *imageAttributes, DrawImageAbort callback, void *callbackData);
GpStatus GdipDrawImagePointsRect (GpGraphics *graphics, GpImage *image, GDIPCONST GpPointF *points, int count, float srcx, float srcy, float srcwidth, float srcheight, GpUnit srcUnit, GDIPCONST GpImageAttributes *imageAttributes, DrawImageAbort callback, void *callbackData);
GpStatus GdipDrawImagePointsRectI (GpGraphics *graphics, GpImage *image, GDIPCONST GpPoint *points, int count, int srcx, int srcy, int srcwidth, int srcheight, GpUnit srcUnit, GDIPCONST GpImageAttributes *imageAttributes, DrawImageAbort callback, void *callbackData);
GpStatus GdipDrawLine (GpGraphics *graphics, GpPen *pen, float x1, float y1, float x2, float y2);
GpStatus GdipDrawLineI (GpGraphics *graphics, GpPen *pen, int x1, int y1, int x2, int y2);
GpStatus GdipDrawLines (GpGraphics *graphics, GpPen *pen, GpPointF *points, int count);