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
)
35 TRACE("(%p, %p)\n", imageattr
, cloneImageattr
);
37 if(!imageattr
|| !cloneImageattr
)
38 return InvalidParameter
;
40 stat
= GdipCreateImageAttributes(cloneImageattr
);
43 **cloneImageattr
= *imageattr
;
48 GpStatus WINGDIPAPI
GdipCreateImageAttributes(GpImageAttributes
**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
);
63 GpStatus WINGDIPAPI
GdipDisposeImageAttributes(GpImageAttributes
*imageattr
)
67 TRACE("(%p)\n", imageattr
);
70 return InvalidParameter
;
72 for (i
=0; i
<ColorAdjustTypeCount
; i
++)
73 heap_free(imageattr
->colorremaptables
[i
].colormap
);
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
);
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
;
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
,
117 if(!imageattr
|| type
>= ColorAdjustTypeCount
|| flags
> ColorMatrixFlagsAltGray
)
118 return InvalidParameter
;
123 return InvalidParameter
;
125 if (flags
== ColorMatrixFlagsAltGray
)
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
;
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
;
157 GpStatus WINGDIPAPI
GdipSetImageAttributesCachedBackground(GpImageAttributes
*imageAttr
,
162 TRACE("(%p,%i)\n", imageAttr
, enableFlag
);
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
;
184 GpStatus WINGDIPAPI
GdipSetImageAttributesNoOp(GpImageAttributes
*imageAttr
,
185 ColorAdjustType type
, BOOL enableFlag
)
189 TRACE("(%p,%u,%i)\n", imageAttr
, type
, enableFlag
);
192 FIXME("not implemented\n");
194 return NotImplemented
;
197 GpStatus WINGDIPAPI
GdipSetImageAttributesOutputChannel(GpImageAttributes
*imageAttr
,
198 ColorAdjustType type
, BOOL enableFlag
, ColorChannelFlags channelFlags
)
202 TRACE("(%p,%u,%i,%x)\n", imageAttr
, type
, enableFlag
, channelFlags
);
205 FIXME("not implemented\n");
207 return NotImplemented
;
210 GpStatus WINGDIPAPI
GdipSetImageAttributesOutputChannelColorProfile(GpImageAttributes
*imageAttr
,
211 ColorAdjustType type
, BOOL enableFlag
,
212 GDIPCONST WCHAR
*colorProfileFilename
)
216 TRACE("(%p,%u,%i,%s)\n", imageAttr
, type
, enableFlag
, debugstr_w(colorProfileFilename
));
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
)
230 TRACE("(%p,%u,%i,%u,%p)\n", imageAttr
, type
, enableFlag
, mapSize
, map
);
232 if(!imageAttr
|| type
>= ColorAdjustTypeCount
)
233 return InvalidParameter
;
238 return InvalidParameter
;
240 new_map
= heap_alloc_zero(sizeof(*map
) * mapSize
);
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
;
254 heap_free(imageAttr
->colorremaptables
[type
].colormap
);
255 imageAttr
->colorremaptables
[type
].colormap
= NULL
;
258 imageAttr
->colorremaptables
[type
].enabled
= enableFlag
;
263 GpStatus WINGDIPAPI
GdipSetImageAttributesThreshold(GpImageAttributes
*imageAttr
,
264 ColorAdjustType type
, BOOL enableFlag
, REAL threshold
)
268 TRACE("(%p,%u,%i,%0.2f)\n", imageAttr
, type
, enableFlag
, threshold
);
271 FIXME("not implemented\n");
273 return NotImplemented
;
276 GpStatus WINGDIPAPI
GdipSetImageAttributesToIdentity(GpImageAttributes
*imageAttr
,
277 ColorAdjustType type
)
281 TRACE("(%p,%u)\n", imageAttr
, type
);
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);