gdiplus: Store copies of remap tables in ImageAttributes objects.
Vincent Povirk
madewokherd at gmail.com
Wed Mar 21 15:55:18 CDT 2012
-------------- next part --------------
From 7fd1312034c4b0dbb4f4c542a055797cbdaf4d63 Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Wed, 21 Mar 2012 15:29:25 -0500
Subject: [PATCH] gdiplus: Store copies of remap tables in ImageAttributes
objects.
---
dlls/gdiplus/gdiplus_private.h | 2 +-
dlls/gdiplus/imageattributes.c | 23 ++++++++++++++++++++++-
2 files changed, 23 insertions(+), 2 deletions(-)
diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h
index 24df3dd..3b82b08 100644
--- a/dlls/gdiplus/gdiplus_private.h
+++ b/dlls/gdiplus/gdiplus_private.h
@@ -326,7 +326,7 @@ struct color_matrix{
struct color_remap_table{
BOOL enabled;
INT mapsize;
- GDIPCONST ColorMap *colormap;
+ ColorMap *colormap;
};
struct GpImageAttributes{
diff --git a/dlls/gdiplus/imageattributes.c b/dlls/gdiplus/imageattributes.c
index c157af3..bd5c082 100644
--- a/dlls/gdiplus/imageattributes.c
+++ b/dlls/gdiplus/imageattributes.c
@@ -62,11 +62,16 @@ GpStatus WINGDIPAPI GdipCreateImageAttributes(GpImageAttributes **imageattr)
GpStatus WINGDIPAPI GdipDisposeImageAttributes(GpImageAttributes *imageattr)
{
+ int i;
+
TRACE("(%p)\n", imageattr);
if(!imageattr)
return InvalidParameter;
+ for (i=0; i<ColorAdjustTypeCount; i++)
+ GdipFree(imageattr->colorremaptables[i].colormap);
+
GdipFree(imageattr);
return Ok;
@@ -205,6 +210,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesRemapTable(GpImageAttributes *imageAtt
ColorAdjustType type, BOOL enableFlag, UINT mapSize,
GDIPCONST ColorMap *map)
{
+ ColorMap *new_map;
+
TRACE("(%p,%u,%i,%u,%p)\n", imageAttr, type, enableFlag, mapSize, map);
if(!imageAttr || type >= ColorAdjustTypeCount)
@@ -215,8 +222,22 @@ GpStatus WINGDIPAPI GdipSetImageAttributesRemapTable(GpImageAttributes *imageAtt
if(!map || !mapSize)
return InvalidParameter;
+ new_map = GdipAlloc(sizeof(*map) * mapSize);
+
+ if (!new_map)
+ return OutOfMemory;
+
+ memcpy(new_map, map, sizeof(*map) * mapSize);
+
+ GdipFree(imageAttr->colorremaptables[type].colormap);
+
imageAttr->colorremaptables[type].mapsize = mapSize;
- imageAttr->colorremaptables[type].colormap = map;
+ imageAttr->colorremaptables[type].colormap = new_map;
+ }
+ else
+ {
+ GdipFree(imageAttr->colorremaptables[type].colormap);
+ imageAttr->colorremaptables[type].colormap = NULL;
}
imageAttr->colorremaptables[type].enabled = enableFlag;
--
1.7.9.1
More information about the wine-patches
mailing list