2007-07-31 04:09:41 +02:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007 Google (Evan Stade)
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "windef.h"
|
2007-08-01 04:15:29 +02:00
|
|
|
#include "wingdi.h"
|
2007-07-31 04:09:41 +02:00
|
|
|
|
2007-08-01 04:15:48 +02:00
|
|
|
#include "objbase.h"
|
|
|
|
|
2007-07-31 04:09:41 +02:00
|
|
|
#include "gdiplus.h"
|
|
|
|
#include "gdiplus_private.h"
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
|
|
|
|
|
2008-06-27 01:26:33 +02:00
|
|
|
GpStatus WINGDIPAPI GdipCloneImageAttributes(GDIPCONST GpImageAttributes *imageattr,
|
|
|
|
GpImageAttributes **cloneImageattr)
|
|
|
|
{
|
2016-08-26 22:14:10 +02:00
|
|
|
GpStatus stat = Ok;
|
|
|
|
struct color_remap_table remap_tables[ColorAdjustTypeCount] = {{0}};
|
|
|
|
int i;
|
2009-12-18 22:18:49 +01:00
|
|
|
|
2008-09-02 22:38:01 +02:00
|
|
|
TRACE("(%p, %p)\n", imageattr, cloneImageattr);
|
|
|
|
|
2008-06-27 01:26:33 +02:00
|
|
|
if(!imageattr || !cloneImageattr)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2016-08-26 22:14:10 +02:00
|
|
|
for (i=0; i<ColorAdjustTypeCount; i++)
|
|
|
|
{
|
|
|
|
if (imageattr->colorremaptables[i].enabled)
|
|
|
|
{
|
|
|
|
remap_tables[i].enabled = TRUE;
|
|
|
|
remap_tables[i].mapsize = imageattr->colorremaptables[i].mapsize;
|
|
|
|
remap_tables[i].colormap = heap_alloc(sizeof(ColorMap) * remap_tables[i].mapsize);
|
|
|
|
|
|
|
|
if (remap_tables[i].colormap)
|
|
|
|
{
|
|
|
|
memcpy(remap_tables[i].colormap, imageattr->colorremaptables[i].colormap,
|
|
|
|
sizeof(ColorMap) * remap_tables[i].mapsize);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
stat = OutOfMemory;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stat == Ok)
|
|
|
|
stat = GdipCreateImageAttributes(cloneImageattr);
|
2008-06-27 01:26:33 +02:00
|
|
|
|
2009-12-18 22:18:49 +01:00
|
|
|
if (stat == Ok)
|
2016-08-26 22:14:10 +02:00
|
|
|
{
|
2009-12-18 22:18:49 +01:00
|
|
|
**cloneImageattr = *imageattr;
|
|
|
|
|
2016-08-26 22:14:10 +02:00
|
|
|
memcpy((*cloneImageattr)->colorremaptables, remap_tables, sizeof(remap_tables));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (stat != Ok)
|
|
|
|
{
|
|
|
|
for (i=0; i<ColorAdjustTypeCount; i++)
|
|
|
|
heap_free(remap_tables[i].colormap);
|
|
|
|
}
|
|
|
|
|
2009-12-18 22:18:49 +01:00
|
|
|
return stat;
|
2008-06-27 01:26:33 +02:00
|
|
|
}
|
|
|
|
|
2007-07-31 04:09:41 +02:00
|
|
|
GpStatus WINGDIPAPI GdipCreateImageAttributes(GpImageAttributes **imageattr)
|
|
|
|
{
|
|
|
|
if(!imageattr)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2015-10-05 00:22:34 +02:00
|
|
|
*imageattr = heap_alloc_zero(sizeof(GpImageAttributes));
|
2007-07-31 04:09:54 +02:00
|
|
|
if(!*imageattr) return OutOfMemory;
|
2007-07-31 04:09:41 +02:00
|
|
|
|
2010-05-08 19:53:07 +02:00
|
|
|
(*imageattr)->wrap = WrapModeClamp;
|
|
|
|
|
2009-12-18 22:21:30 +01:00
|
|
|
TRACE("<-- %p\n", *imageattr);
|
|
|
|
|
2007-07-31 04:09:54 +02:00
|
|
|
return Ok;
|
2007-07-31 04:09:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipDisposeImageAttributes(GpImageAttributes *imageattr)
|
|
|
|
{
|
2012-03-21 21:29:25 +01:00
|
|
|
int i;
|
|
|
|
|
2008-09-02 22:38:01 +02:00
|
|
|
TRACE("(%p)\n", imageattr);
|
|
|
|
|
2007-07-31 04:09:41 +02:00
|
|
|
if(!imageattr)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2012-03-21 21:29:25 +01:00
|
|
|
for (i=0; i<ColorAdjustTypeCount; i++)
|
2015-10-05 00:22:34 +02:00
|
|
|
heap_free(imageattr->colorremaptables[i].colormap);
|
2012-03-21 21:29:25 +01:00
|
|
|
|
2015-10-05 00:22:34 +02:00
|
|
|
heap_free(imageattr);
|
2007-07-31 04:09:41 +02:00
|
|
|
|
2007-08-01 04:14:52 +02:00
|
|
|
return Ok;
|
2007-07-31 04:09:41 +02:00
|
|
|
}
|
|
|
|
|
2016-06-13 23:42:28 +02:00
|
|
|
GpStatus WINGDIPAPI GdipGetImageAttributesAdjustedPalette(GpImageAttributes *imageattr,
|
|
|
|
ColorPalette *palette, ColorAdjustType type)
|
|
|
|
{
|
|
|
|
TRACE("(%p,%p,%u)\n", imageattr, palette, type);
|
|
|
|
|
|
|
|
if (!imageattr || !palette || !palette->Count ||
|
|
|
|
type >= ColorAdjustTypeCount || type == ColorAdjustTypeDefault)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
apply_image_attributes(imageattr, (LPBYTE)palette->Entries, palette->Count, 1, 0,
|
|
|
|
type, PixelFormat32bppARGB);
|
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|
|
|
|
|
2007-08-01 04:16:16 +02:00
|
|
|
GpStatus WINGDIPAPI GdipSetImageAttributesColorKeys(GpImageAttributes *imageattr,
|
|
|
|
ColorAdjustType type, BOOL enableFlag, ARGB colorLow, ARGB colorHigh)
|
|
|
|
{
|
2022-02-10 08:43:13 +01:00
|
|
|
TRACE("(%p,%u,%i,%08lx,%08lx)\n", imageattr, type, enableFlag, colorLow, colorHigh);
|
2007-08-01 04:16:16 +02:00
|
|
|
|
2009-07-25 00:57:38 +02:00
|
|
|
if(!imageattr || type >= ColorAdjustTypeCount)
|
2007-08-01 04:16:16 +02:00
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-07-25 00:57:38 +02:00
|
|
|
imageattr->colorkeys[type].enabled = enableFlag;
|
|
|
|
imageattr->colorkeys[type].low = colorLow;
|
|
|
|
imageattr->colorkeys[type].high = colorHigh;
|
2007-08-01 04:16:16 +02:00
|
|
|
|
2009-07-25 00:57:38 +02:00
|
|
|
return Ok;
|
2007-08-01 04:16:16 +02:00
|
|
|
}
|
|
|
|
|
2007-08-08 03:42:48 +02:00
|
|
|
GpStatus WINGDIPAPI GdipSetImageAttributesColorMatrix(GpImageAttributes *imageattr,
|
|
|
|
ColorAdjustType type, BOOL enableFlag, GDIPCONST ColorMatrix* colorMatrix,
|
|
|
|
GDIPCONST ColorMatrix* grayMatrix, ColorMatrixFlags flags)
|
|
|
|
{
|
2009-12-19 00:42:18 +01:00
|
|
|
TRACE("(%p,%u,%i,%p,%p,%u)\n", imageattr, type, enableFlag, colorMatrix,
|
|
|
|
grayMatrix, flags);
|
2007-08-08 03:42:48 +02:00
|
|
|
|
2009-12-19 00:42:18 +01:00
|
|
|
if(!imageattr || type >= ColorAdjustTypeCount || flags > ColorMatrixFlagsAltGray)
|
2007-08-08 03:42:48 +02:00
|
|
|
return InvalidParameter;
|
|
|
|
|
2009-12-19 00:42:18 +01:00
|
|
|
if (enableFlag)
|
|
|
|
{
|
|
|
|
if (!colorMatrix)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
if (flags == ColorMatrixFlagsAltGray)
|
|
|
|
{
|
|
|
|
if (!grayMatrix)
|
|
|
|
return InvalidParameter;
|
2007-08-08 03:42:48 +02:00
|
|
|
|
2009-12-19 00:42:18 +01:00
|
|
|
imageattr->colormatrices[type].graymatrix = *grayMatrix;
|
|
|
|
}
|
|
|
|
|
|
|
|
imageattr->colormatrices[type].colormatrix = *colorMatrix;
|
|
|
|
imageattr->colormatrices[type].flags = flags;
|
|
|
|
}
|
|
|
|
|
|
|
|
imageattr->colormatrices[type].enabled = enableFlag;
|
|
|
|
|
|
|
|
return Ok;
|
2007-08-08 03:42:48 +02:00
|
|
|
}
|
|
|
|
|
2007-07-31 04:09:41 +02:00
|
|
|
GpStatus WINGDIPAPI GdipSetImageAttributesWrapMode(GpImageAttributes *imageAttr,
|
|
|
|
WrapMode wrap, ARGB argb, BOOL clamp)
|
|
|
|
{
|
2022-02-10 08:43:13 +01:00
|
|
|
TRACE("(%p,%u,%08lx,%i)\n", imageAttr, wrap, argb, clamp);
|
2009-12-18 23:19:34 +01:00
|
|
|
|
2010-05-08 19:53:07 +02:00
|
|
|
if(!imageAttr || wrap > WrapModeClamp)
|
2007-07-31 04:09:41 +02:00
|
|
|
return InvalidParameter;
|
|
|
|
|
2010-05-08 19:53:07 +02:00
|
|
|
imageAttr->wrap = wrap;
|
|
|
|
imageAttr->outside_color = argb;
|
|
|
|
imageAttr->clamp = clamp;
|
2007-07-31 04:09:41 +02:00
|
|
|
|
2010-05-08 19:53:07 +02:00
|
|
|
return Ok;
|
2007-07-31 04:09:41 +02:00
|
|
|
}
|
2008-04-09 22:09:58 +02:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipSetImageAttributesCachedBackground(GpImageAttributes *imageAttr,
|
|
|
|
BOOL enableFlag)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
2009-12-18 23:19:34 +01:00
|
|
|
TRACE("(%p,%i)\n", imageAttr, enableFlag);
|
|
|
|
|
2008-04-09 22:09:58 +02:00
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
2008-04-09 22:14:45 +02:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipSetImageAttributesGamma(GpImageAttributes *imageAttr,
|
|
|
|
ColorAdjustType type, BOOL enableFlag, REAL gamma)
|
|
|
|
{
|
2009-12-18 23:19:34 +01:00
|
|
|
TRACE("(%p,%u,%i,%0.2f)\n", imageAttr, type, enableFlag, gamma);
|
|
|
|
|
2010-01-31 00:09:06 +01:00
|
|
|
if (!imageAttr || (enableFlag && gamma <= 0.0) || type >= ColorAdjustTypeCount)
|
|
|
|
return InvalidParameter;
|
2008-04-09 22:14:45 +02:00
|
|
|
|
2010-01-31 00:09:06 +01:00
|
|
|
imageAttr->gamma_enabled[type] = enableFlag;
|
|
|
|
imageAttr->gamma[type] = gamma;
|
|
|
|
|
|
|
|
return Ok;
|
2008-04-09 22:14:45 +02:00
|
|
|
}
|
2008-04-09 22:16:32 +02:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipSetImageAttributesNoOp(GpImageAttributes *imageAttr,
|
|
|
|
ColorAdjustType type, BOOL enableFlag)
|
|
|
|
{
|
2009-12-18 23:19:34 +01:00
|
|
|
TRACE("(%p,%u,%i)\n", imageAttr, type, enableFlag);
|
|
|
|
|
2017-10-24 12:56:38 +02:00
|
|
|
if (type >= ColorAdjustTypeCount)
|
|
|
|
return InvalidParameter;
|
2008-04-09 22:16:32 +02:00
|
|
|
|
2017-10-24 12:56:38 +02:00
|
|
|
imageAttr->noop[type] = enableFlag ? IMAGEATTR_NOOP_SET : IMAGEATTR_NOOP_CLEAR;
|
|
|
|
|
|
|
|
return Ok;
|
2008-04-09 22:16:32 +02:00
|
|
|
}
|
2008-04-09 22:25:14 +02:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipSetImageAttributesOutputChannel(GpImageAttributes *imageAttr,
|
|
|
|
ColorAdjustType type, BOOL enableFlag, ColorChannelFlags channelFlags)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
2009-12-18 23:19:34 +01:00
|
|
|
TRACE("(%p,%u,%i,%x)\n", imageAttr, type, enableFlag, channelFlags);
|
|
|
|
|
2008-04-09 22:25:14 +02:00
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
2008-04-09 22:26:48 +02:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipSetImageAttributesOutputChannelColorProfile(GpImageAttributes *imageAttr,
|
|
|
|
ColorAdjustType type, BOOL enableFlag,
|
|
|
|
GDIPCONST WCHAR *colorProfileFilename)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
2009-12-18 23:19:34 +01:00
|
|
|
TRACE("(%p,%u,%i,%s)\n", imageAttr, type, enableFlag, debugstr_w(colorProfileFilename));
|
|
|
|
|
2008-04-09 22:26:48 +02:00
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
2008-04-10 21:40:13 +02:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipSetImageAttributesRemapTable(GpImageAttributes *imageAttr,
|
|
|
|
ColorAdjustType type, BOOL enableFlag, UINT mapSize,
|
|
|
|
GDIPCONST ColorMap *map)
|
|
|
|
{
|
2012-03-21 21:29:25 +01:00
|
|
|
ColorMap *new_map;
|
|
|
|
|
2009-12-18 23:19:34 +01:00
|
|
|
TRACE("(%p,%u,%i,%u,%p)\n", imageAttr, type, enableFlag, mapSize, map);
|
|
|
|
|
2010-03-04 02:06:33 +01:00
|
|
|
if(!imageAttr || type >= ColorAdjustTypeCount)
|
|
|
|
return InvalidParameter;
|
2008-04-10 21:40:13 +02:00
|
|
|
|
2010-03-04 02:06:33 +01:00
|
|
|
if (enableFlag)
|
|
|
|
{
|
|
|
|
if(!map || !mapSize)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
2015-10-05 00:22:34 +02:00
|
|
|
new_map = heap_alloc_zero(sizeof(*map) * mapSize);
|
2012-03-21 21:29:25 +01:00
|
|
|
|
|
|
|
if (!new_map)
|
|
|
|
return OutOfMemory;
|
|
|
|
|
|
|
|
memcpy(new_map, map, sizeof(*map) * mapSize);
|
|
|
|
|
2015-10-05 00:22:34 +02:00
|
|
|
heap_free(imageAttr->colorremaptables[type].colormap);
|
2012-03-21 21:29:25 +01:00
|
|
|
|
2010-03-04 02:06:33 +01:00
|
|
|
imageAttr->colorremaptables[type].mapsize = mapSize;
|
2012-03-21 21:29:25 +01:00
|
|
|
imageAttr->colorremaptables[type].colormap = new_map;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2015-10-05 00:22:34 +02:00
|
|
|
heap_free(imageAttr->colorremaptables[type].colormap);
|
2012-03-21 21:29:25 +01:00
|
|
|
imageAttr->colorremaptables[type].colormap = NULL;
|
2010-03-04 02:06:33 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
imageAttr->colorremaptables[type].enabled = enableFlag;
|
|
|
|
|
|
|
|
return Ok;
|
2008-04-10 21:40:13 +02:00
|
|
|
}
|
2008-04-10 21:40:14 +02:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipSetImageAttributesThreshold(GpImageAttributes *imageAttr,
|
|
|
|
ColorAdjustType type, BOOL enableFlag, REAL threshold)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
2009-12-18 23:19:34 +01:00
|
|
|
TRACE("(%p,%u,%i,%0.2f)\n", imageAttr, type, enableFlag, threshold);
|
|
|
|
|
2008-04-10 21:40:14 +02:00
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
2008-04-10 21:40:15 +02:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipSetImageAttributesToIdentity(GpImageAttributes *imageAttr,
|
|
|
|
ColorAdjustType type)
|
|
|
|
{
|
|
|
|
static int calls;
|
|
|
|
|
2009-12-18 23:19:34 +01:00
|
|
|
TRACE("(%p,%u)\n", imageAttr, type);
|
|
|
|
|
2008-04-10 21:40:15 +02:00
|
|
|
if(!(calls++))
|
|
|
|
FIXME("not implemented\n");
|
|
|
|
|
|
|
|
return NotImplemented;
|
|
|
|
}
|
2013-05-22 18:12:18 +02:00
|
|
|
|
|
|
|
GpStatus WINGDIPAPI GdipResetImageAttributes(GpImageAttributes *imageAttr,
|
|
|
|
ColorAdjustType type)
|
|
|
|
{
|
|
|
|
TRACE("(%p,%u)\n", imageAttr, type);
|
|
|
|
|
|
|
|
if(!imageAttr || type >= ColorAdjustTypeCount)
|
|
|
|
return InvalidParameter;
|
|
|
|
|
|
|
|
memset(&imageAttr->colormatrices[type], 0, sizeof(imageAttr->colormatrices[type]));
|
2014-04-25 11:50:04 +02:00
|
|
|
GdipSetImageAttributesColorKeys(imageAttr, type, FALSE, 0, 0);
|
|
|
|
GdipSetImageAttributesRemapTable(imageAttr, type, FALSE, 0, NULL);
|
|
|
|
GdipSetImageAttributesGamma(imageAttr, type, FALSE, 0.0);
|
2017-10-24 12:56:38 +02:00
|
|
|
imageAttr->noop[type] = IMAGEATTR_NOOP_UNDEFINED;
|
2013-05-22 18:12:18 +02:00
|
|
|
|
|
|
|
return Ok;
|
|
|
|
}
|