2 * gdiplusimageattributes.h
\r
4 * GDI+ ImageAttributes class
\r
6 * This file is part of the w32api package.
\r
9 * Created by Markus Koenig <markus@stber-koenig.de>
\r
11 * THIS SOFTWARE IS NOT COPYRIGHTED
\r
13 * This source code is offered for use in the public domain. You may
\r
14 * use, modify or distribute it freely.
\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
23 #ifndef __GDIPLUS_IMAGEATTRIBUTES_H
\r
24 #define __GDIPLUS_IMAGEATTRIBUTES_H
\r
26 #pragma GCC system_header
\r
30 #error "A C++ compiler is required to include gdiplusimageattributes.h."
\r
33 class ImageAttributes: public GdiplusBase
\r
35 friend class Graphics;
\r
36 friend class TextureBrush;
\r
39 ImageAttributes(): nativeImageAttributes(NULL), lastStatus(Ok)
\r
41 lastStatus = DllExports::GdipCreateImageAttributes(
\r
42 &nativeImageAttributes);
\r
46 DllExports::GdipDisposeImageAttributes(nativeImageAttributes);
\r
48 ImageAttributes* Clone() const
\r
50 GpImageAttributes *cloneImageAttributes = NULL;
\r
51 Status status = updateStatus(DllExports::GdipCloneImageAttributes(
\r
52 nativeImageAttributes, &cloneImageAttributes));
\r
54 ImageAttributes *result = new ImageAttributes(
\r
55 cloneImageAttributes, lastStatus);
\r
57 DllExports::GdipDisposeImageAttributes(cloneImageAttributes);
\r
58 lastStatus = OutOfMemory;
\r
66 Status ClearBrushRemapTable()
\r
68 return updateStatus(DllExports::GdipSetImageAttributesRemapTable(
\r
69 nativeImageAttributes, ColorAdjustTypeBrush,
\r
72 Status ClearColorKey(ColorAdjustType type = ColorAdjustTypeDefault)
\r
74 return updateStatus(DllExports::GdipSetImageAttributesColorKeys(
\r
75 nativeImageAttributes, type, FALSE, 0, 0));
\r
77 Status ClearColorMatrices(ColorAdjustType type = ColorAdjustTypeDefault)
\r
79 return updateStatus(DllExports::GdipSetImageAttributesColorMatrix(
\r
80 nativeImageAttributes, type, FALSE,
\r
81 NULL, NULL, ColorMatrixFlagsDefault));
\r
83 Status ClearColorMatrix(ColorAdjustType type = ColorAdjustTypeDefault)
\r
85 return updateStatus(DllExports::GdipSetImageAttributesColorMatrix(
\r
86 nativeImageAttributes, type, FALSE,
\r
87 NULL, NULL, ColorMatrixFlagsDefault));
\r
89 Status ClearGamma(ColorAdjustType type = ColorAdjustTypeDefault)
\r
91 return updateStatus(DllExports::GdipSetImageAttributesGamma(
\r
92 nativeImageAttributes, type, FALSE, 1.0f));
\r
94 Status ClearNoOp(ColorAdjustType type = ColorAdjustTypeDefault)
\r
96 return updateStatus(DllExports::GdipSetImageAttributesNoOp(
\r
97 nativeImageAttributes, type, FALSE));
\r
99 Status ClearOutputChannel(ColorAdjustType type = ColorAdjustTypeDefault)
\r
101 return updateStatus(DllExports::GdipSetImageAttributesOutputChannel(
\r
102 nativeImageAttributes, type, FALSE,
\r
103 ColorChannelFlagsC));
\r
105 Status ClearOutputChannelColorProfile(
\r
106 ColorAdjustType type = ColorAdjustTypeDefault)
\r
108 return updateStatus(DllExports::GdipSetImageAttributesOutputChannelColorProfile(
\r
109 nativeImageAttributes, type, FALSE, NULL));
\r
111 Status ClearRemapTable(ColorAdjustType type = ColorAdjustTypeDefault)
\r
113 return updateStatus(DllExports::GdipSetImageAttributesRemapTable(
\r
114 nativeImageAttributes, type, FALSE, 0, NULL));
\r
116 Status ClearThreshold(ColorAdjustType type = ColorAdjustTypeDefault)
\r
118 return updateStatus(DllExports::GdipSetImageAttributesThreshold(
\r
119 nativeImageAttributes, type, FALSE, 0.0));
\r
121 Status GetAdjustedPalette(ColorPalette *colorPalette,
\r
122 ColorAdjustType type) const
\r
124 return updateStatus(DllExports::GdipGetImageAttributesAdjustedPalette(
\r
125 nativeImageAttributes, colorPalette, type));
\r
127 Status GetLastStatus() const
\r
129 Status result = lastStatus;
\r
133 Status Reset(ColorAdjustType type = ColorAdjustTypeDefault)
\r
135 return updateStatus(DllExports::GdipResetImageAttributes(
\r
136 nativeImageAttributes, type));
\r
138 Status SetBrushRemapTable(UINT mapSize, ColorMap *map)
\r
140 return updateStatus(DllExports::GdipSetImageAttributesRemapTable(
\r
141 nativeImageAttributes, ColorAdjustTypeBrush,
\r
142 TRUE, mapSize, map));
\r
144 Status SetColorKey(const Color& colorLow, const Color& colorHigh,
\r
145 ColorAdjustType type = ColorAdjustTypeDefault)
\r
147 return updateStatus(DllExports::GdipSetImageAttributesColorKeys(
\r
148 nativeImageAttributes, type, TRUE,
\r
149 colorLow.GetValue(), colorHigh.GetValue()));
\r
151 Status SetColorMatrices(const ColorMatrix *colorMatrix,
\r
152 const ColorMatrix *grayMatrix,
\r
153 ColorMatrixFlags mode = ColorMatrixFlagsDefault,
\r
154 ColorAdjustType type = ColorAdjustTypeDefault)
\r
156 return updateStatus(DllExports::GdipSetImageAttributesColorMatrix(
\r
157 nativeImageAttributes, type, TRUE,
\r
158 colorMatrix, grayMatrix, mode));
\r
160 Status SetColorMatrix(const ColorMatrix *colorMatrix,
\r
161 ColorMatrixFlags mode = ColorMatrixFlagsDefault,
\r
162 ColorAdjustType type = ColorAdjustTypeDefault)
\r
164 return updateStatus(DllExports::GdipSetImageAttributesColorMatrix(
\r
165 nativeImageAttributes, type, TRUE,
\r
166 colorMatrix, NULL, mode));
\r
168 Status SetGamma(REAL gamma,
\r
169 ColorAdjustType type = ColorAdjustTypeDefault)
\r
171 return updateStatus(DllExports::GdipSetImageAttributesGamma(
\r
172 nativeImageAttributes, type, TRUE, gamma));
\r
174 Status SetNoOp(ColorAdjustType type = ColorAdjustTypeDefault)
\r
176 return updateStatus(DllExports::GdipSetImageAttributesNoOp(
\r
177 nativeImageAttributes, type, TRUE));
\r
179 Status SetOutputChannel(ColorChannelFlags channelFlags,
\r
180 ColorAdjustType type = ColorAdjustTypeDefault)
\r
182 return updateStatus(DllExports::GdipSetImageAttributesOutputChannel(
\r
183 nativeImageAttributes, type, TRUE,
\r
186 Status SetOutputChannelColorProfile(const WCHAR *colorProfileFilename,
\r
187 ColorAdjustType type = ColorAdjustTypeDefault)
\r
189 return updateStatus(DllExports::GdipSetImageAttributesOutputChannelColorProfile(
\r
190 nativeImageAttributes, type, TRUE,
\r
191 colorProfileFilename));
\r
193 Status SetRemapTable(UINT mapSize, const ColorMap *map,
\r
194 ColorAdjustType type = ColorAdjustTypeDefault)
\r
196 return updateStatus(DllExports::GdipSetImageAttributesRemapTable(
\r
197 nativeImageAttributes, type, TRUE,
\r
200 Status SetThreshold(REAL threshold,
\r
201 ColorAdjustType type = ColorAdjustTypeDefault)
\r
203 return updateStatus(DllExports::GdipSetImageAttributesThreshold(
\r
204 nativeImageAttributes, type, TRUE, threshold));
\r
206 Status SetToIdentity(ColorAdjustType type = ColorAdjustTypeDefault)
\r
208 return updateStatus(DllExports::GdipSetImageAttributesToIdentity(
\r
209 nativeImageAttributes, type));
\r
211 Status SetWrapMode(WrapMode wrap, const Color& color = Color(),
\r
212 BOOL clamp = FALSE)
\r
214 return updateStatus(DllExports::GdipSetImageAttributesWrapMode(
\r
215 nativeImageAttributes, wrap,
\r
216 color.GetValue(), clamp));
\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
225 Status updateStatus(Status newStatus) const
\r
227 if (newStatus != Ok) lastStatus = newStatus;
\r
231 GpImageAttributes *nativeImageAttributes;
\r
232 mutable Status lastStatus;
\r
236 #endif /* __GDIPLUS_IMAGEATTRIBUTES_H */
\r