ReactOS 0.4.16-dev-109-gf4cb10f
imageattributes.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2007 Google (Evan Stade)
3 *
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.
8 *
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.
13 *
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
17 */
18
19#include "windef.h"
20#include "wingdi.h"
21
22#include "objbase.h"
23
24#include "gdiplus.h"
25#include "gdiplus_private.h"
26#include "wine/debug.h"
27
29
31 GpImageAttributes **cloneImageattr)
32{
34 struct color_remap_table remap_tables[ColorAdjustTypeCount] = {{0}};
35 int i;
36
37 TRACE("(%p, %p)\n", imageattr, cloneImageattr);
38
39 if(!imageattr || !cloneImageattr)
40 return InvalidParameter;
41
42 for (i=0; i<ColorAdjustTypeCount; i++)
43 {
44 if (imageattr->colorremaptables[i].enabled)
45 {
46 remap_tables[i].enabled = TRUE;
47 remap_tables[i].mapsize = imageattr->colorremaptables[i].mapsize;
48 remap_tables[i].colormap = heap_alloc(sizeof(ColorMap) * remap_tables[i].mapsize);
49
50 if (remap_tables[i].colormap)
51 {
52 memcpy(remap_tables[i].colormap, imageattr->colorremaptables[i].colormap,
53 sizeof(ColorMap) * remap_tables[i].mapsize);
54 }
55 else
56 {
58 break;
59 }
60 }
61 }
62
63 if (stat == Ok)
64 stat = GdipCreateImageAttributes(cloneImageattr);
65
66 if (stat == Ok)
67 {
68 **cloneImageattr = *imageattr;
69
70 memcpy((*cloneImageattr)->colorremaptables, remap_tables, sizeof(remap_tables));
71 }
72
73 if (stat != Ok)
74 {
75 for (i=0; i<ColorAdjustTypeCount; i++)
76 heap_free(remap_tables[i].colormap);
77 }
78
79 return stat;
80}
81
83{
84 if(!imageattr)
85 return InvalidParameter;
86
87 *imageattr = heap_alloc_zero(sizeof(GpImageAttributes));
88 if(!*imageattr) return OutOfMemory;
89
90 (*imageattr)->wrap = WrapModeClamp;
91
92 TRACE("<-- %p\n", *imageattr);
93
94 return Ok;
95}
96
98{
99 int i;
100
101 TRACE("(%p)\n", imageattr);
102
103 if(!imageattr)
104 return InvalidParameter;
105
106 for (i=0; i<ColorAdjustTypeCount; i++)
107 heap_free(imageattr->colorremaptables[i].colormap);
108
109 heap_free(imageattr);
110
111 return Ok;
112}
113
116{
117 TRACE("(%p,%p,%u)\n", imageattr, palette, type);
118
119 if (!imageattr || !palette || !palette->Count ||
121 return InvalidParameter;
122
123 apply_image_attributes(imageattr, (LPBYTE)palette->Entries, palette->Count, 1, 0,
125
126 return Ok;
127}
128
130 ColorAdjustType type, BOOL enableFlag, ARGB colorLow, ARGB colorHigh)
131{
132 TRACE("(%p,%u,%i,%08x,%08x)\n", imageattr, type, enableFlag, colorLow, colorHigh);
133
134 if(!imageattr || type >= ColorAdjustTypeCount)
135 return InvalidParameter;
136
137 imageattr->colorkeys[type].enabled = enableFlag;
138 imageattr->colorkeys[type].low = colorLow;
139 imageattr->colorkeys[type].high = colorHigh;
140
141 return Ok;
142}
143
145 ColorAdjustType type, BOOL enableFlag, GDIPCONST ColorMatrix* colorMatrix,
147{
148 TRACE("(%p,%u,%i,%p,%p,%u)\n", imageattr, type, enableFlag, colorMatrix,
149 grayMatrix, flags);
150
152 return InvalidParameter;
153
154 if (enableFlag)
155 {
156 if (!colorMatrix)
157 return InvalidParameter;
158
160 {
161 if (!grayMatrix)
162 return InvalidParameter;
163
164 imageattr->colormatrices[type].graymatrix = *grayMatrix;
165 }
166
167 imageattr->colormatrices[type].colormatrix = *colorMatrix;
168 imageattr->colormatrices[type].flags = flags;
169 }
170
171 imageattr->colormatrices[type].enabled = enableFlag;
172
173 return Ok;
174}
175
177 WrapMode wrap, ARGB argb, BOOL clamp)
178{
179 TRACE("(%p,%u,%08x,%i)\n", imageAttr, wrap, argb, clamp);
180
181 if(!imageAttr || wrap > WrapModeClamp)
182 return InvalidParameter;
183
184 imageAttr->wrap = wrap;
185 imageAttr->outside_color = argb;
186 imageAttr->clamp = clamp;
187
188 return Ok;
189}
190
192 BOOL enableFlag)
193{
194 static int calls;
195
196 TRACE("(%p,%i)\n", imageAttr, enableFlag);
197
198 if(!(calls++))
199 FIXME("not implemented\n");
200
201 return NotImplemented;
202}
203
205 ColorAdjustType type, BOOL enableFlag, REAL gamma)
206{
207 TRACE("(%p,%u,%i,%0.2f)\n", imageAttr, type, enableFlag, gamma);
208
209 if (!imageAttr || (enableFlag && gamma <= 0.0) || type >= ColorAdjustTypeCount)
210 return InvalidParameter;
211
212 imageAttr->gamma_enabled[type] = enableFlag;
213 imageAttr->gamma[type] = gamma;
214
215 return Ok;
216}
217
219 ColorAdjustType type, BOOL enableFlag)
220{
221 TRACE("(%p,%u,%i)\n", imageAttr, type, enableFlag);
222
224 return InvalidParameter;
225
226 imageAttr->noop[type] = enableFlag ? IMAGEATTR_NOOP_SET : IMAGEATTR_NOOP_CLEAR;
227
228 return Ok;
229}
230
232 ColorAdjustType type, BOOL enableFlag, ColorChannelFlags channelFlags)
233{
234 static int calls;
235
236 TRACE("(%p,%u,%i,%x)\n", imageAttr, type, enableFlag, channelFlags);
237
238 if(!(calls++))
239 FIXME("not implemented\n");
240
241 return NotImplemented;
242}
243
245 ColorAdjustType type, BOOL enableFlag,
246 GDIPCONST WCHAR *colorProfileFilename)
247{
248 static int calls;
249
250 TRACE("(%p,%u,%i,%s)\n", imageAttr, type, enableFlag, debugstr_w(colorProfileFilename));
251
252 if(!(calls++))
253 FIXME("not implemented\n");
254
255 return NotImplemented;
256}
257
259 ColorAdjustType type, BOOL enableFlag, UINT mapSize,
261{
262 ColorMap *new_map;
263
264 TRACE("(%p,%u,%i,%u,%p)\n", imageAttr, type, enableFlag, mapSize, map);
265
266 if(!imageAttr || type >= ColorAdjustTypeCount)
267 return InvalidParameter;
268
269 if (enableFlag)
270 {
271 if(!map || !mapSize)
272 return InvalidParameter;
273
274 new_map = heap_alloc_zero(sizeof(*map) * mapSize);
275
276 if (!new_map)
277 return OutOfMemory;
278
279 memcpy(new_map, map, sizeof(*map) * mapSize);
280
281 heap_free(imageAttr->colorremaptables[type].colormap);
282
283 imageAttr->colorremaptables[type].mapsize = mapSize;
284 imageAttr->colorremaptables[type].colormap = new_map;
285 }
286 else
287 {
288 heap_free(imageAttr->colorremaptables[type].colormap);
289 imageAttr->colorremaptables[type].colormap = NULL;
290 }
291
292 imageAttr->colorremaptables[type].enabled = enableFlag;
293
294 return Ok;
295}
296
298 ColorAdjustType type, BOOL enableFlag, REAL threshold)
299{
300 static int calls;
301
302 TRACE("(%p,%u,%i,%0.2f)\n", imageAttr, type, enableFlag, threshold);
303
304 if(!(calls++))
305 FIXME("not implemented\n");
306
307 return NotImplemented;
308}
309
312{
313 static int calls;
314
315 TRACE("(%p,%u)\n", imageAttr, type);
316
317 if(!(calls++))
318 FIXME("not implemented\n");
319
320 return NotImplemented;
321}
322
325{
326 TRACE("(%p,%u)\n", imageAttr, type);
327
328 if(!imageAttr || type >= ColorAdjustTypeCount)
329 return InvalidParameter;
330
331 memset(&imageAttr->colormatrices[type], 0, sizeof(imageAttr->colormatrices[type]));
332 GdipSetImageAttributesColorKeys(imageAttr, type, FALSE, 0, 0);
334 GdipSetImageAttributesGamma(imageAttr, type, FALSE, 0.0);
335 imageAttr->noop[type] = IMAGEATTR_NOOP_UNDEFINED;
336
337 return Ok;
338}
#define stat
Definition: acwin.h:99
static void * heap_alloc(size_t len)
Definition: appwiz.h:66
static BOOL heap_free(void *mem)
Definition: appwiz.h:76
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
Definition: _map.h:48
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
float REAL
Definition: types.h:41
#define wrap(journal, var)
Definition: recovery.c:207
unsigned int BOOL
Definition: ntddk_ex.h:94
@ IMAGEATTR_NOOP_UNDEFINED
@ IMAGEATTR_NOOP_CLEAR
@ IMAGEATTR_NOOP_SET
PixelFormat apply_image_attributes(const GpImageAttributes *attributes, LPBYTE data, UINT width, UINT height, INT stride, ColorAdjustType type, PixelFormat fmt) DECLSPEC_HIDDEN
Definition: graphics.c:710
ColorChannelFlags
Definition: gdipluscolor.h:25
ColorAdjustType
@ ColorAdjustTypeCount
@ ColorAdjustTypeDefault
ColorMatrixFlags
@ ColorMatrixFlagsAltGray
WrapMode
Definition: gdiplusenums.h:206
@ WrapModeClamp
Definition: gdiplusenums.h:211
#define GDIPCONST
Definition: gdiplusflat.h:24
#define WINGDIPAPI
Definition: gdiplusflat.h:22
DWORD ARGB
#define PixelFormat32bppARGB
Status
Definition: gdiplustypes.h:25
@ Ok
Definition: gdiplustypes.h:26
@ InvalidParameter
Definition: gdiplustypes.h:28
@ OutOfMemory
Definition: gdiplustypes.h:29
@ NotImplemented
Definition: gdiplustypes.h:32
GLuint GLuint GLsizei GLenum type
Definition: gl.h:1545
GLenum clamp
Definition: glext.h:6216
GLbitfield flags
Definition: glext.h:7161
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint GLint GLint GLenum GLenum GLenum GLint GLuint GLenum GLenum GLfloat GLenum GLfloat GLenum GLint mapsize
Definition: glfuncs.h:262
GpStatus WINGDIPAPI GdipGetImageAttributesAdjustedPalette(GpImageAttributes *imageattr, ColorPalette *palette, ColorAdjustType type)
GpStatus WINGDIPAPI GdipSetImageAttributesToIdentity(GpImageAttributes *imageAttr, ColorAdjustType type)
GpStatus WINGDIPAPI GdipSetImageAttributesColorMatrix(GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag, GDIPCONST ColorMatrix *colorMatrix, GDIPCONST ColorMatrix *grayMatrix, ColorMatrixFlags flags)
GpStatus WINGDIPAPI GdipSetImageAttributesCachedBackground(GpImageAttributes *imageAttr, BOOL enableFlag)
GpStatus WINGDIPAPI GdipCloneImageAttributes(GDIPCONST GpImageAttributes *imageattr, GpImageAttributes **cloneImageattr)
GpStatus WINGDIPAPI GdipSetImageAttributesOutputChannelColorProfile(GpImageAttributes *imageAttr, ColorAdjustType type, BOOL enableFlag, GDIPCONST WCHAR *colorProfileFilename)
GpStatus WINGDIPAPI GdipSetImageAttributesGamma(GpImageAttributes *imageAttr, ColorAdjustType type, BOOL enableFlag, REAL gamma)
GpStatus WINGDIPAPI GdipCreateImageAttributes(GpImageAttributes **imageattr)
GpStatus WINGDIPAPI GdipSetImageAttributesColorKeys(GpImageAttributes *imageattr, ColorAdjustType type, BOOL enableFlag, ARGB colorLow, ARGB colorHigh)
GpStatus WINGDIPAPI GdipSetImageAttributesThreshold(GpImageAttributes *imageAttr, ColorAdjustType type, BOOL enableFlag, REAL threshold)
GpStatus WINGDIPAPI GdipDisposeImageAttributes(GpImageAttributes *imageattr)
GpStatus WINGDIPAPI GdipSetImageAttributesRemapTable(GpImageAttributes *imageAttr, ColorAdjustType type, BOOL enableFlag, UINT mapSize, GDIPCONST ColorMap *map)
GpStatus WINGDIPAPI GdipSetImageAttributesOutputChannel(GpImageAttributes *imageAttr, ColorAdjustType type, BOOL enableFlag, ColorChannelFlags channelFlags)
GpStatus WINGDIPAPI GdipSetImageAttributesWrapMode(GpImageAttributes *imageAttr, WrapMode wrap, ARGB argb, BOOL clamp)
GpStatus WINGDIPAPI GdipSetImageAttributesNoOp(GpImageAttributes *imageAttr, ColorAdjustType type, BOOL enableFlag)
GpStatus WINGDIPAPI GdipResetImageAttributes(GpImageAttributes *imageAttr, ColorAdjustType type)
#define debugstr_w
Definition: kernel32.h:32
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static HPALETTE palette
Definition: clipboard.c:1345
unsigned int UINT
Definition: ndis.h:50
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
struct color_key colorkeys[ColorAdjustTypeCount]
REAL gamma[ColorAdjustTypeCount]
struct color_matrix colormatrices[ColorAdjustTypeCount]
enum imageattr_noop noop[ColorAdjustTypeCount]
BOOL gamma_enabled[ColorAdjustTypeCount]
struct color_remap_table colorremaptables[ColorAdjustTypeCount]
Definition: stat.h:55
unsigned char * LPBYTE
Definition: typedefs.h:53
__wchar_t WCHAR
Definition: xmlstorage.h:180