gdiplus: Copy remap tables when cloning an ImageAttributes.

Signed-off-by: Vincent Povirk <vincent@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Vincent Povirk 2016-08-26 15:14:10 -05:00 committed by Alexandre Julliard
parent 25dbca10dc
commit d26c0ca214

View File

@ -30,18 +30,52 @@ WINE_DEFAULT_DEBUG_CHANNEL(gdiplus);
GpStatus WINGDIPAPI GdipCloneImageAttributes(GDIPCONST GpImageAttributes *imageattr,
GpImageAttributes **cloneImageattr)
{
GpStatus stat;
GpStatus stat = Ok;
struct color_remap_table remap_tables[ColorAdjustTypeCount] = {{0}};
int i;
TRACE("(%p, %p)\n", imageattr, cloneImageattr);
if(!imageattr || !cloneImageattr)
return InvalidParameter;
stat = GdipCreateImageAttributes(cloneImageattr);
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);
if (stat == Ok)
{
**cloneImageattr = *imageattr;
memcpy((*cloneImageattr)->colorremaptables, remap_tables, sizeof(remap_tables));
}
if (stat != Ok)
{
for (i=0; i<ColorAdjustTypeCount; i++)
heap_free(remap_tables[i].colormap);
}
return stat;
}