[5/5] gdiplus: Add metafile test for FillRectangles.
Vincent Povirk
madewokherd at gmail.com
Fri Nov 22 16:47:00 CST 2013
-------------- next part --------------
From b059aaa90a0c82b5458fd2b2dafb9545209bdbcf Mon Sep 17 00:00:00 2001
From: Vincent Povirk <vincent at codeweavers.com>
Date: Wed, 20 Nov 2013 16:07:26 -0600
Subject: [PATCH 5/5] gdiplus: Add metafile test for FillRectangles.
---
dlls/gdiplus/tests/metafile.c | 109 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 109 insertions(+)
diff --git a/dlls/gdiplus/tests/metafile.c b/dlls/gdiplus/tests/metafile.c
index 9dcc803..d4d7adb 100644
--- a/dlls/gdiplus/tests/metafile.c
+++ b/dlls/gdiplus/tests/metafile.c
@@ -601,6 +601,114 @@ static void test_emfonly(void)
ok(ret != 0, "Failed to delete enhmetafile %p\n", hemf);
}
+static const emfplus_record fillrect_records[] = {
+ {0, EMR_HEADER},
+ {0, EmfPlusRecordTypeHeader},
+ {0, EmfPlusRecordTypeFillRects},
+ {0, EmfPlusRecordTypeEndOfFile},
+ {0, EMR_EOF},
+ {0}
+};
+
+static void test_fillrect(void)
+{
+ GpStatus stat;
+ GpMetafile *metafile;
+ GpGraphics *graphics;
+ HDC hdc;
+ HENHMETAFILE hemf;
+ static const GpRectF frame = {0.0, 0.0, 100.0, 100.0};
+ static const GpPointF dst_points[3] = {{0.0,0.0},{100.0,0.0},{0.0,100.0}};
+ static const GpPointF dst_points_half[3] = {{0.0,0.0},{50.0,0.0},{0.0,50.0}};
+ static const WCHAR description[] = {'w','i','n','e','t','e','s','t',0};
+ GpBitmap *bitmap;
+ ARGB color;
+ GpBrush *brush;
+
+ hdc = CreateCompatibleDC(0);
+
+ stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, &frame, MetafileFrameUnitPixel, description, &metafile);
+ expect(Ok, stat);
+
+ DeleteDC(hdc);
+
+ if (stat != Ok)
+ return;
+
+ stat = GdipGetHemfFromMetafile(metafile, &hemf);
+ expect(InvalidParameter, stat);
+
+ stat = GdipGetImageGraphicsContext((GpImage*)metafile, &graphics);
+ expect(Ok, stat);
+
+ stat = GdipCreateSolidFill((ARGB)0xff0000ff, (GpSolidFill**)&brush);
+ expect(Ok, stat);
+
+ stat = GdipFillRectangleI(graphics, brush, 25, 25, 75, 75);
+ expect(Ok, stat);
+
+ stat = GdipDeleteBrush(brush);
+ expect(Ok, stat);
+
+ stat = GdipDeleteGraphics(graphics);
+ expect(Ok, stat);
+
+ check_metafile(metafile, fillrect_records, "fillrect metafile", dst_points, &frame, UnitPixel);
+
+ stat = GdipCreateBitmapFromScan0(100, 100, 0, PixelFormat32bppARGB, NULL, &bitmap);
+ expect(Ok, stat);
+
+ stat = GdipGetImageGraphicsContext((GpImage*)bitmap, &graphics);
+ expect(Ok, stat);
+
+ play_metafile(metafile, graphics, fillrect_records, "fillrect playback", dst_points, &frame, UnitPixel);
+
+ stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
+ expect(Ok, stat);
+ expect(0, color);
+
+ stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
+ expect(Ok, stat);
+ expect(0xff0000ff, color);
+
+ stat = GdipBitmapSetPixel(bitmap, 50, 50, 0);
+ expect(Ok, stat);
+
+ play_metafile(metafile, graphics, fillrect_records, "fillrect playback", dst_points_half, &frame, UnitPixel);
+
+ stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
+ expect(Ok, stat);
+ expect(0xff0000ff, color);
+
+ stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
+ expect(Ok, stat);
+ expect(0, color);
+
+ stat = GdipBitmapSetPixel(bitmap, 15, 15, 0);
+ expect(Ok, stat);
+
+ stat = GdipDrawImagePointsRect(graphics, (GpImage*)metafile, dst_points, 3,
+ 0.0, 0.0, 100.0, 100.0, UnitPixel, NULL, NULL, NULL);
+ expect(Ok, stat);
+
+ stat = GdipBitmapGetPixel(bitmap, 15, 15, &color);
+ expect(Ok, stat);
+ expect(0, color);
+
+ stat = GdipBitmapGetPixel(bitmap, 50, 50, &color);
+ expect(Ok, stat);
+ expect(0xff0000ff, color);
+
+ stat = GdipDeleteGraphics(graphics);
+ expect(Ok, stat);
+
+ stat = GdipDisposeImage((GpImage*)bitmap);
+ expect(Ok, stat);
+
+ stat = GdipDisposeImage((GpImage*)metafile);
+ expect(Ok, stat);
+}
+
START_TEST(metafile)
{
struct GdiplusStartupInput gdiplusStartupInput;
@@ -616,6 +724,7 @@ START_TEST(metafile)
test_empty();
test_getdc();
test_emfonly();
+ test_fillrect();
GdiplusShutdown(gdiplusToken);
}
--
1.8.1.2
More information about the wine-patches
mailing list