ReactOS 0.4.17-dev-243-g1369312
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 = malloc(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 free(remap_tables[i].colormap);
77 }
78
79 return stat;
80}
81
83{
84 if(!imageattr)
85 return InvalidParameter;
86
87 *imageattr = calloc(1, 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 free(imageattr->colorremaptables[i].colormap);
108
109 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 ||
120#ifdef __REACTOS__
122#else
124#endif
125 return InvalidParameter;
126
127 apply_image_attributes(imageattr, (LPBYTE)palette->Entries, palette->Count, 1, 0,
129
130 return Ok;
131}
132
134 ColorAdjustType type, BOOL enableFlag, ARGB colorLow, ARGB colorHigh)
135{
136 TRACE("(%p,%u,%i,%08lx,%08lx)\n", imageattr, type, enableFlag, colorLow, colorHigh);
137
138 if(!imageattr || type >= ColorAdjustTypeCount)
139 return InvalidParameter;
140
141 imageattr->colorkeys[type].enabled = enableFlag;
142 imageattr->colorkeys[type].low = colorLow;
143 imageattr->colorkeys[type].high = colorHigh;
144
145 return Ok;
146}
147
149 ColorAdjustType type, BOOL enableFlag, GDIPCONST ColorMatrix* colorMatrix,
151{
152 TRACE("(%p,%u,%i,%p,%p,%u)\n", imageattr, type, enableFlag, colorMatrix,
153 grayMatrix, flags);
154
156 return InvalidParameter;
157
158 if (enableFlag)
159 {
160 if (!colorMatrix)
161 return InvalidParameter;
162
164 {
165 if (!grayMatrix)
166 return InvalidParameter;
167
168 imageattr->colormatrices[type].graymatrix = *grayMatrix;
169 }
170
171 imageattr->colormatrices[type].colormatrix = *colorMatrix;
172 imageattr->colormatrices[type].flags = flags;
173 }
174
175 imageattr->colormatrices[type].enabled = enableFlag;
176
177 return Ok;
178}
179
181 WrapMode wrap, ARGB argb, BOOL clamp)
182{
183 TRACE("(%p,%u,%08lx,%i)\n", imageAttr, wrap, argb, clamp);
184
185 if(!imageAttr || wrap > WrapModeClamp)
186 return InvalidParameter;
187
188 imageAttr->wrap = wrap;
189 imageAttr->outside_color = argb;
190 imageAttr->clamp = clamp;
191
192 return Ok;
193}
194
196 BOOL enableFlag)
197{
198 static int calls;
199
200 TRACE("(%p,%i)\n", imageAttr, enableFlag);
201
202 if(!(calls++))
203 FIXME("not implemented\n");
204
205 return NotImplemented;
206}
207
209 ColorAdjustType type, BOOL enableFlag, REAL gamma)
210{
211 TRACE("(%p,%u,%i,%0.2f)\n", imageAttr, type, enableFlag, gamma);
212
213 if (!imageAttr || (enableFlag && gamma <= 0.0) || type >= ColorAdjustTypeCount)
214 return InvalidParameter;
215
216 imageAttr->gamma_enabled[type] = enableFlag;
217 imageAttr->gamma[type] = gamma;
218
219 return Ok;
220}
221
223 ColorAdjustType type, BOOL enableFlag)
224{
225 TRACE("(%p,%u,%i)\n", imageAttr, type, enableFlag);
226
228 return InvalidParameter;
229
230 imageAttr->noop[type] = enableFlag ? IMAGEATTR_NOOP_SET : IMAGEATTR_NOOP_CLEAR;
231
232 return Ok;
233}
234
236 ColorAdjustType type, BOOL enableFlag, ColorChannelFlags channelFlags)
237{
238 static int calls;
239
240 TRACE("(%p,%u,%i,%x)\n", imageAttr, type, enableFlag, channelFlags);
241
242 if(!(calls++))
243 FIXME("not implemented\n");
244
245 return NotImplemented;
246}
247
249 ColorAdjustType type, BOOL enableFlag,
250 GDIPCONST WCHAR *colorProfileFilename)
251{
252 static int calls;
253
254 TRACE("(%p,%u,%i,%s)\n", imageAttr, type, enableFlag, debugstr_w(colorProfileFilename));
255
256 if(!(calls++))
257 FIXME("not implemented\n");
258
259 return NotImplemented;
260}
261
263 ColorAdjustType type, BOOL enableFlag, UINT mapSize,
265{
266 ColorMap *new_map;
267
268 TRACE("(%p,%u,%i,%u,%p)\n", imageAttr, type, enableFlag, mapSize, map);
269
270 if(!imageAttr || type >= ColorAdjustTypeCount)
271 return InvalidParameter;
272
273 if (enableFlag)
274 {
275 if(!map || !mapSize)
276 return InvalidParameter;
277
278 new_map = malloc(sizeof(*map) * mapSize);
279
280 if (!new_map)
281 return OutOfMemory;
282
283 memcpy(new_map, map, sizeof(*map) * mapSize);
284
285 free(imageAttr->colorremaptables[type].colormap);
286
287 imageAttr->colorremaptables[type].mapsize = mapSize;
288 imageAttr->colorremaptables[type].colormap = new_map;
289 }
290 else
291 {
292 free(imageAttr->colorremaptables[type].colormap);
293 imageAttr->colorremaptables[type].colormap = NULL;
294 }
295
296 imageAttr->colorremaptables[type].enabled = enableFlag;
297
298 return Ok;
299}
300
302 ColorAdjustType type, BOOL enableFlag, REAL threshold)
303{
304 static int calls;
305
306 TRACE("(%p,%u,%i,%0.2f)\n", imageAttr, type, enableFlag, threshold);
307
308 if(!(calls++))
309 FIXME("not implemented\n");
310
311 return NotImplemented;
312}
313
316{
317 static int calls;
318
319 TRACE("(%p,%u)\n", imageAttr, type);
320
321 if(!(calls++))
322 FIXME("not implemented\n");
323
324 return NotImplemented;
325}
326
329{
330 TRACE("(%p,%u)\n", imageAttr, type);
331
332 if(!imageAttr || type >= ColorAdjustTypeCount)
333 return InvalidParameter;
334
335 memset(&imageAttr->colormatrices[type], 0, sizeof(imageAttr->colormatrices[type]));
336 GdipSetImageAttributesColorKeys(imageAttr, type, FALSE, 0, 0);
338 GdipSetImageAttributesGamma(imageAttr, type, FALSE, 0.0);
339 imageAttr->noop[type] = IMAGEATTR_NOOP_UNDEFINED;
340
341 return Ok;
342}
#define stat
Definition: acwin.h:100
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
Definition: _map.h:48
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#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)
Definition: graphics.c:796
ColorChannelFlags
Definition: gdipluscolor.h:25
ColorAdjustType
@ ColorAdjustTypeCount
@ ColorAdjustTypeDefault
ColorMatrixFlags
@ ColorMatrixFlagsAltGray
WrapMode
Definition: gdiplusenums.h:204
@ WrapModeClamp
Definition: gdiplusenums.h:209
#define GDIPCONST
Definition: gdiplusflat.h:24
#define WINGDIPAPI
Definition: gdiplusflat.h:22
DWORD ARGB
#define PixelFormat32bppARGB
Status
Definition: gdiplustypes.h:24
@ Ok
Definition: gdiplustypes.h:25
@ InvalidParameter
Definition: gdiplustypes.h:27
@ OutOfMemory
Definition: gdiplustypes.h:28
@ NotImplemented
Definition: gdiplustypes.h:31
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:1457
unsigned int UINT
Definition: ndis.h:50
short WCHAR
Definition: pedump.c:58
#define calloc
Definition: rosglue.h:14
#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:66
unsigned char * LPBYTE
Definition: typedefs.h:53