[PATCH] gdiplus: Implement GdipResetImageAttributes

Andrew Eikum aeikum at codeweavers.com
Wed May 22 11:12:18 CDT 2013


---
 dlls/gdiplus/gdiplus.spec      |  2 +-
 dlls/gdiplus/imageattributes.c | 17 +++++++++++
 dlls/gdiplus/tests/image.c     | 65 +++++++++++++++++++++++++++++++++++++++---
 include/gdiplusflat.h          |  2 ++
 4 files changed, 81 insertions(+), 5 deletions(-)

diff --git a/dlls/gdiplus/gdiplus.spec b/dlls/gdiplus/gdiplus.spec
index 4f30ed1..cee3ea6 100644
--- a/dlls/gdiplus/gdiplus.spec
+++ b/dlls/gdiplus/gdiplus.spec
@@ -455,7 +455,7 @@
 455 stdcall GdipReleaseDC(ptr ptr)
 456 stdcall GdipRemovePropertyItem(ptr long)
 457 stdcall GdipResetClip(ptr)
-458 stub GdipResetImageAttributes
+458 stdcall GdipResetImageAttributes(ptr long)
 459 stdcall GdipResetLineTransform(ptr)
 460 stdcall GdipResetPageTransform(ptr)
 461 stdcall GdipResetPath(ptr)
diff --git a/dlls/gdiplus/imageattributes.c b/dlls/gdiplus/imageattributes.c
index bd5c082..0b09547 100644
--- a/dlls/gdiplus/imageattributes.c
+++ b/dlls/gdiplus/imageattributes.c
@@ -270,3 +270,20 @@ GpStatus WINGDIPAPI GdipSetImageAttributesToIdentity(GpImageAttributes *imageAtt
 
     return NotImplemented;
 }
+
+GpStatus WINGDIPAPI GdipResetImageAttributes(GpImageAttributes *imageAttr,
+    ColorAdjustType type)
+{
+    TRACE("(%p,%u)\n", imageAttr, type);
+
+    if(!imageAttr || type >= ColorAdjustTypeCount)
+        return InvalidParameter;
+
+    memset(&imageAttr->colorkeys[type], 0, sizeof(imageAttr->colorkeys[type]));
+    memset(&imageAttr->colormatrices[type], 0, sizeof(imageAttr->colormatrices[type]));
+    memset(&imageAttr->colorremaptables[type], 0, sizeof(imageAttr->colorremaptables[type]));
+    memset(&imageAttr->gamma_enabled[type], 0, sizeof(imageAttr->gamma_enabled[type]));
+    memset(&imageAttr->gamma[type], 0, sizeof(imageAttr->gamma[type]));
+
+    return Ok;
+}
diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c
index 6b4a34c..18e159b 100644
--- a/dlls/gdiplus/tests/image.c
+++ b/dlls/gdiplus/tests/image.c
@@ -2211,6 +2211,17 @@ static void test_colormatrix(void)
     expect(Ok, stat);
     ok(color_match(0xeeff40cc, color, 3), "expected 0xeeff40cc, got 0x%08x\n", color);
 
+    stat = GdipResetImageAttributes(imageattr, ColorAdjustTypeDefault);
+    expect(Ok, stat);
+
+    stat = GdipDrawImageRectRectI(graphics, (GpImage*)bitmap1, 0,0,1,1, 0,0,1,1,
+        UnitPixel, imageattr, NULL, NULL);
+    expect(Ok, stat);
+
+    stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
+    expect(Ok, stat);
+    ok(color_match(0xff40ccee, color, 1), "Expected ff40ccee, got %.8x\n", color);
+
     GdipDeleteGraphics(graphics);
     GdipDisposeImage((GpImage*)bitmap1);
     GdipDisposeImage((GpImage*)bitmap2);
@@ -2273,6 +2284,17 @@ static void test_gamma(void)
     expect(Ok, stat);
     ok(color_match(0xff20ffff, color, 1), "Expected ff20ffff, got %.8x\n", color);
 
+    stat = GdipResetImageAttributes(imageattr, ColorAdjustTypeDefault);
+    expect(Ok, stat);
+
+    stat = GdipDrawImageRectRectI(graphics, (GpImage*)bitmap1, 0,0,1,1, 0,0,1,1,
+        UnitPixel, imageattr, NULL, NULL);
+    expect(Ok, stat);
+
+    stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
+    expect(Ok, stat);
+    ok(color_match(0xff80ffff, color, 1), "Expected ff80ffff, got %.8x\n", color);
+
     GdipDeleteGraphics(graphics);
     GdipDisposeImage((GpImage*)bitmap1);
     GdipDisposeImage((GpImage*)bitmap2);
