Vincent Povirk : gdiplus: Add a test for GdipSetImageAttributesColorMatrix.

Alexandre Julliard julliard at winehq.org
Mon Dec 21 09:39:47 CST 2009


Module: wine
Branch: master
Commit: 70bdc43c20a01d01920c1e397c2e9a26829f76bb
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=70bdc43c20a01d01920c1e397c2e9a26829f76bb

Author: Vincent Povirk <vincent at codeweavers.com>
Date:   Fri Dec 18 17:38:40 2009 -0600

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);
 }




More information about the wine-cvs mailing list