Signed-off-by: Jeff Smith whydoubt@gmail.com --- dlls/gdiplus/tests/brush.c | 94 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+)
diff --git a/dlls/gdiplus/tests/brush.c b/dlls/gdiplus/tests/brush.c index 445b0cd126..8e50318268 100644 --- a/dlls/gdiplus/tests/brush.c +++ b/dlls/gdiplus/tests/brush.c @@ -1758,6 +1758,99 @@ static void test_hatchBrushStyles(void) ReleaseDC(hwnd, hdc); }
+static void test_hatchBrushColors(void) +{ + /* Foreground color, background color, + * resulting 4 colors */ + static const ARGB colors[][6] = { + { 0xff000000, 0xffffffff, + 0xffffffff, 0xffbfbfbf, 0xff151515, 0xff000000 }, + { 0xffffffff, 0xff000000, + 0xff000000, 0xff3f3f3f, 0xffe9e9e9, 0xffffffff }, + { 0xffd2d2d2, 0xff000000, + 0xff000000, 0xff343434, 0xffbfbfbf, 0xffd2d2d2 }, + }; + static const int width = 16, height = 8; + static const int pixel_coord[][2] = { + {12, 1}, {1, 0}, {0, 0}, {8, 0} + }; + HDC hdc; + GpStatus status; + GpGraphics *graphics_hdc; + GpGraphics *graphics_image; + GpGraphics *graphics_image_a; + GpBitmap *bitmap; + GpBitmap *bitmap_a; + GpHatch *brush_diag_cross; + GpHatch *brush_cross; + int i, j; + + hdc = GetDC(hwnd); + status = GdipCreateFromHDC(hdc, &graphics_hdc); + expect(Ok, status); + + status = GdipCreateBitmapFromScan0(width, height, 0, PixelFormat32bppRGB, NULL, &bitmap); + expect(Ok, status); + status = GdipGetImageGraphicsContext((GpImage *)bitmap, &graphics_image); + expect(Ok, status); + + status = GdipCreateBitmapFromScan0(width, height, 0, PixelFormat32bppARGB, NULL, &bitmap_a); + expect(Ok, status); + status = GdipGetImageGraphicsContext((GpImage *)bitmap_a, &graphics_image_a); + expect(Ok, status); + + for (i = 0; i < ARRAY_SIZE(colors); i++) + { + status = GdipCreateHatchBrush(HatchStyleDiagonalCross, colors[i][0], colors[i][1], + &brush_diag_cross); + expect(Ok, status); + status = GdipCreateHatchBrush(HatchStyleCross, colors[i][0], colors[i][1], + &brush_cross); + expect(Ok, status); + + GdipFillRectangleI(graphics_hdc, (GpBrush *)brush_diag_cross, 0, 0, width/2, height); + GdipFillRectangleI(graphics_image, (GpBrush *)brush_diag_cross, 0, 0, width/2, height); + GdipFillRectangleI(graphics_image_a, (GpBrush *)brush_diag_cross, 0, 0, width/2, height); + GdipFillRectangleI(graphics_hdc, (GpBrush *)brush_cross, width/2, 0, width/2, height); + GdipFillRectangleI(graphics_image, (GpBrush *)brush_cross, width/2, 0, width/2, height); + GdipFillRectangleI(graphics_image_a, (GpBrush *)brush_cross, width/2, 0, width/2, height); + + GdipDeleteBrush((GpBrush *)brush_diag_cross); + GdipDeleteBrush((GpBrush *)brush_cross); + + for (j = 0; j < 4; j++) + { + ARGB color; + const ARGB exp_color = colors[i][j+2]; + const int x = pixel_coord[j][0]; + const int y = pixel_coord[j][1]; + + todo_wine_if(j == 1 || j == 2) + { + color = get_pixel_as_argb(hdc, x, y); + ok(color == exp_color, "For hwnd (%d, %d) colorset %d expected %08x, got %08x.\n", + x, y, i, exp_color, color); + + GdipBitmapGetPixel(bitmap, x, y, &color); + ok(color == exp_color, "For rgb image (%d, %d) colorset %d expected %08x, got %08x.\n", + x, y, i, exp_color, color); + + GdipBitmapGetPixel(bitmap_a, x, y, &color); + ok(color == exp_color, "For argb image (%d, %d) colorset %d expected %08x, got %08x.\n", + x, y, i, exp_color, color); + } + } + } + + GdipDeleteGraphics(graphics_hdc); + GdipDeleteGraphics(graphics_image); + GdipDeleteGraphics(graphics_image_a); + + GdipDisposeImage((GpImage*)bitmap); + GdipDisposeImage((GpImage*)bitmap_a); + ReleaseDC(hwnd, hdc); +} + START_TEST(brush) { struct GdiplusStartupInput gdiplusStartupInput; @@ -1811,6 +1904,7 @@ START_TEST(brush) test_pathgradientblend(); test_getHatchStyle(); test_hatchBrushStyles(); + test_hatchBrushColors();
GdiplusShutdown(gdiplusToken); DestroyWindow(hwnd);