From a07cbc0c7621612a142bd31c82225c1f3ef967b3 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Fri, 18 Dec 2009 17:38:40 -0600 Subject: [PATCH 1/2] gdiplus: Add a test for GdipSetImageAttributesColorMatrix. --- dlls/gdiplus/tests/image.c | 104 ++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 104 insertions(+), 0 deletions(-) diff --git a/dlls/gdiplus/tests/image.c b/dlls/gdiplus/tests/image.c index 522e5de..14a4b1b 100644 --- a/dlls/gdiplus/tests/image.c +++ b/dlls/gdiplus/tests/image.c @@ -1092,6 +1092,109 @@ static void test_palette(void) GdipDisposeImage((GpImage*)bitmap); } +static void test_colormatrix(void) +{ + GpStatus stat; + ColorMatrix colormatrix, graymatrix; + GpImageAttributes *imageattr; + const ColorMatrix identity = {{ + {1.0,0.0,0.0,0.0,0.0}, + {0.0,1.0,0.0,0.0,0.0}, + {0.0,0.0,1.0,0.0,0.0}, + {0.0,0.0,0.0,1.0,0.0}, + {0.0,0.0,0.0,0.0,1.0}}}; + const ColorMatrix double_red = {{ + {2.0,0.0,0.0,0.0,0.0}, + {0.0,1.0,0.0,0.0,0.0}, + {0.0,0.0,1.0,0.0,0.0}, + {0.0,0.0,0.0,1.0,0.0}, + {0.0,0.0,0.0,0.0,1.0}}}; + GpBitmap *bitmap1, *bitmap2; + GpGraphics *graphics; + ARGB color; + + colormatrix = identity; + graymatrix = identity; + + stat = GdipSetImageAttributesColorMatrix(NULL, ColorAdjustTypeDefault, + TRUE, &colormatrix, &graymatrix, ColorMatrixFlagsDefault); + expect(InvalidParameter, stat); + + stat = GdipCreateImageAttributes(&imageattr); + expect(Ok, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, + TRUE, &colormatrix, NULL, ColorMatrixFlagsDefault); + todo_wine expect(Ok, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, + TRUE, NULL, NULL, ColorMatrixFlagsDefault); + expect(InvalidParameter, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, + TRUE, &colormatrix, &graymatrix, ColorMatrixFlagsDefault); + todo_wine expect(Ok, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, + TRUE, &colormatrix, NULL, ColorMatrixFlagsSkipGrays); + todo_wine expect(Ok, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, + TRUE, &colormatrix, NULL, ColorMatrixFlagsAltGray); + expect(InvalidParameter, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, + TRUE, &colormatrix, &graymatrix, ColorMatrixFlagsAltGray); + todo_wine expect(Ok, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, + TRUE, &colormatrix, &graymatrix, 3); + todo_wine expect(InvalidParameter, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeCount, + TRUE, &colormatrix, &graymatrix, ColorMatrixFlagsDefault); + todo_wine expect(InvalidParameter, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeAny, + TRUE, &colormatrix, &graymatrix, ColorMatrixFlagsDefault); + todo_wine expect(InvalidParameter, stat); + + stat = GdipSetImageAttributesColorMatrix(imageattr, ColorAdjustTypeDefault, + FALSE, NULL, NULL, ColorMatrixFlagsDefault); + todo_wine 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); + + stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB, NULL, &bitmap1); + expect(Ok, stat); + + stat = GdipCreateBitmapFromScan0(1, 1, 0, PixelFormat32bppRGB, NULL, &bitmap2); + expect(Ok, stat); + + stat = GdipBitmapSetPixel(bitmap1, 0, 0, 0xff40ffff); + expect(Ok, stat); + + stat = GdipGetImageGraphicsContext((GpImage*)bitmap2, &graphics); + 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); + todo_wine expect(0xff80ffff, color); + + GdipDeleteGraphics(graphics); + GdipDisposeImage((GpImage*)bitmap1); + GdipDisposeImage((GpImage*)bitmap2); + GdipDisposeImageAttributes(imageattr); +} + START_TEST(image) { struct GdiplusStartupInput gdiplusStartupInput; @@ -1120,6 +1223,7 @@ START_TEST(image) test_createhbitmap(); test_getsetpixel(); test_palette(); + test_colormatrix(); GdiplusShutdown(gdiplusToken); } -- 1.6.3.3