source: Daodan/MinGW/include/gdiplus/gdiplusimageattributes.h@ 1122

Last change on this file since 1122 was 1046, checked in by alloc, 8 years ago

Daodan: Added Windows MinGW and build batch file

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