@@ -2604,6 +2626,17 @@ static void test_remaptable(void)
     expect(Ok, stat);
     ok(color_match(0xffff00ff, color, 1), "Expected ffff00ff, got %.8x\n", color);
 
+    stat = GdipResetImageAttributes(imageattr, ColorAdjustTypeDefault);
+    expect(Ok, stat);
+
+    stat = GdipDrawImageRectRectI(graphics, (GpImage*)bitmap1, 0,0,1,1, 0,0,1,1,
+        UnitPixel, imageattr, NULL, NULL);
+    expect(Ok, stat);
+
+    stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
+    expect(Ok, stat);
+    ok(color_match(0xff00ff00, color, 1), "Expected ff00ff00, got %.8x\n", color);
+
     GdipDeleteGraphics(graphics);
     GdipDisposeImage((GpImage*)bitmap1);
     GdipDisposeImage((GpImage*)bitmap2);
@@ -2661,19 +2694,43 @@ static void test_colorkey(void)
 
     stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
     expect(Ok, stat);
-    ok(color_match(0x00000000, color, 1), "Expected ffff00ff, got %.8x\n", color);
+    ok(color_match(0x00000000, color, 1), "Expected 00000000, got %.8x\n", color);
 
     stat = GdipBitmapGetPixel(bitmap2, 0, 1, &color);
     expect(Ok, stat);
-    ok(color_match(0x00000000, color, 1), "Expected ffff00ff, got %.8x\n", color);
+    ok(color_match(0x00000000, color, 1), "Expected 00000000, got %.8x\n", color);
 
     stat = GdipBitmapGetPixel(bitmap2, 1, 0, &color);
     expect(Ok, stat);
-    ok(color_match(0x00000000, color, 1), "Expected ffff00ff, got %.8x\n", color);
+    ok(color_match(0x00000000, color, 1), "Expected 00000000, got %.8x\n", color);
 
     stat = GdipBitmapGetPixel(bitmap2, 1, 1, &color);
     expect(Ok, stat);
-    ok(color_match(0xffffffff, color, 1), "Expected ffff00ff, got %.8x\n", color);
+    ok(color_match(0xffffffff, color, 1), "Expected ffffffff, got %.8x\n", color);
+
+    stat = GdipResetImageAttributes(imageattr, ColorAdjustTypeDefault);
+    expect(Ok, stat);
+
+    stat = GdipDrawImageRectRectI(graphics, (GpImage*)bitmap1, 0,0,2,2, 0,0,2,2,
+	UnitPixel, imageattr, NULL, NULL);
+    expect(Ok, stat);
+
+    stat = GdipBitmapGetPixel(bitmap2, 0, 0, &color);
+    expect(Ok, stat);
+    ok(color_match(0x20405060, color, 1), "Expected 20405060, got %.8x\n", color);
+
+    stat = GdipBitmapGetPixel(bitmap2, 0, 1, &color);
+    expect(Ok, stat);
+    ok(color_match(0x40506070, color, 1), "Expected 40506070, got %.8x\n", color);
+
+    stat = GdipBitmapGetPixel(bitmap2, 1, 0, &color);
+    expect(Ok, stat);
+    ok(color_match(0x60708090, color, 1), "Expected 60708090, got %.8x\n", color);
+
+    stat = GdipBitmapGetPixel(bitmap2, 1, 1, &color);
+    expect(Ok, stat);
+    ok(color_match(0xffffffff, color, 1), "Expected ffffffff, got %.8x\n", color);
+
 
     GdipDeleteGraphics(graphics);
     GdipDisposeImage((GpImage*)bitmap1);
diff --git a/include/gdiplusflat.h b/include/gdiplusflat.h
index c622431..0753585 100644
--- a/include/gdiplusflat.h
+++ b/include/gdiplusflat.h
@@ -458,6 +458,8 @@ GpStatus WINGDIPAPI GdipSetImageAttributesToIdentity(GpImageAttributes*,
     ColorAdjustType);
 GpStatus WINGDIPAPI GdipSetImageAttributesWrapMode(GpImageAttributes*,WrapMode,
     ARGB,BOOL);
+GpStatus WINGDIPAPI GdipResetImageAttributes(GpImageAttributes*,
+    ColorAdjustType);
 
 /* LinearGradientBrush */
 GpStatus WINGDIPAPI GdipCreateLineBrush(GDIPCONST GpPointF*,GDIPCONST GpPointF*,
-- 
1.8.2.3




More information about the wine-patches mailing list