devenum: COM cleanup for IMoniker (MediaCatMoniker).
[wine/multimedia.git] / dlls / gdiplus / imageattributes.c
blobbd5c0826cec3d43fbaa6d89fcc94685bc889329c
1 /*
2 * Copyright (C) 2007 Google (Evan Stade)
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
19 #include "windef.h"
20 #include "wingdi.h"
22 #include "objbase.h"
24 #include "gdiplus.h"
25 #include "gdiplus_private.h"
26 #include "wine/debug.h"
28 WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
30 GpStatus WINGDIPAPI GdipCloneImageAttributes(GDIPCONST GpImageAttributes *imageattr,
31 GpImageAttributes **cloneImageattr)
33 GpStatus stat;
35 TRACE("(%p, %p)\n", imageattr, cloneImageattr);
37 if(!imageattr || !cloneImageattr)
38 return InvalidParameter;
40 stat = GdipCreateImageAttributes(cloneImageattr);
42 if (stat == Ok)
43 **cloneImageattr = *imageattr;
45 return stat;
48 GpStatus WINGDIPAPI GdipCreateImageAttributes(GpImageAttributes **imageattr)
50 if(!imageattr)
51 return InvalidParameter;
53 *imageattr = GdipAlloc(sizeof(GpImageAttributes));
54 if(!*imageattr) return OutOfMemory;
56 (*imageattr)->wrap = WrapModeClamp;
58 TRACE("<-- %p\n", *imageattr);
60 return Ok;
63 GpStatus WINGDIPAPI GdipDisposeImageAttributes(GpImageAttributes *imageattr)
65 int i;
67 TRACE("(%p)\n", imageattr);
69 if(!imageattr)
70 return InvalidParameter;
72 for (i=0; i<ColorAdjustTypeCount; i++)
73 GdipFree(imageattr->colorremaptables[i].colormap);
75 GdipFree(imageattr);
77 return Ok;
80 GpStatus WINGDIPAPI GdipSetImageAttributesColorKeys(GpImageAttributes *imageattr,
81 ColorAdjustType type, BOOL enableFlag, ARGB colorLow, ARGB colorHigh)
83 TRACE("(%p,%u,%i,%08x,%08x)\n", imageattr, type, enableFlag, colorLow, colorHigh);
85 if(!imageattr || type >= ColorAdjustTypeCount)
86 return InvalidParameter;
88 imageattr->colorkeys[type].enabled = enableFlag;
89 imageattr->colorkeys[type].low = colorLow;
90 imageattr->colorkeys[type].high = colorHigh;
92 return Ok;
95 GpStatus WINGDIPAPI GdipSetImageAttributesColorMatrix(GpImageAttributes *imageattr,
96 ColorAdjustType type, BOOL enableFlag, GDIPCONST ColorMatrix* colorMatrix,
97 GDIPCONST ColorMatrix* grayMatrix, ColorMatrixFlags flags)
99 TRACE("(%p,%u,%i,%p,%p,%u)\n", imageattr, type, enableFlag, colorMatrix,
100 grayMatrix, flags);
102 if(!imageattr || type >= ColorAdjustTypeCount || flags > ColorMatrixFlagsAltGray)
103 return InvalidParameter;
105 if (enableFlag)
107 if (!colorMatrix)
108 return InvalidParameter;
110 if (flags == ColorMatrixFlagsAltGray)
112 if (!grayMatrix)
113 return InvalidParameter;
115 imageattr->colormatrices[type].graymatrix = *grayMatrix;
118 imageattr->colormatrices[type].colormatrix = *colorMatrix;
119 imageattr->colormatrices[type].flags = flags;
122 imageattr->colormatrices[type].enabled = enableFlag;
124 return Ok;
127 GpStatus WINGDIPAPI GdipSetImageAttributesWrapMode(GpImageAttributes *imageAttr,
128 WrapMode wrap, ARGB argb, BOOL clamp)
130 TRACE("(%p,%u,%08x,%i)\n", imageAttr, wrap, argb, clamp);
132 if(!imageAttr || wrap > WrapModeClamp)
133 return InvalidParameter;
135 imageAttr->wrap = wrap;
136 imageAttr->outside_color = argb;
137 imageAttr->clamp = clamp;
139 return Ok;
142 GpStatus WINGDIPAPI GdipSetImageAttributesCachedBackground(GpImageAttributes *imageAttr,
143 BOOL enableFlag)
145 static int calls;
147 TRACE("(%p,%i)\n", imageAttr, enableFlag);
149 if(!(calls++))
150 FIXME("not implemented\n");
152 return NotImplemented;
155 GpStatus WINGDIPAPI GdipSetImageAttributesGamma(GpImageAttributes *imageAttr,
156 ColorAdjustType type, BOOL enableFlag, REAL gamma)
158 TRACE("(%p,%u,%i,%0.2f)\n", imageAttr, type, enableFlag, gamma);
160 if (!imageAttr || (enableFlag && gamma <= 0.0) || type >= ColorAdjustTypeCount)
161 return InvalidParameter;
163 imageAttr->gamma_enabled[type] = enableFlag;
164 imageAttr->gamma[type] = gamma;
166 return Ok;
169 GpStatus WINGDIPAPI GdipSetImageAttributesNoOp(GpImageAttributes *imageAttr,
170 ColorAdjustType type, BOOL enableFlag)
172 static int calls;
174 TRACE("(%p,%u,%i)\n", imageAttr, type, enableFlag);
176 if(!(calls++))
177 FIXME("not implemented\n");
179 return NotImplemented;
182 GpStatus WINGDIPAPI GdipSetImageAttributesOutputChannel(GpImageAttributes *imageAttr,
183 ColorAdjustType type, BOOL enableFlag, ColorChannelFlags channelFlags)
185 static int calls;
187 TRACE("(%p,%u,%i,%x)\n", imageAttr, type, enableFlag, channelFlags);
189 if(!(calls++))
190 FIXME("not implemented\n");
192 return NotImplemented;
195 GpStatus WINGDIPAPI GdipSetImageAttributesOutputChannelColorProfile(GpImageAttributes *imageAttr,
196 ColorAdjustType type, BOOL enableFlag,
197 GDIPCONST WCHAR *colorProfileFilename)
199 static int calls;
201 TRACE("(%p,%u,%i,%s)\n", imageAttr, type, enableFlag, debugstr_w(colorProfileFilename));
203 if(!(calls++))
204 FIXME("not implemented\n");
206 return NotImplemented;
209 GpStatus WINGDIPAPI GdipSetImageAttributesRemapTable(GpImageAttributes *imageAttr,
210 ColorAdjustType type, BOOL enableFlag, UINT mapSize,
211 GDIPCONST ColorMap *map)
213 ColorMap *new_map;
215 TRACE("(%p,%u,%i,%u,%p)\n", imageAttr, type, enableFlag, mapSize, map);
217 if(!imageAttr || type >= ColorAdjustTypeCount)
218 return InvalidParameter;
220 if (enableFlag)
222 if(!map || !mapSize)
223 return InvalidParameter;
225 new_map = GdipAlloc(sizeof(*map) * mapSize);
227 if (!new_map)
228 return OutOfMemory;
230 memcpy(new_map, map, sizeof(*map) * mapSize);
232 GdipFree(imageAttr->colorremaptables[type].colormap);
234 imageAttr->colorremaptables[type].mapsize = mapSize;
235 imageAttr->colorremaptables[type].colormap = new_map;
237 else
239 GdipFree(imageAttr->colorremaptables[type].colormap);
240 imageAttr->colorremaptables[type].colormap = NULL;
243 imageAttr->colorremaptables[type].enabled = enableFlag;
245 return Ok;
248 GpStatus WINGDIPAPI GdipSetImageAttributesThreshold(GpImageAttributes *imageAttr,
249 ColorAdjustType type, BOOL enableFlag, REAL threshold)
251 static int calls;
253 TRACE("(%p,%u,%i,%0.2f)\n", imageAttr, type, enableFlag, threshold);
255 if(!(calls++))
256 FIXME("not implemented\n");
258 return NotImplemented;
261 GpStatus WINGDIPAPI GdipSetImageAttributesToIdentity(GpImageAttributes *imageAttr,
262 ColorAdjustType type)
264 static int calls;
266 TRACE("(%p,%u)\n", imageAttr, type);
268 if(!(calls++))
269 FIXME("not implemented\n");
271 return NotImplemented;