1 ///////////////////////////////////////////////////////////////////////////////
2 // Name:        src/msw/gdiplus.cpp
3 // Purpose:     implements wrappers for GDI+ flat API
4 // Author:      Vadim Zeitlin
5 // Created:     2007-03-14
6 // Copyright:   (c) 2007 Vadim Zeitlin <vadim@wxwindows.org>
7 // Licence:     wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
9 
10 // ============================================================================
11 // declarations
12 // ============================================================================
13 
14 // ----------------------------------------------------------------------------
15 // headers
16 // ----------------------------------------------------------------------------
17 
18 // for compilers that support precompilation, includes "wx.h".
19 #include "wx/wxprec.h"
20 
21 #ifdef __BORLANDC__
22     #pragma hdrstop
23 #endif
24 
25 #if wxUSE_GRAPHICS_CONTEXT
26 
27 #ifndef WX_PRECOMP
28     #include "wx/cpp.h"
29     #include "wx/log.h"
30     #include "wx/module.h"
31     #include "wx/string.h"
32 #endif // WX_PRECOMP
33 
34 #include "wx/dynload.h"
35 
36 #include "wx/msw/wrapgdip.h"
37 
38 // w32api headers used by both MinGW and Cygwin wrongly define UINT16 inside
39 // Gdiplus namespace in gdiplus.h which results in ambiguity errors when using
40 // this type as UINT16 is also defined in global scope by windows.h (or rather
41 // basetsd.h included from it), so we redefine it to work around this problem.
42 #if defined(__CYGWIN__) || defined(__MINGW32__)
43     #define UINT16 unsigned short
44 #endif
45 
46 // ----------------------------------------------------------------------------
47 // helper macros
48 // ----------------------------------------------------------------------------
49 
50 // return the name we use for the type of the function with the given name
51 // (without "Gdip" prefix)
52 #define wxGDIPLUS_FUNC_T(name) Gdip##name##_t
53 
54 // to avoid repeating all (several hundreds) of GDI+ functions names several
55 // times in this file, we define a macro which allows us to apply another macro
56 // to all (or almost all, as we sometimes have to handle functions not
57 // returning GpStatus separately) these functions at once
58 
59 // this macro expands into an invocation of the given macro m for all GDI+
60 // functions returning standard GpStatus
61 //
62 // m is called with the name of the function without "Gdip" prefix as the first
63 // argument, the list of function parameters with their names as the second one
64 // and the list of just the parameter names as the third one
65 #define wxFOR_ALL_GDIPLUS_STATUS_FUNCS(m) \
66     m(CreatePath, (GpFillMode brushMode, GpPath **path), (brushMode, path)) \
67     m(CreatePath2, (GDIPCONST GpPointF* a1, GDIPCONST BYTE* a2, INT a3, GpFillMode a4, GpPath **path), (a1, a2, a3, a4, path)) \
68     m(CreatePath2I, (GDIPCONST GpPoint* a1, GDIPCONST BYTE* a2, INT a3, GpFillMode a4, GpPath **path), (a1, a2, a3, a4, path)) \
69     m(ClonePath, (GpPath* path, GpPath **clonePath), (path, clonePath)) \
70     m(DeletePath, (GpPath* path), (path)) \
71     m(ResetPath, (GpPath* path), (path)) \
72     m(GetPointCount, (GpPath* path, INT* count), (path, count)) \
73     m(GetPathTypes, (GpPath* path, BYTE* types, INT count), (path, types, count)) \
74     m(GetPathPoints, (GpPath* a1, GpPointF* points, INT count), (a1, points, count)) \
75     m(GetPathPointsI, (GpPath* a1, GpPoint* points, INT count), (a1, points, count)) \
76     m(GetPathFillMode, (GpPath *path, GpFillMode *fillmode), (path, fillmode)) \
77     m(SetPathFillMode, (GpPath *path, GpFillMode fillmode), (path, fillmode)) \
78     m(GetPathData, (GpPath *path, GpPathData* pathData), (path, pathData)) \
79     m(StartPathFigure, (GpPath *path), (path)) \
80     m(ClosePathFigure, (GpPath *path), (path)) \
81     m(ClosePathFigures, (GpPath *path), (path)) \
82     m(SetPathMarker, (GpPath* path), (path)) \
83     m(ClearPathMarkers, (GpPath* path), (path)) \
84     m(ReversePath, (GpPath* path), (path)) \
85     m(GetPathLastPoint, (GpPath* path, GpPointF* lastPoint), (path, lastPoint)) \
86     m(AddPathLine, (GpPath *path, REAL x1, REAL y1, REAL x2, REAL y2), (path, x1, y1, x2, y2)) \
87     m(AddPathLine2, (GpPath *path, GDIPCONST GpPointF *points, INT count), (path, points, count)) \
88     m(AddPathArc, (GpPath *path, REAL x, REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle), (path, x, y, width, height, startAngle, sweepAngle)) \
89     m(AddPathBezier, (GpPath *path, REAL x1, REAL y1, REAL x2, REAL y2, REAL x3, REAL y3, REAL x4, REAL y4), (path, x1, y1, x2, y2, x3, y3, x4, y4)) \
90     m(AddPathBeziers, (GpPath *path, GDIPCONST GpPointF *points, INT count), (path, points, count)) \
91     m(AddPathCurve, (GpPath *path, GDIPCONST GpPointF *points, INT count), (path, points, count)) \
92     m(AddPathCurve2, (GpPath *path, GDIPCONST GpPointF *points, INT count, REAL tension), (path, points, count, tension)) \
93     m(AddPathCurve3, (GpPath *path, GDIPCONST GpPointF *points, INT count, INT offset, INT numberOfSegments, REAL tension), (path, points, count, offset, numberOfSegments, tension)) \
94     m(AddPathClosedCurve, (GpPath *path, GDIPCONST GpPointF *points, INT count), (path, points, count)) \
95     m(AddPathClosedCurve2, (GpPath *path, GDIPCONST GpPointF *points, INT count, REAL tension), (path, points, count, tension)) \
96     m(AddPathRectangle, (GpPath *path, REAL x, REAL y, REAL width, REAL height), (path, x, y, width, height)) \
97     m(AddPathRectangles, (GpPath *path, GDIPCONST GpRectF *rects, INT count), (path, rects, count)) \
98     m(AddPathEllipse, (GpPath *path, REAL x, REAL y, REAL width, REAL height), (path, x, y, width, height)) \
99     m(AddPathPie, (GpPath *path, REAL x, REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle), (path, x, y, width, height, startAngle, sweepAngle)) \
100     m(AddPathPolygon, (GpPath *path, GDIPCONST GpPointF *points, INT count), (path, points, count)) \
101     m(AddPathPath, (GpPath *path, GDIPCONST GpPath* addingPath, BOOL connect), (path, addingPath, connect)) \
102     m(AddPathString, (GpPath *path, GDIPCONST WCHAR *string, INT length, GDIPCONST GpFontFamily *family, INT style, REAL emSize, GDIPCONST RectF *layoutRect, GDIPCONST GpStringFormat *format), (path, string, length, family, style, emSize, layoutRect, format)) \
103     m(AddPathStringI, (GpPath *path, GDIPCONST WCHAR *string, INT length, GDIPCONST GpFontFamily *family, INT style, REAL emSize, GDIPCONST Rect *layoutRect, GDIPCONST GpStringFormat *format), (path, string, length, family, style, emSize, layoutRect, format)) \
104     m(AddPathLineI, (GpPath *path, INT x1, INT y1, INT x2, INT y2), (path, x1, y1, x2, y2)) \
105     m(AddPathLine2I, (GpPath *path, GDIPCONST GpPoint *points, INT count), (path, points, count)) \
106     m(AddPathArcI, (GpPath *path, INT x, INT y, INT width, INT height, REAL startAngle, REAL sweepAngle), (path, x, y, width, height, startAngle, sweepAngle)) \
107     m(AddPathBezierI, (GpPath *path, INT x1, INT y1, INT x2, INT y2, INT x3, INT y3, INT x4, INT y4), (path, x1, y1, x2, y2, x3, y3, x4, y4)) \
108     m(AddPathBeziersI, (GpPath *path, GDIPCONST GpPoint *points, INT count), (path, points, count)) \
109     m(AddPathCurveI, (GpPath *path, GDIPCONST GpPoint *points, INT count), (path, points, count)) \
110     m(AddPathCurve2I, (GpPath *path, GDIPCONST GpPoint *points, INT count, REAL tension), (path, points, count, tension)) \
111     m(AddPathCurve3I, (GpPath *path, GDIPCONST GpPoint *points, INT count, INT offset, INT numberOfSegments, REAL tension), (path, points, count, offset, numberOfSegments, tension)) \
112     m(AddPathClosedCurveI, (GpPath *path, GDIPCONST GpPoint *points, INT count), (path, points, count)) \
113     m(AddPathClosedCurve2I, (GpPath *path, GDIPCONST GpPoint *points, INT count, REAL tension), (path, points, count, tension)) \
114     m(AddPathRectangleI, (GpPath *path, INT x, INT y, INT width, INT height), (path, x, y, width, height)) \
115     m(AddPathRectanglesI, (GpPath *path, GDIPCONST GpRect *rects, INT count), (path, rects, count)) \
116     m(AddPathEllipseI, (GpPath *path, INT x, INT y, INT width, INT height), (path, x, y, width, height)) \
117     m(AddPathPieI, (GpPath *path, INT x, INT y, INT width, INT height, REAL startAngle, REAL sweepAngle), (path, x, y, width, height, startAngle, sweepAngle)) \
118     m(AddPathPolygonI, (GpPath *path, GDIPCONST GpPoint *points, INT count), (path, points, count)) \
119     m(FlattenPath, (GpPath *path, GpMatrix* matrix, REAL flatness), (path, matrix, flatness)) \
120     m(WindingModeOutline, (GpPath *path, GpMatrix *matrix, REAL flatness), (path, matrix, flatness)) \
121     m(WidenPath, (GpPath *nativePath, GpPen *pen, GpMatrix *matrix, REAL flatness), (nativePath, pen, matrix, flatness)) \
122     m(WarpPath, (GpPath *path, GpMatrix* matrix, GDIPCONST GpPointF *points, INT count, REAL srcx, REAL srcy, REAL srcwidth, REAL srcheight, WarpMode warpMode, REAL flatness), (path, matrix, points, count, srcx, srcy, srcwidth, srcheight, warpMode, flatness)) \
123     m(TransformPath, (GpPath* path, GpMatrix* matrix), (path, matrix)) \
124     m(GetPathWorldBounds, (GpPath* path, GpRectF* bounds, GDIPCONST GpMatrix *matrix, GDIPCONST GpPen *pen), (path, bounds, matrix, pen)) \
125     m(GetPathWorldBoundsI, (GpPath* path, GpRect* bounds, GDIPCONST GpMatrix *matrix, GDIPCONST GpPen *pen), (path, bounds, matrix, pen)) \
126     m(IsVisiblePathPoint, (GpPath* path, REAL x, REAL y, GpGraphics *graphics, BOOL *result), (path, x, y, graphics, result)) \
127     m(IsVisiblePathPointI, (GpPath* path, INT x, INT y, GpGraphics *graphics, BOOL *result), (path, x, y, graphics, result)) \
128     m(IsOutlineVisiblePathPoint, (GpPath* path, REAL x, REAL y, GpPen *pen, GpGraphics *graphics, BOOL *result), (path, x, y, pen, graphics, result)) \
129     m(IsOutlineVisiblePathPointI, (GpPath* path, INT x, INT y, GpPen *pen, GpGraphics *graphics, BOOL *result), (path, x, y, pen, graphics, result)) \
130     m(CreatePathIter, (GpPathIterator **iterator, GpPath* path), (iterator, path)) \
131     m(DeletePathIter, (GpPathIterator *iterator), (iterator)) \
132     m(PathIterNextSubpath, (GpPathIterator* iterator, INT *resultCount, INT* startIndex, INT* endIndex, BOOL* isClosed), (iterator, resultCount, startIndex, endIndex, isClosed)) \
133     m(PathIterNextSubpathPath, (GpPathIterator* iterator, INT* resultCount, GpPath* path, BOOL* isClosed), (iterator, resultCount, path, isClosed)) \
134     m(PathIterNextPathType, (GpPathIterator* iterator, INT* resultCount, BYTE* pathType, INT* startIndex, INT* endIndex), (iterator, resultCount, pathType, startIndex, endIndex)) \
135     m(PathIterNextMarker, (GpPathIterator* iterator, INT *resultCount, INT* startIndex, INT* endIndex), (iterator, resultCount, startIndex, endIndex)) \
136     m(PathIterNextMarkerPath, (GpPathIterator* iterator, INT* resultCount, GpPath* path), (iterator, resultCount, path)) \
137     m(PathIterGetCount, (GpPathIterator* iterator, INT* count), (iterator, count)) \
138     m(PathIterGetSubpathCount, (GpPathIterator* iterator, INT* count), (iterator, count)) \
139     m(PathIterIsValid, (GpPathIterator* iterator, BOOL* valid), (iterator, valid)) \
140     m(PathIterHasCurve, (GpPathIterator* iterator, BOOL* hasCurve), (iterator, hasCurve)) \
141     m(PathIterRewind, (GpPathIterator* iterator), (iterator)) \
142     m(PathIterEnumerate, (GpPathIterator* iterator, INT* resultCount, GpPointF *points, BYTE *types, INT count), (iterator, resultCount, points, types, count)) \
143     m(PathIterCopyData, (GpPathIterator* iterator, INT* resultCount, GpPointF* points, BYTE* types, INT startIndex, INT endIndex), (iterator, resultCount, points, types, startIndex, endIndex)) \
144     m(CreateMatrix, (GpMatrix **matrix), (matrix)) \
145     m(CreateMatrix2, (REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy, GpMatrix **matrix), (m11, m12, m21, m22, dx, dy, matrix)) \
146     m(CreateMatrix3, (GDIPCONST GpRectF *rect, GDIPCONST GpPointF *dstplg, GpMatrix **matrix), (rect, dstplg, matrix)) \
147     m(CreateMatrix3I, (GDIPCONST GpRect *rect, GDIPCONST GpPoint *dstplg, GpMatrix **matrix), (rect, dstplg, matrix)) \
148     m(CloneMatrix, (GpMatrix *matrix, GpMatrix **cloneMatrix), (matrix, cloneMatrix)) \
149     m(DeleteMatrix, (GpMatrix *matrix), (matrix)) \
150     m(SetMatrixElements, (GpMatrix *matrix, REAL m11, REAL m12, REAL m21, REAL m22, REAL dx, REAL dy), (matrix, m11, m12, m21, m22, dx, dy)) \
151     m(MultiplyMatrix, (GpMatrix *matrix, GpMatrix* matrix2, GpMatrixOrder order), (matrix, matrix2, order)) \
152     m(TranslateMatrix, (GpMatrix *matrix, REAL offsetX, REAL offsetY, GpMatrixOrder order), (matrix, offsetX, offsetY, order)) \
153     m(ScaleMatrix, (GpMatrix *matrix, REAL scaleX, REAL scaleY, GpMatrixOrder order), (matrix, scaleX, scaleY, order)) \
154     m(RotateMatrix, (GpMatrix *matrix, REAL angle, GpMatrixOrder order), (matrix, angle, order)) \
155     m(ShearMatrix, (GpMatrix *matrix, REAL shearX, REAL shearY, GpMatrixOrder order), (matrix, shearX, shearY, order)) \
156     m(InvertMatrix, (GpMatrix *matrix), (matrix)) \
157     m(TransformMatrixPoints, (GpMatrix *matrix, GpPointF *pts, INT count), (matrix, pts, count)) \
158     m(TransformMatrixPointsI, (GpMatrix *matrix, GpPoint *pts, INT count), (matrix, pts, count)) \
159     m(VectorTransformMatrixPoints, (GpMatrix *matrix, GpPointF *pts, INT count), (matrix, pts, count)) \
160     m(VectorTransformMatrixPointsI, (GpMatrix *matrix, GpPoint *pts, INT count), (matrix, pts, count)) \
161     m(GetMatrixElements, (GDIPCONST GpMatrix *matrix, REAL *matrixOut), (matrix, matrixOut)) \
162     m(IsMatrixInvertible, (GDIPCONST GpMatrix *matrix, BOOL *result), (matrix, result)) \
163     m(IsMatrixIdentity, (GDIPCONST GpMatrix *matrix, BOOL *result), (matrix, result)) \
164     m(IsMatrixEqual, (GDIPCONST GpMatrix *matrix, GDIPCONST GpMatrix *matrix2, BOOL *result), (matrix, matrix2, result)) \
165     m(CreateRegion, (GpRegion **region), (region)) \
166     m(CreateRegionRect, (GDIPCONST GpRectF *rect, GpRegion **region), (rect, region)) \
167     m(CreateRegionRectI, (GDIPCONST GpRect *rect, GpRegion **region), (rect, region)) \
168     m(CreateRegionPath, (GpPath *path, GpRegion **region), (path, region)) \
169     m(CreateRegionRgnData, (GDIPCONST BYTE *regionData, INT size, GpRegion **region), (regionData, size, region)) \
170     m(CreateRegionHrgn, (HRGN hRgn, GpRegion **region), (hRgn, region)) \
171     m(CloneRegion, (GpRegion *region, GpRegion **cloneRegion), (region, cloneRegion)) \
172     m(DeleteRegion, (GpRegion *region), (region)) \
173     m(SetInfinite, (GpRegion *region), (region)) \
174     m(SetEmpty, (GpRegion *region), (region)) \
175     m(CombineRegionRect, (GpRegion *region, GDIPCONST GpRectF *rect, CombineMode combineMode), (region, rect, combineMode)) \
176     m(CombineRegionRectI, (GpRegion *region, GDIPCONST GpRect *rect, CombineMode combineMode), (region, rect, combineMode)) \
177     m(CombineRegionPath, (GpRegion *region, GpPath *path, CombineMode combineMode), (region, path, combineMode)) \
178     m(CombineRegionRegion, (GpRegion *region, GpRegion *region2, CombineMode combineMode), (region, region2, combineMode)) \
179     m(TranslateRegion, (GpRegion *region, REAL dx, REAL dy), (region, dx, dy)) \
180     m(TranslateRegionI, (GpRegion *region, INT dx, INT dy), (region, dx, dy)) \
181     m(TransformRegion, (GpRegion *region, GpMatrix *matrix), (region, matrix)) \
182     m(GetRegionBounds, (GpRegion *region, GpGraphics *graphics, GpRectF *rect), (region, graphics, rect)) \
183     m(GetRegionBoundsI, (GpRegion *region, GpGraphics *graphics, GpRect *rect), (region, graphics, rect)) \
184     m(GetRegionHRgn, (GpRegion *region, GpGraphics *graphics, HRGN *hRgn), (region, graphics, hRgn)) \
185     m(IsEmptyRegion, (GpRegion *region, GpGraphics *graphics, BOOL *result), (region, graphics, result)) \
186     m(IsInfiniteRegion, (GpRegion *region, GpGraphics *graphics, BOOL *result), (region, graphics, result)) \
187     m(IsEqualRegion, (GpRegion *region, GpRegion *region2, GpGraphics *graphics, BOOL *result), (region, region2, graphics, result)) \
188     m(GetRegionDataSize, (GpRegion *region, UINT *bufferSize), (region, bufferSize)) \
189     m(GetRegionData, (GpRegion *region, BYTE *buffer, UINT bufferSize, UINT *sizeFilled), (region, buffer, bufferSize, sizeFilled)) \
190     m(IsVisibleRegionPoint, (GpRegion *region, REAL x, REAL y, GpGraphics *graphics, BOOL *result), (region, x, y, graphics, result)) \
191     m(IsVisibleRegionPointI, (GpRegion *region, INT x, INT y, GpGraphics *graphics, BOOL *result), (region, x, y, graphics, result)) \
192     m(IsVisibleRegionRect, (GpRegion *region, REAL x, REAL y, REAL width, REAL height, GpGraphics *graphics, BOOL *result), (region, x, y, width, height, graphics, result)) \
193     m(IsVisibleRegionRectI, (GpRegion *region, INT x, INT y, INT width, INT height, GpGraphics *graphics, BOOL *result), (region, x, y, width, height, graphics, result)) \
194     m(GetRegionScansCount, (GpRegion *region, UINT* count, GpMatrix* matrix), (region, count, matrix)) \
195     m(GetRegionScans, (GpRegion *region, GpRectF* rects, INT* count, GpMatrix* matrix), (region, rects, count, matrix)) \
196     m(GetRegionScansI, (GpRegion *region, GpRect* rects, INT* count, GpMatrix* matrix), (region, rects, count, matrix)) \
197     m(CloneBrush, (GpBrush *brush, GpBrush **cloneBrush), (brush, cloneBrush)) \
198     m(DeleteBrush, (GpBrush *brush), (brush)) \
199     m(GetBrushType, (GpBrush *brush, GpBrushType *type), (brush, type)) \
200     m(CreateHatchBrush, (GpHatchStyle hatchstyle, ARGB forecol, ARGB backcol, GpHatch **brush), (hatchstyle, forecol, backcol, brush)) \
201     m(GetHatchStyle, (GpHatch *brush, GpHatchStyle *hatchstyle), (brush, hatchstyle)) \
202     m(GetHatchForegroundColor, (GpHatch *brush, ARGB* forecol), (brush, forecol)) \
203     m(GetHatchBackgroundColor, (GpHatch *brush, ARGB* backcol), (brush, backcol)) \
204     m(CreateTexture, (GpImage *image, GpWrapMode wrapmode, GpTexture **texture), (image, wrapmode, texture)) \
205     m(CreateTexture2, (GpImage *image, GpWrapMode wrapmode, REAL x, REAL y, REAL width, REAL height, GpTexture **texture), (image, wrapmode, x, y, width, height, texture)) \
206     m(CreateTextureIA, (GpImage *image, GDIPCONST GpImageAttributes *imageAttributes, REAL x, REAL y, REAL width, REAL height, GpTexture **texture), (image, imageAttributes, x, y, width, height, texture)) \
207     m(CreateTexture2I, (GpImage *image, GpWrapMode wrapmode, INT x, INT y, INT width, INT height, GpTexture **texture), (image, wrapmode, x, y, width, height, texture)) \
208     m(CreateTextureIAI, (GpImage *image, GDIPCONST GpImageAttributes *imageAttributes, INT x, INT y, INT width, INT height, GpTexture **texture), (image, imageAttributes, x, y, width, height, texture)) \
209     m(GetTextureTransform, (GpTexture *brush, GpMatrix *matrix), (brush, matrix)) \
210     m(SetTextureTransform, (GpTexture *brush, GDIPCONST GpMatrix *matrix), (brush, matrix)) \
211     m(ResetTextureTransform, (GpTexture* brush), (brush)) \
212     m(MultiplyTextureTransform, (GpTexture* brush, GDIPCONST GpMatrix *matrix, GpMatrixOrder order), (brush, matrix, order)) \
213     m(TranslateTextureTransform, (GpTexture* brush, REAL dx, REAL dy, GpMatrixOrder order), (brush, dx, dy, order)) \
214     m(ScaleTextureTransform, (GpTexture* brush, REAL sx, REAL sy, GpMatrixOrder order), (brush, sx, sy, order)) \
215     m(RotateTextureTransform, (GpTexture* brush, REAL angle, GpMatrixOrder order), (brush, angle, order)) \
216     m(SetTextureWrapMode, (GpTexture *brush, GpWrapMode wrapmode), (brush, wrapmode)) \
217     m(GetTextureWrapMode, (GpTexture *brush, GpWrapMode *wrapmode), (brush, wrapmode)) \
218     m(GetTextureImage, (GpTexture *brush, GpImage **image), (brush, image)) \
219     m(CreateSolidFill, (ARGB color, GpSolidFill **brush), (color, brush)) \
220     m(SetSolidFillColor, (GpSolidFill *brush, ARGB color), (brush, color)) \
221     m(GetSolidFillColor, (GpSolidFill *brush, ARGB *color), (brush, color)) \
222     m(CreateLineBrush, (GDIPCONST GpPointF* point1, GDIPCONST GpPointF* point2, ARGB color1, ARGB color2, GpWrapMode wrapMode, GpLineGradient **lineGradient), (point1, point2, color1, color2, wrapMode, lineGradient)) \
223     m(CreateLineBrushI, (GDIPCONST GpPoint* point1, GDIPCONST GpPoint* point2, ARGB color1, ARGB color2, GpWrapMode wrapMode, GpLineGradient **lineGradient), (point1, point2, color1, color2, wrapMode, lineGradient)) \
224     m(CreateLineBrushFromRect, (GDIPCONST GpRectF* rect, ARGB color1, ARGB color2, LinearGradientMode mode, GpWrapMode wrapMode, GpLineGradient **lineGradient), (rect, color1, color2, mode, wrapMode, lineGradient)) \
225     m(CreateLineBrushFromRectI, (GDIPCONST GpRect* rect, ARGB color1, ARGB color2, LinearGradientMode mode, GpWrapMode wrapMode, GpLineGradient **lineGradient), (rect, color1, color2, mode, wrapMode, lineGradient)) \
226     m(CreateLineBrushFromRectWithAngle, (GDIPCONST GpRectF* rect, ARGB color1, ARGB color2, REAL angle, BOOL isAngleScalable, GpWrapMode wrapMode, GpLineGradient **lineGradient), (rect, color1, color2, angle, isAngleScalable, wrapMode, lineGradient)) \
227     m(CreateLineBrushFromRectWithAngleI, (GDIPCONST GpRect* rect, ARGB color1, ARGB color2, REAL angle, BOOL isAngleScalable, GpWrapMode wrapMode, GpLineGradient **lineGradient), (rect, color1, color2, angle, isAngleScalable, wrapMode, lineGradient)) \
228     m(SetLineColors, (GpLineGradient *brush, ARGB color1, ARGB color2), (brush, color1, color2)) \
229     m(GetLineColors, (GpLineGradient *brush, ARGB* colors), (brush, colors)) \
230     m(GetLineRect, (GpLineGradient *brush, GpRectF *rect), (brush, rect)) \
231     m(GetLineRectI, (GpLineGradient *brush, GpRect *rect), (brush, rect)) \
232     m(SetLineGammaCorrection, (GpLineGradient *brush, BOOL useGammaCorrection), (brush, useGammaCorrection)) \
233     m(GetLineGammaCorrection, (GpLineGradient *brush, BOOL *useGammaCorrection), (brush, useGammaCorrection)) \
234     m(GetLineBlendCount, (GpLineGradient *brush, INT *count), (brush, count)) \
235     m(GetLineBlend, (GpLineGradient *brush, REAL *blend, REAL* positions, INT count), (brush, blend, positions, count)) \
236     m(SetLineBlend, (GpLineGradient *brush, GDIPCONST REAL *blend, GDIPCONST REAL* positions, INT count), (brush, blend, positions, count)) \
237     m(GetLinePresetBlendCount, (GpLineGradient *brush, INT *count), (brush, count)) \
238     m(GetLinePresetBlend, (GpLineGradient *brush, ARGB *blend, REAL* positions, INT count), (brush, blend, positions, count)) \
239     m(SetLinePresetBlend, (GpLineGradient *brush, GDIPCONST ARGB *blend, GDIPCONST REAL* positions, INT count), (brush, blend, positions, count)) \
240     m(SetLineSigmaBlend, (GpLineGradient *brush, REAL focus, REAL scale), (brush, focus, scale)) \
241     m(SetLineLinearBlend, (GpLineGradient *brush, REAL focus, REAL scale), (brush, focus, scale)) \
242     m(SetLineWrapMode, (GpLineGradient *brush, GpWrapMode wrapmode), (brush, wrapmode)) \
243     m(GetLineWrapMode, (GpLineGradient *brush, GpWrapMode *wrapmode), (brush, wrapmode)) \
244     m(GetLineTransform, (GpLineGradient *brush, GpMatrix *matrix), (brush, matrix)) \
245     m(SetLineTransform, (GpLineGradient *brush, GDIPCONST GpMatrix *matrix), (brush, matrix)) \
246     m(ResetLineTransform, (GpLineGradient* brush), (brush)) \
247     m(MultiplyLineTransform, (GpLineGradient* brush, GDIPCONST GpMatrix *matrix, GpMatrixOrder order), (brush, matrix, order)) \
248     m(TranslateLineTransform, (GpLineGradient* brush, REAL dx, REAL dy, GpMatrixOrder order), (brush, dx, dy, order)) \
249     m(ScaleLineTransform, (GpLineGradient* brush, REAL sx, REAL sy, GpMatrixOrder order), (brush, sx, sy, order)) \
250     m(RotateLineTransform, (GpLineGradient* brush, REAL angle, GpMatrixOrder order), (brush, angle, order)) \
251     m(CreatePathGradient, (GDIPCONST GpPointF* points, INT count, GpWrapMode wrapMode, GpPathGradient **polyGradient), (points, count, wrapMode, polyGradient)) \
252     m(CreatePathGradientI, (GDIPCONST GpPoint* points, INT count, GpWrapMode wrapMode, GpPathGradient **polyGradient), (points, count, wrapMode, polyGradient)) \
253     m(CreatePathGradientFromPath, (GDIPCONST GpPath* path, GpPathGradient **polyGradient), (path, polyGradient)) \
254     m(GetPathGradientCenterColor, (GpPathGradient *brush, ARGB* colors), (brush, colors)) \
255     m(SetPathGradientCenterColor, (GpPathGradient *brush, ARGB colors), (brush, colors)) \
256     m(GetPathGradientSurroundColorsWithCount, (GpPathGradient *brush, ARGB* color, INT* count), (brush, color, count)) \
257     m(SetPathGradientSurroundColorsWithCount, (GpPathGradient *brush, GDIPCONST ARGB* color, INT* count), (brush, color, count)) \
258     m(GetPathGradientPath, (GpPathGradient *brush, GpPath *path), (brush, path)) \
259     m(SetPathGradientPath, (GpPathGradient *brush, GDIPCONST GpPath *path), (brush, path)) \
260     m(GetPathGradientCenterPoint, (GpPathGradient *brush, GpPointF* points), (brush, points)) \
261     m(GetPathGradientCenterPointI, (GpPathGradient *brush, GpPoint* points), (brush, points)) \
262     m(SetPathGradientCenterPoint, (GpPathGradient *brush, GDIPCONST GpPointF* points), (brush, points)) \
263     m(SetPathGradientCenterPointI, (GpPathGradient *brush, GDIPCONST GpPoint* points), (brush, points)) \
264     m(GetPathGradientRect, (GpPathGradient *brush, GpRectF *rect), (brush, rect)) \
265     m(GetPathGradientRectI, (GpPathGradient *brush, GpRect *rect), (brush, rect)) \
266     m(GetPathGradientPointCount, (GpPathGradient *brush, INT* count), (brush, count)) \
267     m(GetPathGradientSurroundColorCount, (GpPathGradient *brush, INT* count), (brush, count)) \
268     m(SetPathGradientGammaCorrection, (GpPathGradient *brush, BOOL useGammaCorrection), (brush, useGammaCorrection)) \
269     m(GetPathGradientGammaCorrection, (GpPathGradient *brush, BOOL *useGammaCorrection), (brush, useGammaCorrection)) \
270     m(GetPathGradientBlendCount, (GpPathGradient *brush, INT *count), (brush, count)) \
271     m(GetPathGradientBlend, (GpPathGradient *brush, REAL *blend, REAL *positions, INT count), (brush, blend, positions, count)) \
272     m(SetPathGradientBlend, (GpPathGradient *brush, GDIPCONST REAL *blend, GDIPCONST REAL *positions, INT count), (brush, blend, positions, count)) \
273     m(GetPathGradientPresetBlendCount, (GpPathGradient *brush, INT *count), (brush, count)) \
274     m(GetPathGradientPresetBlend, (GpPathGradient *brush, ARGB *blend, REAL* positions, INT count), (brush, blend, positions, count)) \
275     m(SetPathGradientPresetBlend, (GpPathGradient *brush, GDIPCONST ARGB *blend, GDIPCONST REAL* positions, INT count), (brush, blend, positions, count)) \
276     m(SetPathGradientSigmaBlend, (GpPathGradient *brush, REAL focus, REAL scale), (brush, focus, scale)) \
277     m(SetPathGradientLinearBlend, (GpPathGradient *brush, REAL focus, REAL scale), (brush, focus, scale)) \
278     m(GetPathGradientWrapMode, (GpPathGradient *brush, GpWrapMode *wrapmode), (brush, wrapmode)) \
279     m(SetPathGradientWrapMode, (GpPathGradient *brush, GpWrapMode wrapmode), (brush, wrapmode)) \
280     m(GetPathGradientTransform, (GpPathGradient *brush, GpMatrix *matrix), (brush, matrix)) \
281     m(SetPathGradientTransform, (GpPathGradient *brush, GpMatrix *matrix), (brush, matrix)) \
282     m(ResetPathGradientTransform, (GpPathGradient* brush), (brush)) \
283     m(MultiplyPathGradientTransform, (GpPathGradient* brush, GDIPCONST GpMatrix *matrix, GpMatrixOrder order), (brush, matrix, order)) \
284     m(TranslatePathGradientTransform, (GpPathGradient* brush, REAL dx, REAL dy, GpMatrixOrder order), (brush, dx, dy, order)) \
285     m(ScalePathGradientTransform, (GpPathGradient* brush, REAL sx, REAL sy, GpMatrixOrder order), (brush, sx, sy, order)) \
286     m(RotatePathGradientTransform, (GpPathGradient* brush, REAL angle, GpMatrixOrder order), (brush, angle, order)) \
287     m(GetPathGradientFocusScales, (GpPathGradient *brush, REAL* xScale, REAL* yScale), (brush, xScale, yScale)) \
288     m(SetPathGradientFocusScales, (GpPathGradient *brush, REAL xScale, REAL yScale), (brush, xScale, yScale)) \
289     m(CreatePen1, (ARGB color, REAL width, GpUnit unit, GpPen **pen), (color, width, unit, pen)) \
290     m(CreatePen2, (GpBrush *brush, REAL width, GpUnit unit, GpPen **pen), (brush, width, unit, pen)) \
291     m(ClonePen, (GpPen *pen, GpPen **clonepen), (pen, clonepen)) \
292     m(DeletePen, (GpPen *pen), (pen)) \
293     m(SetPenWidth, (GpPen *pen, REAL width), (pen, width)) \
294     m(GetPenWidth, (GpPen *pen, REAL *width), (pen, width)) \
295     m(SetPenUnit, (GpPen *pen, GpUnit unit), (pen, unit)) \
296     m(GetPenUnit, (GpPen *pen, GpUnit *unit), (pen, unit)) \
297     m(SetPenLineCap197819, (GpPen *pen, GpLineCap startCap, GpLineCap endCap, GpDashCap dashCap), (pen, startCap, endCap, dashCap)) \
298     m(SetPenStartCap, (GpPen *pen, GpLineCap startCap), (pen, startCap)) \
299     m(SetPenEndCap, (GpPen *pen, GpLineCap endCap), (pen, endCap)) \
300     m(SetPenDashCap197819, (GpPen *pen, GpDashCap dashCap), (pen, dashCap)) \
301     m(GetPenStartCap, (GpPen *pen, GpLineCap *startCap), (pen, startCap)) \
302     m(GetPenEndCap, (GpPen *pen, GpLineCap *endCap), (pen, endCap)) \
303     m(GetPenDashCap197819, (GpPen *pen, GpDashCap *dashCap), (pen, dashCap)) \
304     m(SetPenLineJoin, (GpPen *pen, GpLineJoin lineJoin), (pen, lineJoin)) \
305     m(GetPenLineJoin, (GpPen *pen, GpLineJoin *lineJoin), (pen, lineJoin)) \
306     m(SetPenCustomStartCap, (GpPen *pen, GpCustomLineCap* customCap), (pen, customCap)) \
307     m(GetPenCustomStartCap, (GpPen *pen, GpCustomLineCap** customCap), (pen, customCap)) \
308     m(SetPenCustomEndCap, (GpPen *pen, GpCustomLineCap* customCap), (pen, customCap)) \
309     m(GetPenCustomEndCap, (GpPen *pen, GpCustomLineCap** customCap), (pen, customCap)) \
310     m(SetPenMiterLimit, (GpPen *pen, REAL miterLimit), (pen, miterLimit)) \
311     m(GetPenMiterLimit, (GpPen *pen, REAL *miterLimit), (pen, miterLimit)) \
312     m(SetPenMode, (GpPen *pen, GpPenAlignment penMode), (pen, penMode)) \
313     m(GetPenMode, (GpPen *pen, GpPenAlignment *penMode), (pen, penMode)) \
314     m(SetPenTransform, (GpPen *pen, GpMatrix *matrix), (pen, matrix)) \
315     m(GetPenTransform, (GpPen *pen, GpMatrix *matrix), (pen, matrix)) \
316     m(ResetPenTransform, (GpPen *pen), (pen)) \
317     m(MultiplyPenTransform, (GpPen *pen, GDIPCONST GpMatrix *matrix, GpMatrixOrder order), (pen, matrix, order)) \
318     m(TranslatePenTransform, (GpPen *pen, REAL dx, REAL dy, GpMatrixOrder order), (pen, dx, dy, order)) \
319     m(ScalePenTransform, (GpPen *pen, REAL sx, REAL sy, GpMatrixOrder order), (pen, sx, sy, order)) \
320     m(RotatePenTransform, (GpPen *pen, REAL angle, GpMatrixOrder order), (pen, angle, order)) \
321     m(SetPenColor, (GpPen *pen, ARGB argb), (pen, argb)) \
322     m(GetPenColor, (GpPen *pen, ARGB *argb), (pen, argb)) \
323     m(SetPenBrushFill, (GpPen *pen, GpBrush *brush), (pen, brush)) \
324     m(GetPenBrushFill, (GpPen *pen, GpBrush **brush), (pen, brush)) \
325     m(GetPenFillType, (GpPen *pen, GpPenType* type), (pen, type)) \
326     m(GetPenDashStyle, (GpPen *pen, GpDashStyle *dashstyle), (pen, dashstyle)) \
327     m(SetPenDashStyle, (GpPen *pen, GpDashStyle dashstyle), (pen, dashstyle)) \
328     m(GetPenDashOffset, (GpPen *pen, REAL *offset), (pen, offset)) \
329     m(SetPenDashOffset, (GpPen *pen, REAL offset), (pen, offset)) \
330     m(GetPenDashCount, (GpPen *pen, INT *count), (pen, count)) \
331     m(SetPenDashArray, (GpPen *pen, GDIPCONST REAL *dash, INT count), (pen, dash, count)) \
332     m(GetPenDashArray, (GpPen *pen, REAL *dash, INT count), (pen, dash, count)) \
333     m(GetPenCompoundCount, (GpPen *pen, INT *count), (pen, count)) \
334     m(SetPenCompoundArray, (GpPen *pen, GDIPCONST REAL *dash, INT count), (pen, dash, count)) \
335     m(GetPenCompoundArray, (GpPen *pen, REAL *dash, INT count), (pen, dash, count)) \
336     m(CreateCustomLineCap, (GpPath* fillPath, GpPath* strokePath, GpLineCap baseCap, REAL baseInset, GpCustomLineCap **customCap), (fillPath, strokePath, baseCap, baseInset, customCap)) \
337     m(DeleteCustomLineCap, (GpCustomLineCap* customCap), (customCap)) \
338     m(CloneCustomLineCap, (GpCustomLineCap* customCap, GpCustomLineCap** clonedCap), (customCap, clonedCap)) \
339     m(GetCustomLineCapType, (GpCustomLineCap* customCap, CustomLineCapType* capType), (customCap, capType)) \
340     m(SetCustomLineCapStrokeCaps, (GpCustomLineCap* customCap, GpLineCap startCap, GpLineCap endCap), (customCap, startCap, endCap)) \
341     m(GetCustomLineCapStrokeCaps, (GpCustomLineCap* customCap, GpLineCap* startCap, GpLineCap* endCap), (customCap, startCap, endCap)) \
342     m(SetCustomLineCapStrokeJoin, (GpCustomLineCap* customCap, GpLineJoin lineJoin), (customCap, lineJoin)) \
343     m(GetCustomLineCapStrokeJoin, (GpCustomLineCap* customCap, GpLineJoin* lineJoin), (customCap, lineJoin)) \
344     m(SetCustomLineCapBaseCap, (GpCustomLineCap* customCap, GpLineCap baseCap), (customCap, baseCap)) \
345     m(GetCustomLineCapBaseCap, (GpCustomLineCap* customCap, GpLineCap* baseCap), (customCap, baseCap)) \
346     m(SetCustomLineCapBaseInset, (GpCustomLineCap* customCap, REAL inset), (customCap, inset)) \
347     m(GetCustomLineCapBaseInset, (GpCustomLineCap* customCap, REAL* inset), (customCap, inset)) \
348     m(SetCustomLineCapWidthScale, (GpCustomLineCap* customCap, REAL widthScale), (customCap, widthScale)) \
349     m(GetCustomLineCapWidthScale, (GpCustomLineCap* customCap, REAL* widthScale), (customCap, widthScale)) \
350     m(CreateAdjustableArrowCap, (REAL height, REAL width, BOOL isFilled, GpAdjustableArrowCap **cap), (height, width, isFilled, cap)) \
351     m(SetAdjustableArrowCapHeight, (GpAdjustableArrowCap* cap, REAL height), (cap, height)) \
352     m(GetAdjustableArrowCapHeight, (GpAdjustableArrowCap* cap, REAL* height), (cap, height)) \
353     m(SetAdjustableArrowCapWidth, (GpAdjustableArrowCap* cap, REAL width), (cap, width)) \
354     m(GetAdjustableArrowCapWidth, (GpAdjustableArrowCap* cap, REAL* width), (cap, width)) \
355     m(SetAdjustableArrowCapMiddleInset, (GpAdjustableArrowCap* cap, REAL middleInset), (cap, middleInset)) \
356     m(GetAdjustableArrowCapMiddleInset, (GpAdjustableArrowCap* cap, REAL* middleInset), (cap, middleInset)) \
357     m(SetAdjustableArrowCapFillState, (GpAdjustableArrowCap* cap, BOOL fillState), (cap, fillState)) \
358     m(GetAdjustableArrowCapFillState, (GpAdjustableArrowCap* cap, BOOL* fillState), (cap, fillState)) \
359     m(LoadImageFromStream, (IStream* stream, GpImage **image), (stream, image)) \
360     m(LoadImageFromFile, (GDIPCONST WCHAR* filename, GpImage **image), (filename, image)) \
361     m(LoadImageFromStreamICM, (IStream* stream, GpImage **image), (stream, image)) \
362     m(LoadImageFromFileICM, (GDIPCONST WCHAR* filename, GpImage **image), (filename, image)) \
363     m(CloneImage, (GpImage *image, GpImage **cloneImage), (image, cloneImage)) \
364     m(DisposeImage, (GpImage *image), (image)) \
365     m(SaveImageToFile, (GpImage *image, GDIPCONST WCHAR* filename, GDIPCONST CLSID* clsidEncoder, GDIPCONST EncoderParameters* encoderParams), (image, filename, clsidEncoder, encoderParams)) \
366     m(SaveImageToStream, (GpImage *image, IStream* stream, GDIPCONST CLSID* clsidEncoder, GDIPCONST EncoderParameters* encoderParams), (image, stream, clsidEncoder, encoderParams)) \
367     m(SaveAdd, (GpImage *image, GDIPCONST EncoderParameters* encoderParams), (image, encoderParams)) \
368     m(SaveAddImage, (GpImage *image, GpImage* newImage, GDIPCONST EncoderParameters* encoderParams), (image, newImage, encoderParams)) \
369     m(GetImageGraphicsContext, (GpImage *image, GpGraphics **graphics), (image, graphics)) \
370     m(GetImageBounds, (GpImage *image, GpRectF *srcRect, GpUnit *srcUnit), (image, srcRect, srcUnit)) \
371     m(GetImageDimension, (GpImage *image, REAL *width, REAL *height), (image, width, height)) \
372     m(GetImageType, (GpImage *image, ImageType *type), (image, type)) \
373     m(GetImageWidth, (GpImage *image, UINT *width), (image, width)) \
374     m(GetImageHeight, (GpImage *image, UINT *height), (image, height)) \
375     m(GetImageHorizontalResolution, (GpImage *image, REAL *resolution), (image, resolution)) \
376     m(GetImageVerticalResolution, (GpImage *image, REAL *resolution), (image, resolution)) \
377     m(GetImageFlags, (GpImage *image, UINT *flags), (image, flags)) \
378     m(GetImageRawFormat, (GpImage *image, GUID *format), (image, format)) \
379     m(GetImagePixelFormat, (GpImage *image, PixelFormat *format), (image, format)) \
380     m(GetImageThumbnail, (GpImage *image, UINT thumbWidth, UINT thumbHeight, GpImage **thumbImage, GetThumbnailImageAbort callback, VOID *callbackData), (image, thumbWidth, thumbHeight, thumbImage, callback, callbackData)) \
381     m(GetEncoderParameterListSize, (GpImage *image, GDIPCONST CLSID* clsidEncoder, UINT* size), (image, clsidEncoder, size)) \
382     m(GetEncoderParameterList, (GpImage *image, GDIPCONST CLSID* clsidEncoder, UINT size, EncoderParameters* buffer), (image, clsidEncoder, size, buffer)) \
383     m(ImageGetFrameDimensionsCount, (GpImage* image, UINT* count), (image, count)) \
384     m(ImageGetFrameDimensionsList, (GpImage* image, GUID* dimensionIDs, UINT count), (image, dimensionIDs, count)) \
385     m(ImageGetFrameCount, (GpImage *image, GDIPCONST GUID* dimensionID, UINT* count), (image, dimensionID, count)) \
386     m(ImageSelectActiveFrame, (GpImage *image, GDIPCONST GUID* dimensionID, UINT frameIndex), (image, dimensionID, frameIndex)) \
387     m(ImageRotateFlip, (GpImage *image, RotateFlipType rfType), (image, rfType)) \
388     m(GetImagePalette, (GpImage *image, ColorPalette *palette, INT size), (image, palette, size)) \
389     m(SetImagePalette, (GpImage *image, GDIPCONST ColorPalette *palette), (image, palette)) \
390     m(GetImagePaletteSize, (GpImage *image, INT *size), (image, size)) \
391     m(GetPropertyCount, (GpImage *image, UINT* numOfProperty), (image, numOfProperty)) \
392     m(GetPropertyIdList, (GpImage *image, UINT numOfProperty, PROPID* list), (image, numOfProperty, list)) \
393     m(GetPropertyItemSize, (GpImage *image, PROPID propId, UINT* size), (image, propId, size)) \
394     m(GetPropertyItem, (GpImage *image, PROPID propId,UINT propSize, PropertyItem* buffer), (image, propId, propSize, buffer)) \
395     m(GetPropertySize, (GpImage *image, UINT* totalBufferSize, UINT* numProperties), (image, totalBufferSize, numProperties)) \
396     m(GetAllPropertyItems, (GpImage *image, UINT totalBufferSize, UINT numProperties, PropertyItem* allItems), (image, totalBufferSize, numProperties, allItems)) \
397     m(RemovePropertyItem, (GpImage *image, PROPID propId), (image, propId)) \
398     m(SetPropertyItem, (GpImage *image, GDIPCONST PropertyItem* item), (image, item)) \
399     m(ImageForceValidation, (GpImage *image), (image)) \
400     m(CreateBitmapFromStream, (IStream* stream, GpBitmap **bitmap), (stream, bitmap)) \
401     m(CreateBitmapFromFile, (GDIPCONST WCHAR* filename, GpBitmap **bitmap), (filename, bitmap)) \
402     m(CreateBitmapFromStreamICM, (IStream* stream, GpBitmap **bitmap), (stream, bitmap)) \
403     m(CreateBitmapFromFileICM, (GDIPCONST WCHAR* filename, GpBitmap **bitmap), (filename, bitmap)) \
404     m(CreateBitmapFromScan0, (INT width, INT height, INT stride, PixelFormat format, BYTE* scan0, GpBitmap** bitmap), (width, height, stride, format, scan0, bitmap)) \
405     m(CreateBitmapFromGraphics, (INT width, INT height, GpGraphics* target, GpBitmap** bitmap), (width, height, target, bitmap)) \
406     m(CreateBitmapFromDirectDrawSurface, (IDirectDrawSurface7* surface, GpBitmap** bitmap), (surface, bitmap)) \
407     m(CreateBitmapFromGdiDib, (GDIPCONST BITMAPINFO* gdiBitmapInfo, VOID* gdiBitmapData, GpBitmap** bitmap), (gdiBitmapInfo, gdiBitmapData, bitmap)) \
408     m(CreateBitmapFromHBITMAP, (HBITMAP hbm, HPALETTE hpal, GpBitmap** bitmap), (hbm, hpal, bitmap)) \
409     m(CreateHBITMAPFromBitmap, (GpBitmap* bitmap, HBITMAP* hbmReturn, ARGB background), (bitmap, hbmReturn, background)) \
410     m(CreateBitmapFromHICON, (HICON hicon, GpBitmap** bitmap), (hicon, bitmap)) \
411     m(CreateHICONFromBitmap, (GpBitmap* bitmap, HICON* hbmReturn), (bitmap, hbmReturn)) \
412     m(CreateBitmapFromResource, (HINSTANCE hInstance, GDIPCONST WCHAR* lpBitmapName, GpBitmap** bitmap), (hInstance, lpBitmapName, bitmap)) \
413     m(CloneBitmapArea, (REAL x, REAL y, REAL width, REAL height, PixelFormat format, GpBitmap *srcBitmap, GpBitmap **dstBitmap), (x, y, width, height, format, srcBitmap, dstBitmap)) \
414     m(CloneBitmapAreaI, (INT x, INT y, INT width, INT height, PixelFormat format, GpBitmap *srcBitmap, GpBitmap **dstBitmap), (x, y, width, height, format, srcBitmap, dstBitmap)) \
415     m(BitmapLockBits, (GpBitmap* bitmap, GDIPCONST GpRect* rect, UINT flags, PixelFormat format, BitmapData* lockedBitmapData), (bitmap, rect, flags, format, lockedBitmapData)) \
416     m(BitmapUnlockBits, (GpBitmap* bitmap, BitmapData* lockedBitmapData), (bitmap, lockedBitmapData)) \
417     m(BitmapGetPixel, (GpBitmap* bitmap, INT x, INT y, ARGB *color), (bitmap, x, y, color)) \
418     m(BitmapSetPixel, (GpBitmap* bitmap, INT x, INT y, ARGB color), (bitmap, x, y, color)) \
419     m(BitmapSetResolution, (GpBitmap* bitmap, REAL xdpi, REAL ydpi), (bitmap, xdpi, ydpi)) \
420     m(CreateImageAttributes, (GpImageAttributes **imageattr), (imageattr)) \
421     m(CloneImageAttributes, (GDIPCONST GpImageAttributes *imageattr, GpImageAttributes **cloneImageattr), (imageattr, cloneImageattr)) \
422     m(DisposeImageAttributes, (GpImageAttributes *imageattr), (imageattr)) \
423     m(SetImageAttributesToIdentity, (GpImageAttributes *imageattr, ColorAdjustType type), (imageattr, type)) \
424     m(ResetImageAttributes, (GpImageAttributes *imageattr, ColorAdjustType type), (imageattr, type)) \
425     m(SetImageAttributesColorMatrix, (GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag, GDIPCONST ColorMatrix* colorMatrix, GDIPCONST ColorMatrix* grayMatrix, ColorMatrixFlags flags), (imageattr, type, enableFlag, colorMatrix, grayMatrix, flags)) \
426     m(SetImageAttributesThreshold, (GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag, REAL threshold), (imageattr, type, enableFlag, threshold)) \
427     m(SetImageAttributesGamma, (GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag, REAL gamma), (imageattr, type, enableFlag, gamma)) \
428     m(SetImageAttributesNoOp, (GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag), (imageattr, type, enableFlag)) \
429     m(SetImageAttributesColorKeys, (GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag, ARGB colorLow, ARGB colorHigh), (imageattr, type, enableFlag, colorLow, colorHigh)) \
430     m(SetImageAttributesOutputChannel, (GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag, ColorChannelFlags channelFlags), (imageattr, type, enableFlag, channelFlags)) \
431     m(SetImageAttributesOutputChannelColorProfile, (GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag, GDIPCONST WCHAR *colorProfileFilename), (imageattr, type, enableFlag, colorProfileFilename)) \
432     m(SetImageAttributesRemapTable, (GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag, UINT mapSize, GDIPCONST ColorMap *map), (imageattr, type, enableFlag, mapSize, map)) \
433     m(SetImageAttributesWrapMode, (GpImageAttributes *imageAttr, WrapMode wrap, ARGB argb, BOOL clamp), (imageAttr, wrap, argb, clamp)) \
434     m(GetImageAttributesAdjustedPalette, (GpImageAttributes *imageAttr, ColorPalette *colorPalette, ColorAdjustType colorAdjustType), (imageAttr, colorPalette, colorAdjustType)) \
435     m(Flush, (GpGraphics *graphics, GpFlushIntention intention), (graphics, intention)) \
436     m(CreateFromHDC, (HDC hdc, GpGraphics **graphics), (hdc, graphics)) \
437     m(CreateFromHDC2, (HDC hdc, HANDLE hDevice, GpGraphics **graphics), (hdc, hDevice, graphics)) \
438     m(CreateFromHWND, (HWND hwnd, GpGraphics **graphics), (hwnd, graphics)) \
439     m(CreateFromHWNDICM, (HWND hwnd, GpGraphics **graphics), (hwnd, graphics)) \
440     m(DeleteGraphics, (GpGraphics *graphics), (graphics)) \
441     m(GetDC, (GpGraphics* graphics, HDC *hdc), (graphics, hdc)) \
442     m(ReleaseDC, (GpGraphics* graphics, HDC hdc), (graphics, hdc)) \
443     m(SetCompositingMode, (GpGraphics *graphics, CompositingMode compositingMode), (graphics, compositingMode)) \
444     m(GetCompositingMode, (GpGraphics *graphics, CompositingMode *compositingMode), (graphics, compositingMode)) \
445     m(SetRenderingOrigin, (GpGraphics *graphics, INT x, INT y), (graphics, x, y)) \
446     m(GetRenderingOrigin, (GpGraphics *graphics, INT *x, INT *y), (graphics, x, y)) \
447     m(SetCompositingQuality, (GpGraphics *graphics, CompositingQuality compositingQuality), (graphics, compositingQuality)) \
448     m(GetCompositingQuality, (GpGraphics *graphics, CompositingQuality *compositingQuality), (graphics, compositingQuality)) \
449     m(SetSmoothingMode, (GpGraphics *graphics, SmoothingMode smoothingMode), (graphics, smoothingMode)) \
450     m(GetSmoothingMode, (GpGraphics *graphics, SmoothingMode *smoothingMode), (graphics, smoothingMode)) \
451     m(SetPixelOffsetMode, (GpGraphics* graphics, PixelOffsetMode pixelOffsetMode), (graphics, pixelOffsetMode)) \
452     m(GetPixelOffsetMode, (GpGraphics *graphics, PixelOffsetMode *pixelOffsetMode), (graphics, pixelOffsetMode)) \
453     m(SetTextRenderingHint, (GpGraphics *graphics, TextRenderingHint mode), (graphics, mode)) \
454     m(GetTextRenderingHint, (GpGraphics *graphics, TextRenderingHint *mode), (graphics, mode)) \
455     m(SetTextContrast, (GpGraphics *graphics, UINT contrast), (graphics, contrast)) \
456     m(GetTextContrast, (GpGraphics *graphics, UINT *contrast), (graphics, contrast)) \
457     m(SetInterpolationMode, (GpGraphics *graphics, InterpolationMode interpolationMode), (graphics, interpolationMode)) \
458     m(GetInterpolationMode, (GpGraphics *graphics, InterpolationMode *interpolationMode), (graphics, interpolationMode)) \
459     m(SetWorldTransform, (GpGraphics *graphics, GpMatrix *matrix), (graphics, matrix)) \
460     m(ResetWorldTransform, (GpGraphics *graphics), (graphics)) \
461     m(MultiplyWorldTransform, (GpGraphics *graphics, GDIPCONST GpMatrix *matrix, GpMatrixOrder order), (graphics, matrix, order)) \
462     m(TranslateWorldTransform, (GpGraphics *graphics, REAL dx, REAL dy, GpMatrixOrder order), (graphics, dx, dy, order)) \
463     m(ScaleWorldTransform, (GpGraphics *graphics, REAL sx, REAL sy, GpMatrixOrder order), (graphics, sx, sy, order)) \
464     m(RotateWorldTransform, (GpGraphics *graphics, REAL angle, GpMatrixOrder order), (graphics, angle, order)) \
465     m(GetWorldTransform, (GpGraphics *graphics, GpMatrix *matrix), (graphics, matrix)) \
466     m(ResetPageTransform, (GpGraphics *graphics), (graphics)) \
467     m(GetPageUnit, (GpGraphics *graphics, GpUnit *unit), (graphics, unit)) \
468     m(GetPageScale, (GpGraphics *graphics, REAL *scale), (graphics, scale)) \
469     m(SetPageUnit, (GpGraphics *graphics, GpUnit unit), (graphics, unit)) \
470     m(SetPageScale, (GpGraphics *graphics, REAL scale), (graphics, scale)) \
471     m(GetDpiX, (GpGraphics *graphics, REAL* dpi), (graphics, dpi)) \
472     m(GetDpiY, (GpGraphics *graphics, REAL* dpi), (graphics, dpi)) \
473     m(TransformPoints, (GpGraphics *graphics, GpCoordinateSpace destSpace, GpCoordinateSpace srcSpace, GpPointF *points, INT count), (graphics, destSpace, srcSpace, points, count)) \
474     m(TransformPointsI, (GpGraphics *graphics, GpCoordinateSpace destSpace, GpCoordinateSpace srcSpace, GpPoint *points, INT count), (graphics, destSpace, srcSpace, points, count)) \
475     m(GetNearestColor, (GpGraphics *graphics, ARGB* argb), (graphics, argb)) \
476     m(DrawLine, (GpGraphics *graphics, GpPen *pen, REAL x1, REAL y1, REAL x2, REAL y2), (graphics, pen, x1, y1, x2, y2)) \
477     m(DrawLineI, (GpGraphics *graphics, GpPen *pen, INT x1, INT y1, INT x2, INT y2), (graphics, pen, x1, y1, x2, y2)) \
478     m(DrawLines, (GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *points, INT count), (graphics, pen, points, count)) \
479     m(DrawLinesI, (GpGraphics *graphics, GpPen *pen, GDIPCONST GpPoint *points, INT count), (graphics, pen, points, count)) \
480     m(DrawArc, (GpGraphics *graphics, GpPen *pen, REAL x, REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle), (graphics, pen, x, y, width, height, startAngle, sweepAngle)) \
481     m(DrawArcI, (GpGraphics *graphics, GpPen *pen, INT x, INT y, INT width, INT height, REAL startAngle, REAL sweepAngle), (graphics, pen, x, y, width, height, startAngle, sweepAngle)) \
482     m(DrawBezier, (GpGraphics *graphics, GpPen *pen, REAL x1, REAL y1, REAL x2, REAL y2, REAL x3, REAL y3, REAL x4, REAL y4), (graphics, pen, x1, y1, x2, y2, x3, y3, x4, y4)) \
483     m(DrawBezierI, (GpGraphics *graphics, GpPen *pen, INT x1, INT y1, INT x2, INT y2, INT x3, INT y3, INT x4, INT y4), (graphics, pen, x1, y1, x2, y2, x3, y3, x4, y4)) \
484     m(DrawBeziers, (GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *points, INT count), (graphics, pen, points, count)) \
485     m(DrawBeziersI, (GpGraphics *graphics, GpPen *pen, GDIPCONST GpPoint *points, INT count), (graphics, pen, points, count)) \
486     m(DrawRectangle, (GpGraphics *graphics, GpPen *pen, REAL x, REAL y, REAL width, REAL height), (graphics, pen, x, y, width, height)) \
487     m(DrawRectangleI, (GpGraphics *graphics, GpPen *pen, INT x, INT y, INT width, INT height), (graphics, pen, x, y, width, height)) \
488     m(DrawRectangles, (GpGraphics *graphics, GpPen *pen, GDIPCONST GpRectF *rects, INT count), (graphics, pen, rects, count)) \
489     m(DrawRectanglesI, (GpGraphics *graphics, GpPen *pen, GDIPCONST GpRect *rects, INT count), (graphics, pen, rects, count)) \
490     m(DrawEllipse, (GpGraphics *graphics, GpPen *pen, REAL x, REAL y, REAL width, REAL height), (graphics, pen, x, y, width, height)) \
491     m(DrawEllipseI, (GpGraphics *graphics, GpPen *pen, INT x, INT y, INT width, INT height), (graphics, pen, x, y, width, height)) \
492     m(DrawPie, (GpGraphics *graphics, GpPen *pen, REAL x, REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle), (graphics, pen, x, y, width, height, startAngle, sweepAngle)) \
493     m(DrawPieI, (GpGraphics *graphics, GpPen *pen, INT x, INT y, INT width, INT height, REAL startAngle, REAL sweepAngle), (graphics, pen, x, y, width, height, startAngle, sweepAngle)) \
494     m(DrawPolygon, (GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *points, INT count), (graphics, pen, points, count)) \
495     m(DrawPolygonI, (GpGraphics *graphics, GpPen *pen, GDIPCONST GpPoint *points, INT count), (graphics, pen, points, count)) \
496     m(DrawPath, (GpGraphics *graphics, GpPen *pen, GpPath *path), (graphics, pen, path)) \
497     m(DrawCurve, (GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *points, INT count), (graphics, pen, points, count)) \
498     m(DrawCurveI, (GpGraphics *graphics, GpPen *pen, GDIPCONST GpPoint *points, INT count), (graphics, pen, points, count)) \
499     m(DrawCurve2, (GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *points, INT count, REAL tension), (graphics, pen, points, count, tension)) \
500     m(DrawCurve2I, (GpGraphics *graphics, GpPen *pen, GDIPCONST GpPoint *points, INT count, REAL tension), (graphics, pen, points, count, tension)) \
501     m(DrawCurve3, (GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *points, INT count, INT offset, INT numberOfSegments, REAL tension), (graphics, pen, points, count, offset, numberOfSegments, tension)) \
502     m(DrawCurve3I, (GpGraphics *graphics, GpPen *pen, GDIPCONST GpPoint *points, INT count, INT offset, INT numberOfSegments, REAL tension), (graphics, pen, points, count, offset, numberOfSegments, tension)) \
503     m(DrawClosedCurve, (GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *points, INT count), (graphics, pen, points, count)) \
504     m(DrawClosedCurveI, (GpGraphics *graphics, GpPen *pen, GDIPCONST GpPoint *points, INT count), (graphics, pen, points, count)) \
505     m(DrawClosedCurve2, (GpGraphics *graphics, GpPen *pen, GDIPCONST GpPointF *points, INT count, REAL tension), (graphics, pen, points, count, tension)) \
506     m(DrawClosedCurve2I, (GpGraphics *graphics, GpPen *pen, GDIPCONST GpPoint *points, INT count, REAL tension), (graphics, pen, points, count, tension)) \
507     m(GraphicsClear, (GpGraphics *graphics, ARGB color), (graphics, color)) \
508     m(FillRectangle, (GpGraphics *graphics, GpBrush *brush, REAL x, REAL y, REAL width, REAL height), (graphics, brush, x, y, width, height)) \
509     m(FillRectangleI, (GpGraphics *graphics, GpBrush *brush, INT x, INT y, INT width, INT height), (graphics, brush, x, y, width, height)) \
510     m(FillRectangles, (GpGraphics *graphics, GpBrush *brush, GDIPCONST GpRectF *rects, INT count), (graphics, brush, rects, count)) \
511     m(FillRectanglesI, (GpGraphics *graphics, GpBrush *brush, GDIPCONST GpRect *rects, INT count), (graphics, brush, rects, count)) \
512     m(FillPolygon, (GpGraphics *graphics, GpBrush *brush, GDIPCONST GpPointF *points, INT count, GpFillMode fillMode), (graphics, brush, points, count, fillMode)) \
513     m(FillPolygonI, (GpGraphics *graphics, GpBrush *brush, GDIPCONST GpPoint *points, INT count, GpFillMode fillMode), (graphics, brush, points, count, fillMode)) \
514     m(FillPolygon2, (GpGraphics *graphics, GpBrush *brush, GDIPCONST GpPointF *points, INT count), (graphics, brush, points, count)) \
515     m(FillPolygon2I, (GpGraphics *graphics, GpBrush *brush, GDIPCONST GpPoint *points, INT count), (graphics, brush, points, count)) \
516     m(FillEllipse, (GpGraphics *graphics, GpBrush *brush, REAL x, REAL y, REAL width, REAL height), (graphics, brush, x, y, width, height)) \
517     m(FillEllipseI, (GpGraphics *graphics, GpBrush *brush, INT x, INT y, INT width, INT height), (graphics, brush, x, y, width, height)) \
518     m(FillPie, (GpGraphics *graphics, GpBrush *brush, REAL x, REAL y, REAL width, REAL height, REAL startAngle, REAL sweepAngle), (graphics, brush, x, y, width, height, startAngle, sweepAngle)) \
519     m(FillPieI, (GpGraphics *graphics, GpBrush *brush, INT x, INT y, INT width, INT height, REAL startAngle, REAL sweepAngle), (graphics, brush, x, y, width, height, startAngle, sweepAngle)) \
520     m(FillPath, (GpGraphics *graphics, GpBrush *brush, GpPath *path), (graphics, brush, path)) \
521     m(FillClosedCurve, (GpGraphics *graphics, GpBrush *brush, GDIPCONST GpPointF *points, INT count), (graphics, brush, points, count)) \
522     m(FillClosedCurveI, (GpGraphics *graphics, GpBrush *brush, GDIPCONST GpPoint *points, INT count), (graphics, brush, points, count)) \
523     m(FillClosedCurve2, (GpGraphics *graphics, GpBrush *brush, GDIPCONST GpPointF *points, INT count, REAL tension, GpFillMode fillMode), (graphics, brush, points, count, tension, fillMode)) \
524     m(FillClosedCurve2I, (GpGraphics *graphics, GpBrush *brush, GDIPCONST GpPoint *points, INT count, REAL tension, GpFillMode fillMode), (graphics, brush, points, count, tension, fillMode)) \
525     m(FillRegion, (GpGraphics *graphics, GpBrush *brush, GpRegion *region), (graphics, brush, region)) \
526     m(DrawImage, (GpGraphics *graphics, GpImage *image, REAL x, REAL y), (graphics, image, x, y)) \
527     m(DrawImageI, (GpGraphics *graphics, GpImage *image, INT x, INT y), (graphics, image, x, y)) \
528     m(DrawImageRect, (GpGraphics *graphics, GpImage *image, REAL x, REAL y, REAL width, REAL height), (graphics, image, x, y, width, height)) \
529     m(DrawImageRectI, (GpGraphics *graphics, GpImage *image, INT x, INT y, INT width, INT height), (graphics, image, x, y, width, height)) \
530     m(DrawImagePoints, (GpGraphics *graphics, GpImage *image, GDIPCONST GpPointF *dstpoints, INT count), (graphics, image, dstpoints, count)) \
531     m(DrawImagePointsI, (GpGraphics *graphics, GpImage *image, GDIPCONST GpPoint *dstpoints, INT count), (graphics, image, dstpoints, count)) \
532     m(DrawImagePointRect, (GpGraphics *graphics, GpImage *image, REAL x, REAL y, REAL srcx, REAL srcy, REAL srcwidth, REAL srcheight, GpUnit srcUnit), (graphics, image, x, y, srcx, srcy, srcwidth, srcheight, srcUnit)) \
533     m(DrawImagePointRectI, (GpGraphics *graphics, GpImage *image, INT x, INT y, INT srcx, INT srcy, INT srcwidth, INT srcheight, GpUnit srcUnit), (graphics, image, x, y, srcx, srcy, srcwidth, srcheight, srcUnit)) \
534     m(DrawImageRectRect, (GpGraphics *graphics, GpImage *image, REAL dstx, REAL dsty, REAL dstwidth, REAL dstheight, REAL srcx, REAL srcy, REAL srcwidth, REAL srcheight, GpUnit srcUnit, GDIPCONST GpImageAttributes* imageAttributes, DrawImageAbort callback, VOID *callbackData), (graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData)) \
535     m(DrawImageRectRectI, (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), (graphics, image, dstx, dsty, dstwidth, dstheight, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData)) \
536     m(DrawImagePointsRect, (GpGraphics *graphics, GpImage *image, GDIPCONST GpPointF *points, INT count, REAL srcx, REAL srcy, REAL srcwidth, REAL srcheight, GpUnit srcUnit, GDIPCONST GpImageAttributes* imageAttributes, DrawImageAbort callback, VOID *callbackData), (graphics, image, points, count, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData)) \
537     m(DrawImagePointsRectI, (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), (graphics, image, points, count, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData)) \
538     m(EnumerateMetafileDestPoint, (GpGraphics *graphics, GDIPCONST GpMetafile *metafile, GDIPCONST PointF & destPoint, EnumerateMetafileProc callback, VOID *callbackData, GDIPCONST GpImageAttributes *imageAttributes), (graphics, metafile, destPoint, callback, callbackData, imageAttributes)) \
539     m(EnumerateMetafileDestPointI, (GpGraphics *graphics, GDIPCONST GpMetafile *metafile, GDIPCONST Point & destPoint, EnumerateMetafileProc callback, VOID *callbackData, GDIPCONST GpImageAttributes *imageAttributes), (graphics, metafile, destPoint, callback, callbackData, imageAttributes)) \
540     m(EnumerateMetafileDestRect, (GpGraphics *graphics, GDIPCONST GpMetafile *metafile, GDIPCONST RectF & destRect, EnumerateMetafileProc callback, VOID *callbackData, GDIPCONST GpImageAttributes *imageAttributes), (graphics, metafile, destRect, callback, callbackData, imageAttributes)) \
541     m(EnumerateMetafileDestRectI, (GpGraphics *graphics, GDIPCONST GpMetafile *metafile, GDIPCONST Rect & destRect, EnumerateMetafileProc callback, VOID *callbackData, GDIPCONST GpImageAttributes *imageAttributes), (graphics, metafile, destRect, callback, callbackData, imageAttributes)) \
542     m(EnumerateMetafileDestPoints, (GpGraphics *graphics, GDIPCONST GpMetafile *metafile, GDIPCONST PointF *destPoints, INT count, EnumerateMetafileProc callback, VOID *callbackData, GDIPCONST GpImageAttributes *imageAttributes), (graphics, metafile, destPoints, count, callback, callbackData, imageAttributes)) \
543     m(EnumerateMetafileDestPointsI, (GpGraphics *graphics, GDIPCONST GpMetafile *metafile, GDIPCONST Point *destPoints, INT count, EnumerateMetafileProc callback, VOID *callbackData, GDIPCONST GpImageAttributes *imageAttributes), (graphics, metafile, destPoints, count, callback, callbackData, imageAttributes)) \
544     m(EnumerateMetafileSrcRectDestPoint, (GpGraphics *graphics, GDIPCONST GpMetafile *metafile, GDIPCONST PointF & destPoint, GDIPCONST RectF & srcRect, Unit srcUnit, EnumerateMetafileProc callback, VOID *callbackData, GDIPCONST GpImageAttributes *imageAttributes), (graphics, metafile, destPoint, srcRect, srcUnit, callback, callbackData, imageAttributes)) \
545     m(EnumerateMetafileSrcRectDestPointI, (GpGraphics *graphics, GDIPCONST GpMetafile *metafile, GDIPCONST Point & destPoint, GDIPCONST Rect & srcRect, Unit srcUnit, EnumerateMetafileProc callback, VOID *callbackData, GDIPCONST GpImageAttributes *imageAttributes), (graphics, metafile, destPoint, srcRect, srcUnit, callback, callbackData, imageAttributes)) \
546     m(EnumerateMetafileSrcRectDestRect, (GpGraphics *graphics, GDIPCONST GpMetafile *metafile, GDIPCONST RectF & destRect, GDIPCONST RectF & srcRect, Unit srcUnit, EnumerateMetafileProc callback, VOID *callbackData, GDIPCONST GpImageAttributes *imageAttributes), (graphics, metafile, destRect, srcRect, srcUnit, callback, callbackData, imageAttributes)) \
547     m(EnumerateMetafileSrcRectDestRectI, (GpGraphics *graphics, GDIPCONST GpMetafile *metafile, GDIPCONST Rect & destRect, GDIPCONST Rect & srcRect, Unit srcUnit, EnumerateMetafileProc callback, VOID *callbackData, GDIPCONST GpImageAttributes *imageAttributes), (graphics, metafile, destRect, srcRect, srcUnit, callback, callbackData, imageAttributes)) \
548     m(EnumerateMetafileSrcRectDestPoints, (GpGraphics *graphics, GDIPCONST GpMetafile *metafile, GDIPCONST PointF *destPoints, INT count, GDIPCONST RectF & srcRect, Unit srcUnit, EnumerateMetafileProc callback, VOID *callbackData, GDIPCONST GpImageAttributes *imageAttributes), (graphics, metafile, destPoints, count, srcRect, srcUnit, callback, callbackData, imageAttributes)) \
549     m(EnumerateMetafileSrcRectDestPointsI, (GpGraphics *graphics, GDIPCONST GpMetafile *metafile, GDIPCONST Point *destPoints, INT count, GDIPCONST Rect & srcRect, Unit srcUnit, EnumerateMetafileProc callback, VOID *callbackData, GDIPCONST GpImageAttributes *imageAttributes), (graphics, metafile, destPoints, count, srcRect, srcUnit, callback, callbackData, imageAttributes)) \
550     m(PlayMetafileRecord, (GDIPCONST GpMetafile *metafile, EmfPlusRecordType recordType, UINT flags, UINT dataSize, GDIPCONST BYTE *data), (metafile, recordType, flags, dataSize, data)) \
551     m(SetClipGraphics, (GpGraphics *graphics, GpGraphics *srcgraphics, CombineMode combineMode), (graphics, srcgraphics, combineMode)) \
552     m(SetClipRect, (GpGraphics *graphics, REAL x, REAL y, REAL width, REAL height, CombineMode combineMode), (graphics, x, y, width, height, combineMode)) \
553     m(SetClipRectI, (GpGraphics *graphics, INT x, INT y, INT width, INT height, CombineMode combineMode), (graphics, x, y, width, height, combineMode)) \
554     m(SetClipPath, (GpGraphics *graphics, GpPath *path, CombineMode combineMode), (graphics, path, combineMode)) \
555     m(SetClipRegion, (GpGraphics *graphics, GpRegion *region, CombineMode combineMode), (graphics, region, combineMode)) \
556     m(SetClipHrgn, (GpGraphics *graphics, HRGN hRgn, CombineMode combineMode), (graphics, hRgn, combineMode)) \
557     m(ResetClip, (GpGraphics *graphics), (graphics)) \
558     m(TranslateClip, (GpGraphics *graphics, REAL dx, REAL dy), (graphics, dx, dy)) \
559     m(TranslateClipI, (GpGraphics *graphics, INT dx, INT dy), (graphics, dx, dy)) \
560     m(GetClip, (GpGraphics *graphics, GpRegion *region), (graphics, region)) \
561     m(GetClipBounds, (GpGraphics *graphics, GpRectF *rect), (graphics, rect)) \
562     m(GetClipBoundsI, (GpGraphics *graphics, GpRect *rect), (graphics, rect)) \
563     m(IsClipEmpty, (GpGraphics *graphics, BOOL *result), (graphics, result)) \
564     m(GetVisibleClipBounds, (GpGraphics *graphics, GpRectF *rect), (graphics, rect)) \
565     m(GetVisibleClipBoundsI, (GpGraphics *graphics, GpRect *rect), (graphics, rect)) \
566     m(IsVisibleClipEmpty, (GpGraphics *graphics, BOOL *result), (graphics, result)) \
567     m(IsVisiblePoint, (GpGraphics *graphics, REAL x, REAL y, BOOL *result), (graphics, x, y, result)) \
568     m(IsVisiblePointI, (GpGraphics *graphics, INT x, INT y, BOOL *result), (graphics, x, y, result)) \
569     m(IsVisibleRect, (GpGraphics *graphics, REAL x, REAL y, REAL width, REAL height, BOOL *result), (graphics, x, y, width, height, result)) \
570     m(IsVisibleRectI, (GpGraphics *graphics, INT x, INT y, INT width, INT height, BOOL *result), (graphics, x, y, width, height, result)) \
571     m(SaveGraphics, (GpGraphics *graphics, GraphicsState *state), (graphics, state)) \
572     m(RestoreGraphics, (GpGraphics *graphics, GraphicsState state), (graphics, state)) \
573     m(BeginContainer, (GpGraphics *graphics, GDIPCONST GpRectF* dstrect, GDIPCONST GpRectF *srcrect, GpUnit unit, GraphicsContainer *state), (graphics, dstrect, srcrect, unit, state)) \
574     m(BeginContainerI, (GpGraphics *graphics, GDIPCONST GpRect* dstrect, GDIPCONST GpRect *srcrect, GpUnit unit, GraphicsContainer *state), (graphics, dstrect, srcrect, unit, state)) \
575     m(BeginContainer2, (GpGraphics *graphics, GraphicsContainer* state), (graphics, state)) \
576     m(EndContainer, (GpGraphics *graphics, GraphicsContainer state), (graphics, state)) \
577     m(GetMetafileHeaderFromEmf, (HENHMETAFILE hEmf, MetafileHeader *header), (hEmf, header)) \
578     m(GetMetafileHeaderFromFile, (GDIPCONST WCHAR* filename, MetafileHeader *header), (filename, header)) \
579     m(GetMetafileHeaderFromStream, (IStream *stream, MetafileHeader *header), (stream, header)) \
580     m(GetMetafileHeaderFromMetafile, (GpMetafile *metafile, MetafileHeader *header), (metafile, header)) \
581     m(GetHemfFromMetafile, (GpMetafile *metafile, HENHMETAFILE *hEmf), (metafile, hEmf)) \
582     m(CreateStreamOnFile, (GDIPCONST WCHAR *filename, UINT access, IStream **stream), (filename, access, stream)) \
583     m(CreateMetafileFromWmf, (HMETAFILE hWmf, BOOL deleteWmf, GDIPCONST WmfPlaceableFileHeader *wmfPlaceableFileHeader, GpMetafile **metafile), (hWmf, deleteWmf, wmfPlaceableFileHeader, metafile)) \
584     m(CreateMetafileFromEmf, (HENHMETAFILE hEmf, BOOL deleteEmf, GpMetafile **metafile), (hEmf, deleteEmf, metafile)) \
585     m(CreateMetafileFromFile, (GDIPCONST WCHAR* file, GpMetafile **metafile), (file, metafile)) \
586     m(CreateMetafileFromWmfFile, (GDIPCONST WCHAR* file, GDIPCONST WmfPlaceableFileHeader *wmfPlaceableFileHeader, GpMetafile **metafile), (file, wmfPlaceableFileHeader, metafile)) \
587     m(CreateMetafileFromStream, (IStream *stream, GpMetafile **metafile), (stream, metafile)) \
588     m(RecordMetafile, (HDC referenceHdc, EmfType type, GDIPCONST GpRectF *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *description, GpMetafile ** metafile), (referenceHdc, type, frameRect, frameUnit, description, metafile)) \
589     m(RecordMetafileI, (HDC referenceHdc, EmfType type, GDIPCONST GpRect *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *description, GpMetafile ** metafile), (referenceHdc, type, frameRect, frameUnit, description, metafile)) \
590     m(RecordMetafileFileName, (GDIPCONST WCHAR* fileName, HDC referenceHdc, EmfType type, GDIPCONST GpRectF *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *description, GpMetafile ** metafile), (fileName, referenceHdc, type, frameRect, frameUnit, description, metafile)) \
591     m(RecordMetafileFileNameI, (GDIPCONST WCHAR* fileName, HDC referenceHdc, EmfType type, GDIPCONST GpRect *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *description, GpMetafile ** metafile), (fileName, referenceHdc, type, frameRect, frameUnit, description, metafile)) \
592     m(RecordMetafileStream, (IStream *stream, HDC referenceHdc, EmfType type, GDIPCONST GpRectF *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *description, GpMetafile ** metafile), (stream, referenceHdc, type, frameRect, frameUnit, description, metafile)) \
593     m(RecordMetafileStreamI, (IStream *stream, HDC referenceHdc, EmfType type, GDIPCONST GpRect *frameRect, MetafileFrameUnit frameUnit, GDIPCONST WCHAR *description, GpMetafile ** metafile), (stream, referenceHdc, type, frameRect, frameUnit, description, metafile)) \
594     m(SetMetafileDownLevelRasterizationLimit, (GpMetafile *metafile, UINT metafileRasterizationLimitDpi), (metafile, metafileRasterizationLimitDpi)) \
595     m(GetMetafileDownLevelRasterizationLimit, (GDIPCONST GpMetafile *metafile, UINT *metafileRasterizationLimitDpi), (metafile, metafileRasterizationLimitDpi)) \
596     m(GetImageDecodersSize, (UINT *numDecoders, UINT *size), (numDecoders, size)) \
597     m(GetImageDecoders, (UINT numDecoders, UINT size, ImageCodecInfo *decoders), (numDecoders, size, decoders)) \
598     m(GetImageEncodersSize, (UINT *numEncoders, UINT *size), (numEncoders, size)) \
599     m(GetImageEncoders, (UINT numEncoders, UINT size, ImageCodecInfo *encoders), (numEncoders, size, encoders)) \
600     m(Comment, (GpGraphics* graphics, UINT sizeData, GDIPCONST BYTE *data), (graphics, sizeData, data)) \
601     m(CreateFontFamilyFromName, (GDIPCONST WCHAR *name, GpFontCollection *fontCollection, GpFontFamily **FontFamily), (name, fontCollection, FontFamily)) \
602     m(DeleteFontFamily, (GpFontFamily *FontFamily), (FontFamily)) \
603     m(CloneFontFamily, (GpFontFamily *FontFamily, GpFontFamily **clonedFontFamily), (FontFamily, clonedFontFamily)) \
604     m(GetGenericFontFamilySansSerif, (GpFontFamily **nativeFamily), (nativeFamily)) \
605     m(GetGenericFontFamilySerif, (GpFontFamily **nativeFamily), (nativeFamily)) \
606     m(GetGenericFontFamilyMonospace, (GpFontFamily **nativeFamily), (nativeFamily)) \
607     m(GetFamilyName, (GDIPCONST GpFontFamily *family, WCHAR name[LF_FACESIZE], LANGID language), (family, name, language)) \
608     m(IsStyleAvailable, (GDIPCONST GpFontFamily *family, INT style, BOOL *IsStyleAvailable), (family, style, IsStyleAvailable)) \
609     m(GetEmHeight, (GDIPCONST GpFontFamily *family, INT style, UINT16 *EmHeight), (family, style, EmHeight)) \
610     m(GetCellAscent, (GDIPCONST GpFontFamily *family, INT style, UINT16 *CellAscent), (family, style, CellAscent)) \
611     m(GetCellDescent, (GDIPCONST GpFontFamily *family, INT style, UINT16 *CellDescent), (family, style, CellDescent)) \
612     m(GetLineSpacing, (GDIPCONST GpFontFamily *family, INT style, UINT16 *LineSpacing), (family, style, LineSpacing)) \
613     m(CreateFontFromDC, (HDC hdc, GpFont **font), (hdc, font)) \
614     m(CreateFontFromLogfontA, (HDC hdc, GDIPCONST LOGFONTA *logfont, GpFont **font), (hdc, logfont, font)) \
615     m(CreateFontFromLogfontW, (HDC hdc, GDIPCONST LOGFONTW *logfont, GpFont **font), (hdc, logfont, font)) \
616     m(CreateFont, (GDIPCONST GpFontFamily *fontFamily, REAL emSize, INT style, Unit unit, GpFont **font), (fontFamily, emSize, style, unit, font)) \
617     m(CloneFont, (GpFont* font, GpFont** cloneFont), (font, cloneFont)) \
618     m(DeleteFont, (GpFont* font), (font)) \
619     m(GetFamily, (GpFont *font, GpFontFamily **family), (font, family)) \
620     m(GetFontStyle, (GpFont *font, INT *style), (font, style)) \
621     m(GetFontSize, (GpFont *font, REAL *size), (font, size)) \
622     m(GetFontUnit, (GpFont *font, Unit *unit), (font, unit)) \
623     m(GetFontHeight, (GDIPCONST GpFont *font, GDIPCONST GpGraphics *graphics, REAL *height), (font, graphics, height)) \
624     m(GetFontHeightGivenDPI, (GDIPCONST GpFont *font, REAL dpi, REAL *height), (font, dpi, height)) \
625     m(GetLogFontA, (GpFont *font, GpGraphics *graphics, LOGFONTA *logfontA), (font, graphics, logfontA)) \
626     m(GetLogFontW, (GpFont *font, GpGraphics *graphics, LOGFONTW *logfontW), (font, graphics, logfontW)) \
627     m(NewInstalledFontCollection, (GpFontCollection** fontCollection), (fontCollection)) \
628     m(NewPrivateFontCollection, (GpFontCollection** fontCollection), (fontCollection)) \
629     m(DeletePrivateFontCollection, (GpFontCollection** fontCollection), (fontCollection)) \
630     m(GetFontCollectionFamilyCount, (GpFontCollection* fontCollection, INT *numFound), (fontCollection, numFound)) \
631     m(GetFontCollectionFamilyList, (GpFontCollection* fontCollection, INT numSought, GpFontFamily* gpfamilies[], INT* numFound), (fontCollection, numSought, gpfamilies, numFound)) \
632     m(PrivateAddFontFile, (GpFontCollection* fontCollection, GDIPCONST WCHAR* filename), (fontCollection, filename)) \
633     m(PrivateAddMemoryFont, (GpFontCollection* fontCollection, GDIPCONST void* memory, INT length), (fontCollection, memory, length)) \
634     m(DrawString, (GpGraphics *graphics, GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font, GDIPCONST RectF *layoutRect, GDIPCONST GpStringFormat *stringFormat, GDIPCONST GpBrush *brush), (graphics, string, length, font, layoutRect, stringFormat, brush)) \
635     m(MeasureString, (GpGraphics *graphics, GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font, GDIPCONST RectF *layoutRect, GDIPCONST GpStringFormat *stringFormat, RectF *boundingBox, INT *codepointsFitted, INT *linesFilled), (graphics, string, length, font, layoutRect, stringFormat, boundingBox, codepointsFitted, linesFilled)) \
636     m(MeasureCharacterRanges, (GpGraphics *graphics, GDIPCONST WCHAR *string, INT length, GDIPCONST GpFont *font, GDIPCONST RectF &layoutRect, GDIPCONST GpStringFormat *stringFormat, INT regionCount, GpRegion **regions), (graphics, string, length, font, layoutRect, stringFormat, regionCount, regions)) \
637     m(DrawDriverString, (GpGraphics *graphics, GDIPCONST UINT16 *text, INT length, GDIPCONST GpFont *font, GDIPCONST GpBrush *brush, GDIPCONST PointF *positions, INT flags, GDIPCONST GpMatrix *matrix), (graphics, text, length, font, brush, positions, flags, matrix)) \
638     m(MeasureDriverString, (GpGraphics *graphics, GDIPCONST UINT16 *text, INT length, GDIPCONST GpFont *font, GDIPCONST PointF *positions, INT flags, GDIPCONST GpMatrix *matrix, RectF *boundingBox), (graphics, text, length, font, positions, flags, matrix, boundingBox)) \
639     m(CreateStringFormat, (INT formatAttributes, LANGID language, GpStringFormat **format), (formatAttributes, language, format)) \
640     m(StringFormatGetGenericDefault, (GpStringFormat **format), (format)) \
641     m(StringFormatGetGenericTypographic, (GpStringFormat **format), (format)) \
642     m(DeleteStringFormat, (GpStringFormat *format), (format)) \
643     m(CloneStringFormat, (GDIPCONST GpStringFormat *format, GpStringFormat **newFormat), (format, newFormat)) \
644     m(SetStringFormatFlags, (GpStringFormat *format, INT flags), (format, flags)) \
645     m(GetStringFormatFlags, (GDIPCONST GpStringFormat *format, INT *flags), (format, flags)) \
646     m(SetStringFormatAlign, (GpStringFormat *format, StringAlignment align), (format, align)) \
647     m(GetStringFormatAlign, (GDIPCONST GpStringFormat *format, StringAlignment *align), (format, align)) \
648     m(SetStringFormatLineAlign, (GpStringFormat *format, StringAlignment align), (format, align)) \
649     m(GetStringFormatLineAlign, (GDIPCONST GpStringFormat *format, StringAlignment *align), (format, align)) \
650     m(SetStringFormatTrimming, (GpStringFormat *format, StringTrimming trimming), (format, trimming)) \
651     m(GetStringFormatTrimming, (GDIPCONST GpStringFormat *format, StringTrimming *trimming), (format, trimming)) \
652     m(SetStringFormatHotkeyPrefix, (GpStringFormat *format, INT hotkeyPrefix), (format, hotkeyPrefix)) \
653     m(GetStringFormatHotkeyPrefix, (GDIPCONST GpStringFormat *format, INT *hotkeyPrefix), (format, hotkeyPrefix)) \
654     m(SetStringFormatTabStops, (GpStringFormat *format, REAL firstTabOffset, INT count, GDIPCONST REAL *tabStops), (format, firstTabOffset, count, tabStops)) \
655     m(GetStringFormatTabStops, (GDIPCONST GpStringFormat *format, INT count, REAL *firstTabOffset, REAL *tabStops), (format, count, firstTabOffset, tabStops)) \
656     m(GetStringFormatTabStopCount, (GDIPCONST GpStringFormat *format, INT *count), (format, count)) \
657     m(SetStringFormatDigitSubstitution, (GpStringFormat *format, LANGID language, StringDigitSubstitute substitute), (format, language, substitute)) \
658     m(GetStringFormatDigitSubstitution, (GDIPCONST GpStringFormat *format, LANGID *language, StringDigitSubstitute *substitute), (format, language, substitute)) \
659     m(GetStringFormatMeasurableCharacterRangeCount, (GDIPCONST GpStringFormat *format, INT *count), (format, count)) \
660     m(SetStringFormatMeasurableCharacterRanges, (GpStringFormat *format, INT rangeCount, GDIPCONST CharacterRange *ranges), (format, rangeCount, ranges)) \
661     m(CreateCachedBitmap, (GpBitmap *bitmap, GpGraphics *graphics, GpCachedBitmap **cachedBitmap), (bitmap, graphics, cachedBitmap)) \
662     m(DeleteCachedBitmap, (GpCachedBitmap *cachedBitmap), (cachedBitmap)) \
663     m(DrawCachedBitmap, (GpGraphics *graphics, GpCachedBitmap *cachedBitmap, INT x, INT y), (graphics, cachedBitmap, x, y)) \
664     m(SetImageAttributesCachedBackground, (GpImageAttributes *imageattr, BOOL enableFlag), (imageattr, enableFlag)) \
665     m(TestControl, (GpTestControlEnum control, void *param), (control, param)) \
666 
667     // non-standard/problematic functions, to review later if needed
668 #if 0
669     // these functions don't seem to exist in the DLL even though they are
670     // declared in the header
671     m(SetImageAttributesICMMode, (GpImageAttributes *imageAttr, BOOL on), (imageAttr, on)) \
672     m(FontCollectionEnumerable, (GpFontCollection* fontCollection, GpGraphics* graphics, INT *numFound), (fontCollection, graphics, numFound)) \
673     m(FontCollectionEnumerate, (GpFontCollection* fontCollection, INT numSought, GpFontFamily* gpfamilies[], INT* numFound, GpGraphics* graphics), (fontCollection, numSought, gpfamilies, numFound, graphics)) \
674 
675 GpStatus
676 GdipGetMetafileHeaderFromWmf(
677     HMETAFILE           hWmf,
678     GDIPCONST WmfPlaceableFileHeader *     wmfPlaceableFileHeader,
679     MetafileHeader *    header
680     );
681 HPALETTE WINGDIPAPI
682 GdipCreateHalftonePalette();
683 
684 UINT WINGDIPAPI
685 GdipEmfToWmfBits(
686     HENHMETAFILE hemf,
687     UINT         cbData16,
688     LPBYTE       pData16,
689     INT          iMapMode,
690     INT          eFlags
691 );
692 #endif // 0
693 
694 // this macro expands into an invocation of the given macro m for all GDI+
695 // functions: m is called with the name of the function without "Gdip" prefix
696 #define wxFOR_ALL_GDIP_FUNCNAMES(m)                                           \
697     m(Alloc, (size_t size), (size))                                           \
698     m(Free, (void *ptr), (ptr))                                               \
699     wxFOR_ALL_GDIPLUS_STATUS_FUNCS(m)
700 
701 // unfortunately we need a separate macro for these functions as they have
702 // "Gdiplus" prefix instead of "Gdip" for (almost) all the others (and also
703 // WINAPI calling convention instead of WINGDIPAPI although they happen to be
704 // both stdcall in fact)
705 #define wxFOR_ALL_GDIPLUS_FUNCNAMES(m)                                        \
706     m(Startup, (ULONG_PTR *token,                                             \
707                 const GdiplusStartupInput *input,                             \
708                 GdiplusStartupOutput *output),                                \
709                 (token, input, output))                                       \
710     m(Shutdown, (ULONG_PTR token), (token))                                   \
711     m(NotificationHook, (ULONG_PTR *token), (token))                          \
712     m(NotificationUnhook, (ULONG_PTR token), (token))                         \
713 
714 #define wxFOR_ALL_FUNCNAMES(m)                                                \
715     wxFOR_ALL_GDIP_FUNCNAMES(m)                                               \
716     wxFOR_ALL_GDIPLUS_FUNCNAMES(m)
717 
718 // ----------------------------------------------------------------------------
719 // declare typedefs for types of all GDI+ functions
720 // ----------------------------------------------------------------------------
721 
722 extern "C"
723 {
724 
725 typedef void* (WINGDIPAPI *wxGDIPLUS_FUNC_T(Alloc))(size_t size);
726 typedef void (WINGDIPAPI *wxGDIPLUS_FUNC_T(Free))(void* ptr);
727 typedef Status
728 (WINAPI *wxGDIPLUS_FUNC_T(Startup))(ULONG_PTR *token,
729                                     const GdiplusStartupInput *input,
730                                     GdiplusStartupOutput *output);
731 typedef void (WINAPI *wxGDIPLUS_FUNC_T(Shutdown))(ULONG_PTR token);
732 typedef GpStatus (WINAPI *wxGDIPLUS_FUNC_T(NotificationHook))(ULONG_PTR *token);
733 typedef void (WINAPI *wxGDIPLUS_FUNC_T(NotificationUnhook))(ULONG_PTR token);
734 
735 #define wxDECL_GDIPLUS_FUNC_TYPE(name, params, args) \
736     typedef GpStatus (WINGDIPAPI *wxGDIPLUS_FUNC_T(name)) params ;
737 
738 wxFOR_ALL_GDIPLUS_STATUS_FUNCS(wxDECL_GDIPLUS_FUNC_TYPE)
739 
740 #undef wxDECL_GDIPLUS_FUNC_TYPE
741 
742 // Special hack for w32api headers that reference this variable which is
743 // normally defined in w32api-specific gdiplus.lib but as we don't link with it
744 // and load gdiplus.dll dynamically, it's not defined in our case resulting in
745 // linking errors -- so just provide it ourselves, it doesn't matter where it
746 // is and if Cygwin headers are modified to not use it in the future, it's not
747 // a big deal neither, we'll just have an unused pointer.
748 #if defined(__CYGWIN__) || defined(__MINGW32__)
749 void *_GdipStringFormatCachedGenericTypographic = NULL;
750 #endif // __CYGWIN__ || __MINGW32__
751 
752 } // extern "C"
753 
754 // ============================================================================
755 // wxGdiPlus helper class
756 // ============================================================================
757 
758 class wxGdiPlus
759 {
760 public:
761     // load GDI+ DLL when we're called for the first time, return true on
762     // success or false on failure
Initialize()763     static bool Initialize()
764     {
765         if ( m_initialized == -1 )
766             m_initialized = DoInit();
767 
768         return m_initialized == 1;
769     }
770 
771     // check if we're initialized without loading the GDI+ DLL
IsInitialized()772     static bool IsInitialized()
773     {
774         return m_initialized == 1;
775     }
776 
777     // shutdown: should be called on termination to unload the GDI+ DLL, safe
778     // to call even if we hadn't loaded it
Terminate()779     static void Terminate()
780     {
781         if ( m_hdll )
782         {
783             wxDynamicLibrary::Unload(m_hdll);
784             m_hdll = 0;
785         }
786 
787         m_initialized = -1;
788     }
789 
790 
791     // define function pointers as members
792     #define wxDECL_GDIPLUS_FUNC_MEMBER(name, params, args) \
793         static wxGDIPLUS_FUNC_T(name) name;
794 
795     wxFOR_ALL_FUNCNAMES(wxDECL_GDIPLUS_FUNC_MEMBER)
796 
797     #undef wxDECL_GDIPLUS_FUNC_MEMBER
798 
799 private:
800     // do load the GDI+ DLL and bind all the functions
801     static bool DoInit();
802 
803 
804     // initially -1 meaning unknown, set to false or true by Initialize()
805     static int m_initialized;
806 
807     // handle of the GDI+ DLL if we loaded it successfully
808     static wxDllType m_hdll;
809 };
810 
811 #define wxINIT_GDIPLUS_FUNC(name, params, args) \
812     wxGDIPLUS_FUNC_T(name) wxGdiPlus::name = NULL;
813 
814 wxFOR_ALL_FUNCNAMES(wxINIT_GDIPLUS_FUNC)
815 
816 #undef wxINIT_GDIPLUS_FUNC
817 
818 int wxGdiPlus::m_initialized = -1;
819 wxDllType wxGdiPlus::m_hdll = 0;
820 
821 /* static */
DoInit()822 bool wxGdiPlus::DoInit()
823 {
824     // we're prepared to handler errors so suppress log messages about them
825     wxLogNull noLog;
826 
827     wxDynamicLibrary dllGdip(wxT("gdiplus.dll"), wxDL_VERBATIM);
828     if ( !dllGdip.IsLoaded() )
829         return false;
830 
831     // use RawGetSymbol() for efficiency, we have ~600 functions to load...
832     #define wxDO_LOAD_FUNC(name, namedll)                                     \
833         name = (wxGDIPLUS_FUNC_T(name))dllGdip.RawGetSymbol(namedll);         \
834         if ( !name )                                                          \
835             return false;
836 
837     #define wxLOAD_GDIPLUS_FUNC(name, params, args)                           \
838         wxDO_LOAD_FUNC(name, wxT("Gdiplus") wxSTRINGIZE_T(name))
839 
840     wxFOR_ALL_GDIPLUS_FUNCNAMES(wxLOAD_GDIPLUS_FUNC)
841 
842     #undef wxLOAD_GDIPLUS_FUNC
843 
844     #define wxLOAD_GDIP_FUNC(name, params, args)                              \
845         wxDO_LOAD_FUNC(name, wxT("Gdip") wxSTRINGIZE_T(name))
846 
847     wxFOR_ALL_GDIP_FUNCNAMES(wxLOAD_GDIP_FUNC)
848 
849     #undef wxLOAD_GDIP_FUNC
850 
851     // ok, prevent the DLL from being unloaded right now, we'll do it later
852     m_hdll = dllGdip.Detach();
853 
854     return true;
855 }
856 
857 // ============================================================================
858 // module to unload GDI+ DLL on program termination
859 // ============================================================================
860 
861 class wxGdiPlusModule : public wxModule
862 {
863 public:
OnInit()864     virtual bool OnInit() { return true; }
OnExit()865     virtual void OnExit() { wxGdiPlus::Terminate(); }
866 
867     DECLARE_DYNAMIC_CLASS(wxGdiPlusModule)
868 };
869 
IMPLEMENT_DYNAMIC_CLASS(wxGdiPlusModule,wxModule)870 IMPLEMENT_DYNAMIC_CLASS(wxGdiPlusModule, wxModule)
871 
872 // ============================================================================
873 // implementation of the functions themselves
874 // ============================================================================
875 
876 extern "C"
877 {
878 
879 void* WINGDIPAPI
880 GdipAlloc(size_t size)
881 {
882     return wxGdiPlus::Initialize() ? wxGdiPlus::Alloc(size) : NULL;
883 }
884 
885 void WINGDIPAPI
886 GdipFree(void* ptr)
887 {
888     if ( wxGdiPlus::Initialize() )
889         wxGdiPlus::Free(ptr);
890 }
891 
892 Status WINAPI
893 GdiplusStartup(ULONG_PTR *token,
894                const GdiplusStartupInput *input,
895                GdiplusStartupOutput *output)
896 {
897     return wxGdiPlus::Initialize() ? wxGdiPlus::Startup(token, input, output)
898                                    : GdiplusNotInitialized;
899 }
900 
901 void WINAPI
902 GdiplusShutdown(ULONG_PTR token)
903 {
904     if ( wxGdiPlus::IsInitialized() )
905         wxGdiPlus::Shutdown(token);
906 }
907 
908 #define wxIMPL_GDIPLUS_FUNC(name, params, args)                               \
909     GpStatus WINGDIPAPI                                                       \
910     Gdip##name params                                                         \
911     {                                                                         \
912         return wxGdiPlus::Initialize() ? wxGdiPlus::name args                 \
913                                        : GdiplusNotInitialized;               \
914     }
915 
916 wxFOR_ALL_GDIPLUS_STATUS_FUNCS(wxIMPL_GDIPLUS_FUNC)
917 
918 #undef wxIMPL_GDIPLUS_FUNC
919 
920 } // extern "C"
921 
922 #endif // wxUSE_GRAPHICS_CONTEXT
923