Embed:
(wiki syntax)
Show/hide line numbers
gdiplusimageattributes.h
00001 /* 00002 * gdiplusimageattributes.h 00003 * 00004 * GDI+ ImageAttributes class 00005 * 00006 * This file is part of the w32api package. 00007 * 00008 * Contributors: 00009 * Created by Markus Koenig <markus@stber-koenig.de> 00010 * 00011 * THIS SOFTWARE IS NOT COPYRIGHTED 00012 * 00013 * This source code is offered for use in the public domain. You may 00014 * use, modify or distribute it freely. 00015 * 00016 * This code is distributed in the hope that it will be useful but 00017 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY 00018 * DISCLAIMED. This includes but is not limited to warranties of 00019 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00020 * 00021 */ 00022 00023 #ifndef __GDIPLUS_IMAGEATTRIBUTES_H 00024 #define __GDIPLUS_IMAGEATTRIBUTES_H 00025 #if __GNUC__ >=3 00026 #pragma GCC system_header 00027 #endif 00028 00029 #ifndef __cplusplus 00030 #error "A C++ compiler is required to include gdiplusimageattributes.h." 00031 #endif 00032 00033 class ImageAttributes: public GdiplusBase 00034 { 00035 friend class Graphics; 00036 friend class TextureBrush; 00037 00038 public: 00039 ImageAttributes(): nativeImageAttributes(NULL), lastStatus(Ok) 00040 { 00041 lastStatus = DllExports::GdipCreateImageAttributes( 00042 &nativeImageAttributes); 00043 } 00044 ~ImageAttributes() 00045 { 00046 DllExports::GdipDisposeImageAttributes(nativeImageAttributes); 00047 } 00048 ImageAttributes* Clone() const 00049 { 00050 GpImageAttributes *cloneImageAttributes = NULL; 00051 Status status = updateStatus(DllExports::GdipCloneImageAttributes( 00052 nativeImageAttributes, &cloneImageAttributes)); 00053 if (status == Ok) { 00054 ImageAttributes *result = new ImageAttributes( 00055 cloneImageAttributes, lastStatus); 00056 if (!result) { 00057 DllExports::GdipDisposeImageAttributes(cloneImageAttributes); 00058 lastStatus = OutOfMemory; 00059 } 00060 return result; 00061 } else { 00062 return NULL; 00063 } 00064 } 00065 00066 Status ClearBrushRemapTable() 00067 { 00068 return updateStatus(DllExports::GdipSetImageAttributesRemapTable( 00069 nativeImageAttributes, ColorAdjustTypeBrush, 00070 FALSE, 0, NULL)); 00071 } 00072 Status ClearColorKey(ColorAdjustType type = ColorAdjustTypeDefault) 00073 { 00074 return updateStatus(DllExports::GdipSetImageAttributesColorKeys( 00075 nativeImageAttributes, type, FALSE, 0, 0)); 00076 } 00077 Status ClearColorMatrices(ColorAdjustType type = ColorAdjustTypeDefault) 00078 { 00079 return updateStatus(DllExports::GdipSetImageAttributesColorMatrix( 00080 nativeImageAttributes, type, FALSE, 00081 NULL, NULL, ColorMatrixFlagsDefault)); 00082 } 00083 Status ClearColorMatrix(ColorAdjustType type = ColorAdjustTypeDefault) 00084 { 00085 return updateStatus(DllExports::GdipSetImageAttributesColorMatrix( 00086 nativeImageAttributes, type, FALSE, 00087 NULL, NULL, ColorMatrixFlagsDefault)); 00088 } 00089 Status ClearGamma(ColorAdjustType type = ColorAdjustTypeDefault) 00090 { 00091 return updateStatus(DllExports::GdipSetImageAttributesGamma( 00092 nativeImageAttributes, type, FALSE, 1.0f)); 00093 } 00094 Status ClearNoOp(ColorAdjustType type = ColorAdjustTypeDefault) 00095 { 00096 return updateStatus(DllExports::GdipSetImageAttributesNoOp( 00097 nativeImageAttributes, type, FALSE)); 00098 } 00099 Status ClearOutputChannel(ColorAdjustType type = ColorAdjustTypeDefault) 00100 { 00101 return updateStatus(DllExports::GdipSetImageAttributesOutputChannel( 00102 nativeImageAttributes, type, FALSE, 00103 ColorChannelFlagsC)); 00104 } 00105 Status ClearOutputChannelColorProfile( 00106 ColorAdjustType type = ColorAdjustTypeDefault) 00107 { 00108 return updateStatus(DllExports::GdipSetImageAttributesOutputChannelColorProfile( 00109 nativeImageAttributes, type, FALSE, NULL)); 00110 } 00111 Status ClearRemapTable(ColorAdjustType type = ColorAdjustTypeDefault) 00112 { 00113 return updateStatus(DllExports::GdipSetImageAttributesRemapTable( 00114 nativeImageAttributes, type, FALSE, 0, NULL)); 00115 } 00116 Status ClearThreshold(ColorAdjustType type = ColorAdjustTypeDefault) 00117 { 00118 return updateStatus(DllExports::GdipSetImageAttributesThreshold( 00119 nativeImageAttributes, type, FALSE, 0.0)); 00120 } 00121 Status GetAdjustedPalette(ColorPalette *colorPalette, 00122 ColorAdjustType type) const 00123 { 00124 return updateStatus(DllExports::GdipGetImageAttributesAdjustedPalette( 00125 nativeImageAttributes, colorPalette, type)); 00126 } 00127 Status GetLastStatus() const 00128 { 00129 Status result = lastStatus; 00130 lastStatus = Ok; 00131 return result; 00132 } 00133 Status Reset(ColorAdjustType type = ColorAdjustTypeDefault) 00134 { 00135 return updateStatus(DllExports::GdipResetImageAttributes( 00136 nativeImageAttributes, type)); 00137 } 00138 Status SetBrushRemapTable(UINT mapSize, ColorMap *map) 00139 { 00140 return updateStatus(DllExports::GdipSetImageAttributesRemapTable( 00141 nativeImageAttributes, ColorAdjustTypeBrush, 00142 TRUE, mapSize, map)); 00143 } 00144 Status SetColorKey(const Color& colorLow, const Color& colorHigh, 00145 ColorAdjustType type = ColorAdjustTypeDefault) 00146 { 00147 return updateStatus(DllExports::GdipSetImageAttributesColorKeys( 00148 nativeImageAttributes, type, TRUE, 00149 colorLow.GetValue(), colorHigh.GetValue())); 00150 } 00151 Status SetColorMatrices(const ColorMatrix *colorMatrix, 00152 const ColorMatrix *grayMatrix, 00153 ColorMatrixFlags mode = ColorMatrixFlagsDefault, 00154 ColorAdjustType type = ColorAdjustTypeDefault) 00155 { 00156 return updateStatus(DllExports::GdipSetImageAttributesColorMatrix( 00157 nativeImageAttributes, type, TRUE, 00158 colorMatrix, grayMatrix, mode)); 00159 } 00160 Status SetColorMatrix(const ColorMatrix *colorMatrix, 00161 ColorMatrixFlags mode = ColorMatrixFlagsDefault, 00162 ColorAdjustType type = ColorAdjustTypeDefault) 00163 { 00164 return updateStatus(DllExports::GdipSetImageAttributesColorMatrix( 00165 nativeImageAttributes, type, TRUE, 00166 colorMatrix, NULL, mode)); 00167 } 00168 Status SetGamma(REAL gamma, 00169 ColorAdjustType type = ColorAdjustTypeDefault) 00170 { 00171 return updateStatus(DllExports::GdipSetImageAttributesGamma( 00172 nativeImageAttributes, type, TRUE, gamma)); 00173 } 00174 Status SetNoOp(ColorAdjustType type = ColorAdjustTypeDefault) 00175 { 00176 return updateStatus(DllExports::GdipSetImageAttributesNoOp( 00177 nativeImageAttributes, type, TRUE)); 00178 } 00179 Status SetOutputChannel(ColorChannelFlags channelFlags, 00180 ColorAdjustType type = ColorAdjustTypeDefault) 00181 { 00182 return updateStatus(DllExports::GdipSetImageAttributesOutputChannel( 00183 nativeImageAttributes, type, TRUE, 00184 channelFlags)); 00185 } 00186 Status SetOutputChannelColorProfile(const WCHAR *colorProfileFilename, 00187 ColorAdjustType type = ColorAdjustTypeDefault) 00188 { 00189 return updateStatus(DllExports::GdipSetImageAttributesOutputChannelColorProfile( 00190 nativeImageAttributes, type, TRUE, 00191 colorProfileFilename)); 00192 } 00193 Status SetRemapTable(UINT mapSize, const ColorMap *map, 00194 ColorAdjustType type = ColorAdjustTypeDefault) 00195 { 00196 return updateStatus(DllExports::GdipSetImageAttributesRemapTable( 00197 nativeImageAttributes, type, TRUE, 00198 mapSize, map)); 00199 } 00200 Status SetThreshold(REAL threshold, 00201 ColorAdjustType type = ColorAdjustTypeDefault) 00202 { 00203 return updateStatus(DllExports::GdipSetImageAttributesThreshold( 00204 nativeImageAttributes, type, TRUE, threshold)); 00205 } 00206 Status SetToIdentity(ColorAdjustType type = ColorAdjustTypeDefault) 00207 { 00208 return updateStatus(DllExports::GdipSetImageAttributesToIdentity( 00209 nativeImageAttributes, type)); 00210 } 00211 Status SetWrapMode(WrapMode wrap, const Color& color = Color(), 00212 BOOL clamp = FALSE) 00213 { 00214 return updateStatus(DllExports::GdipSetImageAttributesWrapMode( 00215 nativeImageAttributes, wrap, 00216 color.GetValue(), clamp)); 00217 } 00218 00219 private: 00220 ImageAttributes(GpImageAttributes *imageAttributes, Status status): 00221 nativeImageAttributes(imageAttributes), lastStatus(status) {} 00222 ImageAttributes(const ImageAttributes&); 00223 ImageAttributes& operator=(const ImageAttributes&); 00224 00225 Status updateStatus(Status newStatus) const 00226 { 00227 if (newStatus != Ok) lastStatus = newStatus; 00228 return newStatus; 00229 } 00230 00231 GpImageAttributes *nativeImageAttributes; 00232 mutable Status lastStatus; 00233 }; 00234 00235 00236 #endif /* __GDIPLUS_IMAGEATTRIBUTES_H */
Generated on Tue Jul 12 2022 19:59:54 by
1.7.2