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
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
)
34 struct color_remap_table remap_tables
[ColorAdjustTypeCount
] = {{0}};
37 TRACE("(%p, %p)\n", imageattr
, cloneImageattr
);
39 if(!imageattr
|| !cloneImageattr
)
40 return InvalidParameter
;
42 for (i
=0; i
<ColorAdjustTypeCount
; i
++)
44 if (imageattr
->colorremaptables
[i
].enabled
)
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
);
50 if (remap_tables
[i
].colormap
)
52 memcpy(remap_tables
[i
].colormap
, imageattr
->colorremaptables
[i
].colormap
,
53 sizeof(ColorMap
) * remap_tables
[i
].mapsize
);
64 stat
= GdipCreateImageAttributes(cloneImageattr
);
68 **cloneImageattr
= *imageattr
;
70 memcpy((*cloneImageattr
)->colorremaptables
, remap_tables
, sizeof(remap_tables
));
75 for (i
=0; i
<ColorAdjustTypeCount
; i
++)
76 heap_free(remap_tables
[i
].colormap
);
82 GpStatus WINGDIPAPI
GdipCreateImageAttributes(GpImageAttributes
**imageattr
)
85 return InvalidParameter
;
87 *imageattr
= heap_alloc_zero(sizeof(GpImageAttributes
));
88 if(!*imageattr
) return OutOfMemory
;
90 (*imageattr
)->wrap
= WrapModeClamp
;
92 TRACE("<-- %p\n", *imageattr
);
97 GpStatus WINGDIPAPI
GdipDisposeImageAttributes(GpImageAttributes
*imageattr
)
101 TRACE("(%p)\n", imageattr
);
104 return InvalidParameter
;
106 for (i
=0; i
<ColorAdjustTypeCount
; i
++)
107 heap_free(imageattr
->colorremaptables
[i
].colormap
);
109 heap_free(imageattr
);
114 GpStatus WINGDIPAPI
GdipGetImageAttributesAdjustedPalette(GpImageAttributes
*imageattr
,
115 ColorPalette
*palette
, ColorAdjustType type
)
117 TRACE("(%p,%p,%u)\n", imageattr
, palette
, type
);
119 if (!imageattr
|| !palette
|| !palette
->Count
||
120 type
>= ColorAdjustTypeCount
|| type
== ColorAdjustTypeDefault
)
121 return InvalidParameter
;
123 apply_image_attributes(imageattr
, (LPBYTE
)palette
->Entries
, palette
->Count
, 1, 0,
124 type
, PixelFormat32bppARGB
);
129 GpStatus WINGDIPAPI
GdipSetImageAttributesColorKeys(GpImageAttributes
*imageattr
,
130 ColorAdjustType type
, BOOL enableFlag
, ARGB colorLow
, ARGB colorHigh
)
132 TRACE("(%p,%u,%i,%08x,%08x)\n", imageattr
, type
, enableFlag
, colorLow
, colorHigh
);
134 if(!imageattr
|| type
>= ColorAdjustTypeCount
)
135 return InvalidParameter
;
137 imageattr
->colorkeys
[type
].enabled
= enableFlag
;
138 imageattr
->colorkeys
[type
].low
= colorLow
;
139 imageattr
->colorkeys
[type
].high
= colorHigh
;
144 GpStatus WINGDIPAPI
GdipSetImageAttributesColorMatrix(GpImageAttributes
*imageattr
,
145 ColorAdjustType type
, BOOL enableFlag
, GDIPCONST ColorMatrix
* colorMatrix
,
146 GDIPCONST ColorMatrix
* grayMatrix
, ColorMatrixFlags flags
)
148 TRACE("(%p,%u,%i,%p,%p,%u)\n", imageattr
, type
, enableFlag
, colorMatrix
,
151 if(!imageattr
|| type
>= ColorAdjustTypeCount
|| flags
> ColorMatrixFlagsAltGray
)
152 return InvalidParameter
;
157 return InvalidParameter
;
159 if (flags
== ColorMatrixFlagsAltGray
)
162 return InvalidParameter
;
164 imageattr
->colormatrices
[type
].graymatrix
= *grayMatrix
;
167 imageattr
->colormatrices
[type
].colormatrix
= *colorMatrix
;
168 imageattr
->colormatrices
[type
].flags
= flags
;
171 imageattr
->colormatrices
[type
].enabled
= enableFlag
;
176 GpStatus WINGDIPAPI
GdipSetImageAttributesWrapMode(GpImageAttributes
*imageAttr
,
177 WrapMode wrap
, ARGB argb
, BOOL clamp
)
179 TRACE("(%p,%u,%08x,%i)\n", imageAttr
, wrap
, argb
, clamp
);
181 if(!imageAttr
|| wrap
> WrapModeClamp
)
182 return InvalidParameter
;
184 imageAttr
->wrap
= wrap
;
185 imageAttr
->outside_color
= argb
;
186 imageAttr
->clamp
= clamp
;
191 GpStatus WINGDIPAPI
GdipSetImageAttributesCachedBackground(GpImageAttributes
*imageAttr
,
196 TRACE("(%p,%i)\n", imageAttr
, enableFlag
);
199 FIXME("not implemented\n");
201 return NotImplemented
;
204 GpStatus WINGDIPAPI
GdipSetImageAttributesGamma(GpImageAttributes
*imageAttr
,
205 ColorAdjustType type
, BOOL enableFlag
, REAL gamma
)
207 TRACE("(%p,%u,%i,%0.2f)\n", imageAttr
, type
, enableFlag
, gamma
);
209 if (!imageAttr
|| (enableFlag
&& gamma
<= 0.0) || type
>= ColorAdjustTypeCount
)
210 return InvalidParameter
;
212 imageAttr
->gamma_enabled
[type
] = enableFlag
;
213 imageAttr
->gamma
[type
] = gamma
;
218 GpStatus WINGDIPAPI
GdipSetImageAttributesNoOp(GpImageAttributes
*imageAttr
,
219 ColorAdjustType type
, BOOL enableFlag
)
221 TRACE("(%p,%u,%i)\n", imageAttr
, type
, enableFlag
);
223 if (type
>= ColorAdjustTypeCount
)
224 return InvalidParameter
;
226 imageAttr
->noop
[type
] = enableFlag
? IMAGEATTR_NOOP_SET
: IMAGEATTR_NOOP_CLEAR
;
231 GpStatus WINGDIPAPI
GdipSetImageAttributesOutputChannel(GpImageAttributes
*imageAttr
,
232 ColorAdjustType type
, BOOL enableFlag
, ColorChannelFlags channelFlags
)
236 TRACE("(%p,%u,%i,%x)\n", imageAttr
, type
, enableFlag
, channelFlags
);
239 FIXME("not implemented\n");
241 return NotImplemented
;
244 GpStatus WINGDIPAPI
GdipSetImageAttributesOutputChannelColorProfile(GpImageAttributes
*imageAttr
,
245 ColorAdjustType type
, BOOL enableFlag
,
246 GDIPCONST WCHAR
*colorProfileFilename
)
250 TRACE("(%p,%u,%i,%s)\n", imageAttr
, type
, enableFlag
, debugstr_w(colorProfileFilename
));
253 FIXME("not implemented\n");
255 return NotImplemented
;
258 GpStatus WINGDIPAPI
GdipSetImageAttributesRemapTable(GpImageAttributes
*imageAttr
,
259 ColorAdjustType type
, BOOL enableFlag
, UINT mapSize
,
260 GDIPCONST ColorMap
*map
)
264 TRACE("(%p,%u,%i,%u,%p)\n", imageAttr
, type
, enableFlag
, mapSize
, map
);
266 if(!imageAttr
|| type
>= ColorAdjustTypeCount
)
267 return InvalidParameter
;
272 return InvalidParameter
;
274 new_map
= heap_alloc_zero(sizeof(*map
) * mapSize
);
279 memcpy(new_map
, map
, sizeof(*map
) * mapSize
);
281 heap_free(imageAttr
->colorremaptables
[type
].colormap
);
283 imageAttr
->colorremaptables
[type
].mapsize
= mapSize
;
284 imageAttr
->colorremaptables
[type
].colormap
= new_map
;
288 heap_free(imageAttr
->colorremaptables
[type
].colormap
);
289 imageAttr
->colorremaptables
[type
].colormap
= NULL
;
292 imageAttr
->colorremaptables
[type
].enabled
= enableFlag
;
297 GpStatus WINGDIPAPI
GdipSetImageAttributesThreshold(GpImageAttributes
*imageAttr
,
298 ColorAdjustType type
, BOOL enableFlag
, REAL threshold
)
302 TRACE("(%p,%u,%i,%0.2f)\n", imageAttr
, type
, enableFlag
, threshold
);
305 FIXME("not implemented\n");
307 return NotImplemented
;
310 GpStatus WINGDIPAPI
GdipSetImageAttributesToIdentity(GpImageAttributes
*imageAttr
,
311 ColorAdjustType type
)
315 TRACE("(%p,%u)\n", imageAttr
, type
);
318 FIXME("not implemented\n");
320 return NotImplemented
;
323 GpStatus WINGDIPAPI
GdipResetImageAttributes(GpImageAttributes
*imageAttr
,
324 ColorAdjustType type
)
326 TRACE("(%p,%u)\n", imageAttr
, type
);
328 if(!imageAttr
|| type
>= ColorAdjustTypeCount
)
329 return InvalidParameter
;
331 memset(&imageAttr
->colormatrices
[type
], 0, sizeof(imageAttr
->colormatrices
[type
]));
332 GdipSetImageAttributesColorKeys(imageAttr
, type
, FALSE
, 0, 0);
333 GdipSetImageAttributesRemapTable(imageAttr
, type
, FALSE
, 0, NULL
);
334 GdipSetImageAttributesGamma(imageAttr
, type
, FALSE
, 0.0);
335 imageAttr
->noop
[type
] = IMAGEATTR_NOOP_UNDEFINED
;