From a36cede2cafb24358add82c8ab1749d7d2735451 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Sun, 5 Sep 2010 18:30:51 -0500 Subject: [PATCH 1/2] gdiplus: Add a test showing that GdipGraphicsClear replaces image data. --- dlls/gdiplus/tests/graphics.c | 43 +++++++++++++++++++++++++++++++++++++++++ 1 files changed, 43 insertions(+), 0 deletions(-) diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index 9fae06c..a0882f4 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -29,6 +29,18 @@ #define expectf(expected, got) expectf_(expected, got, 0.0001) #define TABLE_LEN (23) +static BOOL color_match(ARGB c1, ARGB c2, BYTE max_diff) +{ + if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE; + c1 >>= 8; c2 >>= 8; + if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE; + c1 >>= 8; c2 >>= 8; + if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE; + c1 >>= 8; c2 >>= 8; + if (abs((c1 & 0xff) - (c2 & 0xff)) > max_diff) return FALSE; + return TRUE; +} + static HWND hwnd; static void test_constructor_destructor(void) @@ -2221,6 +2233,36 @@ static void test_fromMemoryBitmap(void) GdipDisposeImage((GpImage*)bitmap); } +static void test_fromAlphaBitmap(void) +{ + GpStatus status; + GpGraphics *graphics = NULL; + GpBitmap *bitmap = NULL; + BYTE bits[64] = {0}; + ARGB color; + + status = GdipCreateBitmapFromScan0(4, 4, 16, PixelFormat32bppARGB, bits, &bitmap); + expect(Ok, status); + + status = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics); + expect(Ok, status); + + status = GdipGraphicsClear(graphics, 0xffffffff); + expect(Ok, status); + + status = GdipGraphicsClear(graphics, 0x8090a0b0); + expect(Ok, status); + + GdipDeleteGraphics(graphics); + + status = GdipBitmapGetPixel(bitmap, 1, 1, &color); + expect(Ok, status); + /* GdipGraphicsClear replaces pixels rather than composing them. */ + todo_wine ok(color_match(0x8090a0b0, color, 1), "Expected 8090a0b0, got %.8x\n", color); + + GdipDisposeImage((GpImage*)bitmap); +} + static void test_GdipIsVisiblePoint(void) { GpStatus status; @@ -3009,6 +3051,7 @@ START_TEST(graphics) test_clear(); test_textcontrast(); test_fromMemoryBitmap(); + test_fromAlphaBitmap(); test_string_functions(); GdiplusShutdown(gdiplusToken); -- 1.6.3.3