OSDN Git Service

Prepare environment for Earnie's tools.
[mingw/mingw-org-wsl.git] / w32api / include / gdiplus / gdiplusimageattributes.h
1 /*\r
2  * gdiplusimageattributes.h\r
3  *\r
4  * GDI+ ImageAttributes class\r
5  *\r
6  * This file is part of the w32api package.\r
7  *\r
8  * Contributors:\r
9  *   Created by Markus Koenig <markus@stber-koenig.de>\r
10  *\r
11  * THIS SOFTWARE IS NOT COPYRIGHTED\r
12  *\r
13  * This source code is offered for use in the public domain. You may\r
14  * use, modify or distribute it freely.\r
15  *\r
16  * This code is distributed in the hope that it will be useful but\r
17  * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY\r
18  * DISCLAIMED. This includes but is not limited to warranties of\r
19  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\r
20  *\r
21  */\r
22 \r
23 #ifndef __GDIPLUS_IMAGEATTRIBUTES_H\r
24 #define __GDIPLUS_IMAGEATTRIBUTES_H\r
25 #if __GNUC__ >=3\r
26 #pragma GCC system_header\r
27 #endif\r
28 \r
29 #ifndef __cplusplus\r
30 #error "A C++ compiler is required to include gdiplusimageattributes.h."\r
31 #endif\r
32 \r
33 class ImageAttributes: public GdiplusBase\r
34 {\r
35         friend class Graphics;\r
36         friend class TextureBrush;\r
37 \r
38 public:\r
39         ImageAttributes(): nativeImageAttributes(NULL), lastStatus(Ok)\r
40         {\r
41                 lastStatus = DllExports::GdipCreateImageAttributes(\r
42                                 &nativeImageAttributes);\r
43         }\r
44         ~ImageAttributes()\r
45         {\r
46                 DllExports::GdipDisposeImageAttributes(nativeImageAttributes);\r
47         }\r
48         ImageAttributes* Clone() const\r
49         {\r
50                 GpImageAttributes *cloneImageAttributes = NULL;\r
51                 Status status = updateStatus(DllExports::GdipCloneImageAttributes(\r
52                                 nativeImageAttributes, &cloneImageAttributes));\r
53                 if (status == Ok) {\r
54                         ImageAttributes *result = new ImageAttributes(\r
55                                         cloneImageAttributes, lastStatus);\r
56                         if (!result) {\r
57                                 DllExports::GdipDisposeImageAttributes(cloneImageAttributes);\r
58                                 lastStatus = OutOfMemory;\r
59                         }\r
60                         return result;\r
61                 } else {\r
62                         return NULL;\r
63                 }\r
64         }\r
65 \r
66         Status ClearBrushRemapTable()\r
67         {\r
68                 return updateStatus(DllExports::GdipSetImageAttributesRemapTable(\r
69                                 nativeImageAttributes, ColorAdjustTypeBrush,\r
70                                 FALSE, 0, NULL));\r
71         }\r
72         Status ClearColorKey(ColorAdjustType type = ColorAdjustTypeDefault)\r
73         {\r
74                 return updateStatus(DllExports::GdipSetImageAttributesColorKeys(\r
75                                 nativeImageAttributes, type, FALSE, 0, 0));\r
76         }\r
77         Status ClearColorMatrices(ColorAdjustType type = ColorAdjustTypeDefault)\r
78         {\r
79                 return updateStatus(DllExports::GdipSetImageAttributesColorMatrix(\r
80                                 nativeImageAttributes, type, FALSE,\r
81                                 NULL, NULL, ColorMatrixFlagsDefault));\r
82         }\r
83         Status ClearColorMatrix(ColorAdjustType type = ColorAdjustTypeDefault)\r
84         {\r
85                 return updateStatus(DllExports::GdipSetImageAttributesColorMatrix(\r
86                                 nativeImageAttributes, type, FALSE,\r
87                                 NULL, NULL, ColorMatrixFlagsDefault));\r
88         }\r
89         Status ClearGamma(ColorAdjustType type = ColorAdjustTypeDefault)\r
90         {\r
91                 return updateStatus(DllExports::GdipSetImageAttributesGamma(\r
92                                 nativeImageAttributes, type, FALSE, 1.0f));\r
93         }\r
94         Status ClearNoOp(ColorAdjustType type = ColorAdjustTypeDefault)\r
95         {\r
96                 return updateStatus(DllExports::GdipSetImageAttributesNoOp(\r
97                                 nativeImageAttributes, type, FALSE));\r
98         }\r
99         Status ClearOutputChannel(ColorAdjustType type = ColorAdjustTypeDefault)\r
100         {\r
101                 return updateStatus(DllExports::GdipSetImageAttributesOutputChannel(\r
102                                 nativeImageAttributes, type, FALSE,\r
103                                 ColorChannelFlagsC));\r
104         }\r
105         Status ClearOutputChannelColorProfile(\r
106                         ColorAdjustType type = ColorAdjustTypeDefault)\r
107         {\r
108                 return updateStatus(DllExports::GdipSetImageAttributesOutputChannelColorProfile(\r
109                                 nativeImageAttributes, type, FALSE, NULL));\r
110         }\r
111         Status ClearRemapTable(ColorAdjustType type = ColorAdjustTypeDefault)\r
112         {\r
113                 return updateStatus(DllExports::GdipSetImageAttributesRemapTable(\r
114                                 nativeImageAttributes, type, FALSE, 0, NULL));\r
115         }\r
116         Status ClearThreshold(ColorAdjustType type = ColorAdjustTypeDefault)\r
117         {\r
118                 return updateStatus(DllExports::GdipSetImageAttributesThreshold(\r
119                                 nativeImageAttributes, type, FALSE, 0.0));\r
120         }\r
121         Status GetAdjustedPalette(ColorPalette *colorPalette,\r
122                         ColorAdjustType type) const\r
123         {\r
124                 return updateStatus(DllExports::GdipGetImageAttributesAdjustedPalette(\r
125                                 nativeImageAttributes, colorPalette, type));\r
126         }\r
127         Status GetLastStatus() const\r
128         {\r
129                 Status result = lastStatus;\r
130                 lastStatus = Ok;\r
131                 return result;\r
132         }\r
133         Status Reset(ColorAdjustType type = ColorAdjustTypeDefault)\r
134         {\r
135                 return updateStatus(DllExports::GdipResetImageAttributes(\r
136                                 nativeImageAttributes, type));\r
137         }\r
138         Status SetBrushRemapTable(UINT mapSize, ColorMap *map)\r
139         {\r
140                 return updateStatus(DllExports::GdipSetImageAttributesRemapTable(\r
141                                 nativeImageAttributes, ColorAdjustTypeBrush,\r
142                                 TRUE, mapSize, map));\r
143         }\r
144         Status SetColorKey(const Color& colorLow, const Color& colorHigh,\r
145                         ColorAdjustType type = ColorAdjustTypeDefault)\r
146         {\r
147                 return updateStatus(DllExports::GdipSetImageAttributesColorKeys(\r
148                                 nativeImageAttributes, type, TRUE,\r
149                                 colorLow.GetValue(), colorHigh.GetValue()));\r
150         }\r
151         Status SetColorMatrices(const ColorMatrix *colorMatrix,\r
152                         const ColorMatrix *grayMatrix,\r
153                         ColorMatrixFlags mode = ColorMatrixFlagsDefault,\r
154                         ColorAdjustType type = ColorAdjustTypeDefault)\r
155         {\r
156                 return updateStatus(DllExports::GdipSetImageAttributesColorMatrix(\r
157                                 nativeImageAttributes, type, TRUE,\r
158                                 colorMatrix, grayMatrix, mode));\r
159         }\r
160         Status SetColorMatrix(const ColorMatrix *colorMatrix,\r
161                         ColorMatrixFlags mode = ColorMatrixFlagsDefault,\r
162                         ColorAdjustType type = ColorAdjustTypeDefault)\r
163         {\r
164                 return updateStatus(DllExports::GdipSetImageAttributesColorMatrix(\r
165                                 nativeImageAttributes, type, TRUE,\r
166                                 colorMatrix, NULL, mode));\r
167         }\r
168         Status SetGamma(REAL gamma,\r
169                         ColorAdjustType type = ColorAdjustTypeDefault)\r
170         {\r
171                 return updateStatus(DllExports::GdipSetImageAttributesGamma(\r
172                                 nativeImageAttributes, type, TRUE, gamma));\r
173         }\r
174         Status SetNoOp(ColorAdjustType type = ColorAdjustTypeDefault)\r
175         {\r
176                 return updateStatus(DllExports::GdipSetImageAttributesNoOp(\r
177                                 nativeImageAttributes, type, TRUE));\r
178         }\r
179         Status SetOutputChannel(ColorChannelFlags channelFlags,\r
180                         ColorAdjustType type = ColorAdjustTypeDefault)\r
181         {\r
182                 return updateStatus(DllExports::GdipSetImageAttributesOutputChannel(\r
183                                 nativeImageAttributes, type, TRUE,\r
184                                 channelFlags));\r
185         }\r
186         Status SetOutputChannelColorProfile(const WCHAR *colorProfileFilename,\r
187                         ColorAdjustType type = ColorAdjustTypeDefault)\r
188         {\r
189                 return updateStatus(DllExports::GdipSetImageAttributesOutputChannelColorProfile(\r
190                                 nativeImageAttributes, type, TRUE,\r
191                                 colorProfileFilename));\r
192         }\r
193         Status SetRemapTable(UINT mapSize, const ColorMap *map,\r
194                         ColorAdjustType type = ColorAdjustTypeDefault)\r
195         {\r
196                 return updateStatus(DllExports::GdipSetImageAttributesRemapTable(\r
197                                 nativeImageAttributes, type, TRUE,\r
198                                 mapSize, map));\r
199         }\r
200         Status SetThreshold(REAL threshold,\r
201                         ColorAdjustType type = ColorAdjustTypeDefault)\r
202         {\r
203                 return updateStatus(DllExports::GdipSetImageAttributesThreshold(\r
204                                 nativeImageAttributes, type, TRUE, threshold));\r
205         }\r
206         Status SetToIdentity(ColorAdjustType type = ColorAdjustTypeDefault)\r
207         {\r
208                 return updateStatus(DllExports::GdipSetImageAttributesToIdentity(\r
209                                 nativeImageAttributes, type));\r
210         }\r
211         Status SetWrapMode(WrapMode wrap, const Color& color = Color(),\r
212                         BOOL clamp = FALSE)\r
213         {\r
214                 return updateStatus(DllExports::GdipSetImageAttributesWrapMode(\r
215                                 nativeImageAttributes, wrap,\r
216                                 color.GetValue(), clamp));\r
217         }\r
218 \r
219 private:\r
220         ImageAttributes(GpImageAttributes *imageAttributes, Status status):\r
221                 nativeImageAttributes(imageAttributes), lastStatus(status) {}\r
222         ImageAttributes(const ImageAttributes&);\r
223         ImageAttributes& operator=(const ImageAttributes&);\r
224 \r
225         Status updateStatus(Status newStatus) const\r
226         {\r
227                 if (newStatus != Ok) lastStatus = newStatus;\r
228                 return newStatus;\r
229         }\r
230 \r
231         GpImageAttributes *nativeImageAttributes;\r
232         mutable Status lastStatus;\r
233 };\r
234 \r
235 \r
236 #endif /* __GDIPLUS_IMAGEATTRIBUTES_H */\r