wined3d: Pass a texture and sub-resource index to wined3d_volume_download_data().
[wine.git] / dlls / gdiplus / imageattributes.c
bloba76fe3b1c1f99a3d124a5c68dec89fdfaffad619
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 = heap_alloc_zero(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 heap_free(imageattr->colorremaptables[i].colormap);
75 heap_free(imageattr);
77 return Ok;
80 GpStatus WINGDIPAPI GdipGetImageAttributesAdjustedPalette(GpImageAttributes *imageattr,
81 ColorPalette *palette, ColorAdjustType type)
83 TRACE("(%p,%p,%u)\n", imageattr, palette, type);
85 if (!imageattr || !palette || !palette->Count ||
86 type >= ColorAdjustTypeCount || type == ColorAdjustTypeDefault)
87 return InvalidParameter;
89 apply_image_attributes(imageattr, (LPBYTE)palette->Entries, palette->Count, 1, 0,
90 type, PixelFormat32bppARGB);
92 return Ok;
95 GpStatus WINGDIPAPI GdipSetImageAttributesColorKeys(GpImageAttributes *imageattr,
96 ColorAdjustType type, BOOL enableFlag, ARGB colorLow, ARGB colorHigh)
98 TRACE("(%p,%u,%i,%08x,%08x)\n", imageattr, type, enableFlag, colorLow, colorHigh);
100 if(!imageattr || type >= ColorAdjustTypeCount)
101 return InvalidParameter;
103 imageattr->colorkeys[type].enabled = enableFlag;
104 imageattr->colorkeys[type].low = colorLow;
105 imageattr->colorkeys[type].high = colorHigh;
107 return Ok;
110 GpStatus WINGDIPAPI GdipSetImageAttributesColorMatrix(GpImageAttributes *imageattr,
111 ColorAdjustType type, BOOL enableFlag, GDIPCONST ColorMatrix* colorMatrix,
112 GDIPCONST ColorMatrix* grayMatrix, ColorMatrixFlags flags)
114 TRACE("(%p,%u,%i,%p,%p,%u)\n", imageattr, type, enableFlag, colorMatrix,
115 grayMatrix, flags);
117 if(!imageattr || type >= ColorAdjustTypeCount || flags > ColorMatrixFlagsAltGray)
118 return InvalidParameter;
120 if (enableFlag)
122 if (!colorMatrix)
123 return InvalidParameter;
125 if (flags == ColorMatrixFlagsAltGray)
127 if (!grayMatrix)
128 return InvalidParameter;
130 imageattr->colormatrices[type].graymatrix = *grayMatrix;
133 imageattr->colormatrices[type].colormatrix = *colorMatrix;
134 imageattr->colormatrices[type].flags = flags;
137 imageattr->colormatrices[type].enabled = enableFlag;
139 return Ok;
142 GpStatus WINGDIPAPI GdipSetImageAttributesWrapMode(GpImageAttributes *imageAttr,
143 WrapMode wrap, ARGB argb, BOOL clamp)
145 TRACE("(%p,%u,%08x,%i)\n", imageAttr, wrap, argb, clamp);
147 if(!imageAttr || wrap > WrapModeClamp)
148 return InvalidParameter;
150 imageAttr->wrap = wrap;
151 imageAttr->outside_color = argb;
152 imageAttr->clamp = clamp;
154 return Ok;
157 GpStatus WINGDIPAPI GdipSetImageAttributesCachedBackground(GpImageAttributes *imageAttr,
158 BOOL enableFlag)
160 static int calls;
162 TRACE("(%p,%i)\n", imageAttr, enableFlag);
164 if(!(calls++))
165 FIXME("not implemented\n");
167 return NotImplemented;
170 GpStatus WINGDIPAPI GdipSetImageAttributesGamma(GpImageAttributes *imageAttr,
171 ColorAdjustType type, BOOL enableFlag, REAL gamma)
173 TRACE("(%p,%u,%i,%0.2f)\n", imageAttr, type, enableFlag, gamma);
175 if (!imageAttr || (enableFlag && gamma <= 0.0) || type >= ColorAdjustTypeCount)
176 return InvalidParameter;
178 imageAttr->gamma_enabled[type] = enableFlag;
179 imageAttr->gamma[type] = gamma;
181 return Ok;
184 GpStatus WINGDIPAPI GdipSetImageAttributesNoOp(GpImageAttributes *imageAttr,
185 ColorAdjustType type, BOOL enableFlag)
187 static int calls;
189 TRACE("(%p,%u,%i)\n", imageAttr, type, enableFlag);
191 if(!(calls++))
192 FIXME("not implemented\n");
194 return NotImplemented;
197 GpStatus WINGDIPAPI GdipSetImageAttributesOutputChannel(GpImageAttributes *imageAttr,
198 ColorAdjustType type, BOOL enableFlag, ColorChannelFlags channelFlags)
200 static int calls;
202 TRACE("(%p,%u,%i,%x)\n", imageAttr, type, enableFlag, channelFlags);
204 if(!(calls++))
205 FIXME("not implemented\n");
207 return NotImplemented;
210 GpStatus WINGDIPAPI GdipSetImageAttributesOutputChannelColorProfile(GpImageAttributes *imageAttr,
211 ColorAdjustType type, BOOL enableFlag,
212 GDIPCONST WCHAR *colorProfileFilename)
214 static int calls;
216 TRACE("(%p,%u,%i,%s)\n", imageAttr, type, enableFlag, debugstr_w(colorProfileFilename));
218 if(!(calls++))
219 FIXME("not implemented\n");
221 return NotImplemented;
224 GpStatus WINGDIPAPI GdipSetImageAttributesRemapTable(GpImageAttributes *imageAttr,
225 ColorAdjustType type, BOOL enableFlag, UINT mapSize,
226 GDIPCONST ColorMap *map)
228 ColorMap *new_map;
230 TRACE("(%p,%u,%i,%u,%p)\n", imageAttr, type, enableFlag, mapSize, map);
232 if(!imageAttr || type >= ColorAdjustTypeCount)
233 return InvalidParameter;
235 if (enableFlag)
237 if(!map || !mapSize)
238 return InvalidParameter;
240 new_map = heap_alloc_zero(sizeof(*map) * mapSize);
242 if (!new_map)
243 return OutOfMemory;
245 memcpy(new_map, map, sizeof(*map) * mapSize);
247 heap_free(imageAttr->colorremaptables[type].colormap);
249 imageAttr->colorremaptables[type].mapsize = mapSize;
250 imageAttr->colorremaptables[type].colormap = new_map;
252 else
254 heap_free(imageAttr->colorremaptables[type].colormap);
255 imageAttr->colorremaptables[type].colormap = NULL;
258 imageAttr->colorremaptables[type].enabled = enableFlag;
260 return Ok;
263 GpStatus WINGDIPAPI GdipSetImageAttributesThreshold(GpImageAttributes *imageAttr,
264 ColorAdjustType type, BOOL enableFlag, REAL threshold)
266 static int calls;
268 TRACE("(%p,%u,%i,%0.2f)\n", imageAttr, type, enableFlag, threshold);
270 if(!(calls++))
271 FIXME("not implemented\n");
273 return NotImplemented;
276 GpStatus WINGDIPAPI GdipSetImageAttributesToIdentity(GpImageAttributes *imageAttr,
277 ColorAdjustType type)
279 static int calls;
281 TRACE("(%p,%u)\n", imageAttr, type);
283 if(!(calls++))
284 FIXME("not implemented\n");
286 return NotImplemented;
289 GpStatus WINGDIPAPI GdipResetImageAttributes(GpImageAttributes *imageAttr,
290 ColorAdjustType type)
292 TRACE("(%p,%u)\n", imageAttr, type);
294 if(!imageAttr || type >= ColorAdjustTypeCount)
295 return InvalidParameter;
297 memset(&imageAttr->colormatrices[type], 0, sizeof(imageAttr->colormatrices[type]));
298 GdipSetImageAttributesColorKeys(imageAttr, type, FALSE, 0, 0);
299 GdipSetImageAttributesRemapTable(imageAttr, type, FALSE, 0, NULL);
300 GdipSetImageAttributesGamma(imageAttr, type, FALSE, 0.0);
302 return Ok;