2 * GdiPlusImageAttributes.h
6 * This file is part of the w32api package.
8 * THIS SOFTWARE IS NOT COPYRIGHTED
10 * This source code is offered for use in the public domain. You may
11 * use, modify or distribute it freely.
13 * This code is distributed in the hope that it will be useful but
14 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
15 * DISCLAIMED. This includes but is not limited to warranties of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
19 #ifndef _GDIPLUSIMAGEATTRIBUTES_H
20 #define _GDIPLUSIMAGEATTRIBUTES_H
22 class ImageAttributes
: public GdiplusBase
25 friend class TextureBrush
;
27 ImageAttributes() : nativeImageAttr(NULL
)
29 lastStatus
= DllExports::GdipCreateImageAttributes(&nativeImageAttr
);
34 DllExports::GdipDisposeImageAttributes(nativeImageAttr
);
38 ClearBrushRemapTable()
40 return ClearRemapTable(ColorAdjustTypeBrush
);
44 ClearColorKey(ColorAdjustType type
= ColorAdjustTypeDefault
)
46 return SetStatus(DllExports::GdipSetImageAttributesColorKeys(nativeImageAttr
, type
, FALSE
, NULL
, NULL
));
50 ClearColorMatrices(ColorAdjustType type
= ColorAdjustTypeDefault
)
52 return SetStatus(DllExports::GdipSetImageAttributesColorMatrix(
53 nativeImageAttr
, type
, FALSE
, NULL
, NULL
, ColorMatrixFlagsDefault
));
57 ClearColorMatrix(ColorAdjustType type
= ColorAdjustTypeDefault
)
59 return SetStatus(DllExports::GdipSetImageAttributesColorMatrix(
60 nativeImageAttr
, type
, FALSE
, NULL
, NULL
, ColorMatrixFlagsDefault
));
64 ClearGamma(ColorAdjustType type
= ColorAdjustTypeDefault
)
66 return SetStatus(DllExports::GdipSetImageAttributesGamma(nativeImageAttr
, type
, FALSE
, 0.0));
70 ClearNoOp(ColorAdjustType type
= ColorAdjustTypeDefault
)
72 return SetStatus(DllExports::GdipSetImageAttributesNoOp(nativeImageAttr
, type
, FALSE
));
76 ClearOutputChannel(ColorAdjustType type
= ColorAdjustTypeDefault
)
79 DllExports::GdipSetImageAttributesOutputChannel(nativeImageAttr
, type
, FALSE
, ColorChannelFlagsLast
));
83 ClearOutputChannelColorProfile(ColorAdjustType type
= ColorAdjustTypeDefault
)
86 DllExports::GdipSetImageAttributesOutputChannelColorProfile(nativeImageAttr
, type
, FALSE
, NULL
));
90 ClearRemapTable(ColorAdjustType type
= ColorAdjustTypeDefault
)
92 return SetStatus(DllExports::GdipSetImageAttributesRemapTable(nativeImageAttr
, type
, FALSE
, 0, NULL
));
96 ClearThreshold(ColorAdjustType type
= ColorAdjustTypeDefault
)
98 return SetStatus(DllExports::GdipSetImageAttributesThreshold(nativeImageAttr
, type
, FALSE
, 0.0));
104 GpImageAttributes
*clone
= NULL
;
105 SetStatus(DllExports::GdipCloneImageAttributes(nativeImageAttr
, &clone
));
106 if (lastStatus
!= Ok
)
109 ImageAttributes
*newImageAttr
= new ImageAttributes(clone
, lastStatus
);
110 if (newImageAttr
== NULL
)
111 SetStatus(DllExports::GdipDisposeImageAttributes(clone
));
117 GetAdjustedPalette(ColorPalette
*colorPalette
, ColorAdjustType colorAdjustType
)
120 DllExports::GdipGetImageAttributesAdjustedPalette(nativeImageAttr
, colorPalette
, colorAdjustType
));
130 Reset(ColorAdjustType type
= ColorAdjustTypeDefault
)
132 return SetStatus(DllExports::GdipResetImageAttributes(nativeImageAttr
, type
));
136 SetBrushRemapTable(UINT mapSize
, ColorMap
*map
)
138 return SetRemapTable(mapSize
, map
, ColorAdjustTypeBrush
);
142 SetColorKey(const Color
&colorLow
, const Color
&colorHigh
, ColorAdjustType type
= ColorAdjustTypeDefault
)
144 return SetStatus(DllExports::GdipSetImageAttributesColorKeys(
145 nativeImageAttr
, type
, TRUE
, colorLow
.GetValue(), colorHigh
.GetValue()));
150 const ColorMatrix
*colorMatrix
,
151 const ColorMatrix
*grayMatrix
,
152 ColorMatrixFlags mode
= ColorMatrixFlagsDefault
,
153 ColorAdjustType type
= ColorAdjustTypeDefault
)
156 DllExports::GdipSetImageAttributesColorMatrix(nativeImageAttr
, type
, TRUE
, colorMatrix
, grayMatrix
, mode
));
161 const ColorMatrix
*colorMatrix
,
162 ColorMatrixFlags mode
= ColorMatrixFlagsDefault
,
163 ColorAdjustType type
= ColorAdjustTypeDefault
)
166 DllExports::GdipSetImageAttributesColorMatrix(nativeImageAttr
, type
, TRUE
, colorMatrix
, NULL
, mode
));
170 SetGamma(REAL gamma
, ColorAdjustType type
= ColorAdjustTypeDefault
)
172 return SetStatus(DllExports::GdipSetImageAttributesGamma(nativeImageAttr
, type
, TRUE
, gamma
));
176 SetNoOp(ColorAdjustType type
= ColorAdjustTypeDefault
)
178 return SetStatus(DllExports::GdipSetImageAttributesNoOp(nativeImageAttr
, type
, TRUE
));
182 SetOutputChannel(ColorChannelFlags channelFlags
, ColorAdjustType type
= ColorAdjustTypeDefault
)
184 return SetStatus(DllExports::GdipSetImageAttributesOutputChannel(nativeImageAttr
, type
, TRUE
, channelFlags
));
188 SetOutputChannelColorProfile(const WCHAR
*colorProfileFilename
, ColorAdjustType type
= ColorAdjustTypeDefault
)
190 return SetStatus(DllExports::GdipSetImageAttributesOutputChannelColorProfile(
191 nativeImageAttr
, type
, TRUE
, colorProfileFilename
));
195 SetRemapTable(UINT mapSize
, const ColorMap
*map
, ColorAdjustType type
= ColorAdjustTypeDefault
)
197 return SetStatus(DllExports::GdipSetImageAttributesRemapTable(nativeImageAttr
, type
, TRUE
, mapSize
, map
));
201 SetThreshold(REAL threshold
, ColorAdjustType type
= ColorAdjustTypeDefault
)
203 return SetStatus(DllExports::GdipSetImageAttributesThreshold(nativeImageAttr
, type
, TRUE
, threshold
));
207 SetToIdentity(ColorAdjustType type
= ColorAdjustTypeDefault
)
209 return SetStatus(DllExports::GdipSetImageAttributesToIdentity(nativeImageAttr
, type
));
213 SetWrapMode(WrapMode wrap
, const Color
&color
= Color(), BOOL clamp
= FALSE
)
215 ARGB argb
= color
.GetValue();
216 return SetStatus(DllExports::GdipSetImageAttributesWrapMode(nativeImageAttr
, wrap
, argb
, clamp
));
220 GpImageAttributes
*nativeImageAttr
;
221 mutable Status lastStatus
;
223 ImageAttributes(GpImageAttributes
*imageAttr
, Status status
) : nativeImageAttr(imageAttr
), lastStatus(status
)
228 SetNativeImageAttr(GpImageAttributes
*imageAttr
)
230 nativeImageAttr
= imageAttr
;
234 SetStatus(Status status
) const
242 // ImageAttributes is not copyable
243 ImageAttributes(const ImageAttributes
&);
245 operator=(const ImageAttributes
&);
248 friend inline GpImageAttributes
*&
249 getNat(const ImageAttributes
*ia
)
251 return const_cast<ImageAttributes
*>(ia
)->nativeImageAttr
;
255 #endif /* _GDIPLUSIMAGEATTRIBUTES_H */