From 85f1f82365b1d2f02fed9c860618a7e1a8048a7e Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Fri, 18 Dec 2009 17:42:18 -0600 Subject: [PATCH 2/2] gdiplus: Implement GdipSetImageAttributesColorMatrix. --- dlls/gdiplus/gdiplus_private.h | 8 ++++++++ dlls/gdiplus/imageattributes.c | 27 ++++++++++++++++++++++----- dlls/gdiplus/tests/image.c | 18 +++++++++--------- 3 files changed, 39 insertions(+), 14 deletions(-) diff --git a/dlls/gdiplus/gdiplus_private.h b/dlls/gdiplus/gdiplus_private.h index 0ceeb6e..9a357c8 100644 --- a/dlls/gdiplus/gdiplus_private.h +++ b/dlls/gdiplus/gdiplus_private.h @@ -249,9 +249,17 @@ struct color_key{ ARGB high; }; +struct color_matrix{ + BOOL enabled; + ColorMatrixFlags flags; + ColorMatrix colormatrix; + ColorMatrix graymatrix; +}; + struct GpImageAttributes{ WrapMode wrap; struct color_key colorkeys[ColorAdjustTypeCount]; + struct color_matrix colormatrices[ColorAdjustTypeCount]; }; struct GpFont{ diff --git a/dlls/gdiplus/imageattributes.c b/dlls/gdiplus/imageattributes.c index 8f49c67..e0e88dc 100644 --- a/dlls/gdiplus/imageattributes.c +++ b/dlls/gdiplus/imageattributes.c @@ -84,15 +84,32 @@ GpStatus WINGDIPAPI GdipSetImageAttributesColorMatrix(GpImageAttributes *imageat ColorAdjustType type, BOOL enableFlag, GDIPCONST ColorMatrix* colorMatrix, GDIPCONST ColorMatrix* grayMatrix, ColorMatrixFlags flags) { - static int calls; + TRACE("(%p,%u,%i,%p,%p,%u)\n", imageattr, type, enableFlag, colorMatrix, + grayMatrix, flags); - if(!imageattr || !colorMatrix || !grayMatrix) + if(!imageattr || type >= ColorAdjustTypeCount || flags > ColorMatrixFlagsAltGray) return InvalidParameter; - if(!(calls++)) - FIXME("not implemented\n"); + if (enableFlag) + { + if (!colorMatrix) + return InvalidParameter; - return NotImplemented; + if (flags == ColorMatrixFlagsAltGray) + { + if (!grayMatrix) + return InvalidParameter; + + imageattr->colormatrices[type].graymatrix = *grayMatrix; + } + + imageattr->colormatrices[type].colormatrix = *colorMatrix; + imageattr->colormatrices[type].flags = flags; + } + + imageattr->colormatrices[type].enabled = enableFlag; + + return Ok; } GpStatus WINGDIPAPI GdipSetImageAttributesWrapMode(GpImageAttributes *imageAttr, diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c index 14a4b1b..e090de9 100644 --- a/dlls/gdiplus/tests/image.c +++ b/dlls/gdiplus/tests/image.c @@ -1125,7 +1125,7 @@ static void test_colormatrix(void) stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, TRUE, &colormatrix, NULL, ColorMatrixFlagsDefault); - todo_wine expect(Ok, stat); + expect(Ok, stat); stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, TRUE, NULL, NULL, ColorMatrixFlagsDefault); @@ -1133,11 +1133,11 @@ static void test_colormatrix(void) stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, TRUE, &colormatrix, &graymatrix, ColorMatrixFlagsDefault); - todo_wine expect(Ok, stat); + expect(Ok, stat); stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, TRUE, &colormatrix, NULL, ColorMatrixFlagsSkipGrays); - todo_wine expect(Ok, stat); + expect(Ok, stat); stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, TRUE, &colormatrix, NULL, ColorMatrixFlagsAltGray); @@ -1145,29 +1145,29 @@ static void test_colormatrix(void) stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, TRUE, &colormatrix, &graymatrix, ColorMatrixFlagsAltGray); - todo_wine expect(Ok, stat); + expect(Ok, stat); stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, TRUE, &colormatrix, &graymatrix, 3); - todo_wine expect(InvalidParameter, stat); + expect(InvalidParameter, stat); stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeCount, TRUE, &colormatrix, &graymatrix, ColorMatrixFlagsDefault); - todo_wine expect(InvalidParameter, stat); + expect(InvalidParameter, stat); stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeAny, TRUE, &colormatrix, &graymatrix, ColorMatrixFlagsDefault); - todo_wine expect(InvalidParameter, stat); + expect(InvalidParameter, stat); stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, FALSE, NULL, NULL, ColorMatrixFlagsDefault); - todo_wine expect(Ok, stat); + expect(Ok, stat); /* Drawing a bitmap transforms the colors */ colormatrix = double_red; stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, TRUE, &colormatrix, NULL, ColorMatrixFlagsDefault); - todo_wine expect(Ok, stat); + expect(Ok, stat); stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB, NULL, &bitmap1); expect(Ok, stat); -- 1.6.3.3