https://git.reactos.org/?p=reactos.git;a=commitdiff;h=7d57324d5dfd586a73eab4...
commit 7d57324d5dfd586a73eab4582af944417f16867f Author: Amine Khaldi amine.khaldi@reactos.org AuthorDate: Fri Jan 25 13:23:03 2019 +0100 Commit: Amine Khaldi amine.khaldi@reactos.org CommitDate: Fri Jan 25 13:23:03 2019 +0100
[GDIPLUS_WINETEST] Sync with Wine Staging 4.0. CORE-15682 --- modules/rostests/winetests/gdiplus/brush.c | 380 ++++++++++++-------------- modules/rostests/winetests/gdiplus/font.c | 25 +- modules/rostests/winetests/gdiplus/graphics.c | 36 ++- modules/rostests/winetests/gdiplus/image.c | 231 +++++++++++++--- modules/rostests/winetests/gdiplus/pen.c | 148 ++++++++++ modules/rostests/winetests/gdiplus/region.c | 9 +- 6 files changed, 569 insertions(+), 260 deletions(-)
diff --git a/modules/rostests/winetests/gdiplus/brush.c b/modules/rostests/winetests/gdiplus/brush.c index 0451948175..bb645ffef9 100644 --- a/modules/rostests/winetests/gdiplus/brush.c +++ b/modules/rostests/winetests/gdiplus/brush.c @@ -621,141 +621,103 @@ static void test_texturewrap(void)
static void test_gradientgetrect(void) { + static const struct + { + LinearGradientMode mode; + GpRectF rect; + REAL transform[6]; + } + create_from_rect[] = + { + { LinearGradientModeHorizontal, { 10.0f, 10.0f, -100.0f, -100.0f } }, + { LinearGradientModeHorizontal, { 10.0f, 10.0f, 100.0f, 100.0f } }, + { LinearGradientModeHorizontal, { 10.0f, -5.0f, 100.0f, 50.0f } }, + { LinearGradientModeHorizontal, { -5.0f, 10.0f, 100.0f, 50.0f } }, + { LinearGradientModeVertical, { 0.0f, 0.0f, 100.0f, 10.0f }, { 0.0f, 0.1f, -10.0f, -0.0f, 100.0f, 0.0f } }, + { LinearGradientModeVertical, { 10.0f, -12.0f, 100.0f, 105.0f }, { 0.0f, 1.05f, -0.952f, 0.0f, 98.571f, -22.5f } }, + }; + static const struct + { + GpPointF pt1, pt2; + GpRectF rect; + REAL transform[6]; + } + create_from_pt[] = + { + { { 1.0f, 1.0f }, { 100.0f, 100.0f }, { 1.0f, 1.0f, 99.0f, 99.0f }, { 1.0f, 1.0f, -1.0f, 1.0f, 50.50f, -50.50f } }, + { { 0.0f, 0.0f }, { 0.0f, 10.0f }, { -5.0f, 0.0f, 10.0f, 10.0f }, { 0.0f, 1.0f, -1.0f, 0.0f, 5.0f, 5.0f } }, + { { 0.0f, 0.0f }, { 10.0f, 0.0f }, { 0.0f, -5.0f, 10.0f, 10.0f }, { 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f } }, + /* Slope = -1 */ + { { 0.0f, 0.0f }, { 20.0f, -20.0f }, { 0.0f, -20.0f, 20.0f, 20.0f }, { 1.0f, -1.0f, 1.0f, 1.0f, 10.0f, 10.0f } }, + /* Slope = 1/100 */ + { { 0.0f, 0.0f }, { 100.0f, 1.0f }, { 0.0f, 0.0f, 100.0f, 1.0f }, { 1.0f, 0.01f, -0.02f, 2.0f, 0.01f, -1.0f } }, + { { 10.0f, 10.0f }, { -90.0f, 10.0f }, { -90.0f, -40.0f, 100.0f, 100.0f }, { -1.0f, 0.0f, 0.0f, -1.0f, -80.0f, 20.0f } }, + }; + static const struct + { + GpRectF rect; + REAL angle; + BOOL is_scalable; + REAL transform[6]; + } + create_with_angle[] = + { + { { 10.0f, 10.0f, -100.0f, -100.0f }, 0.0f, TRUE }, + { { 10.0f, 10.0f, -100.0f, -100.0f }, 0.0f, FALSE }, + { { 10.0f, 10.0f, 100.0f, 100.0f }, 0.0f, FALSE }, + { { 10.0f, 10.0f, 100.0f, 100.0f }, 0.0f, TRUE }, + { { 10.0f, -5.0f, 100.0f, 50.0f }, 0.0f, FALSE }, + { { 10.0f, -5.0f, 100.0f, 50.0f }, 0.0f, TRUE }, + { { -5.0f, 10.0f, 100.0f, 50.0f }, 0.0f, FALSE }, + { { -5.0f, 10.0f, 100.0f, 50.0f }, 0.0f, TRUE }, + { { 0.0f, 0.0f, 100.0f, 10.0f }, -90.0f, TRUE, { 0.0f, -0.1f, 10.0f, 0.0f, 0.0f, 10.0f } }, + { { 10.0f, -12.0f, 100.0f, 105.0f }, -90.0f, TRUE, { 0.0f, -1.05f, 0.952f, 0.0f, 21.429f, 103.5f } }, + { { 0.0f, 0.0f, 100.0f, 10.0f }, -90.0f, FALSE, { 0.0f, -0.1f, 10.0f, -0.0f, 0.0f, 10.0f } }, + { { 10.0f, -12.0f, 100.0f, 105.0f }, -90.0f, FALSE, { 0.0f, -1.05f, 0.952f, 0.0f, 21.429f, 103.5f } }, + }; GpLineGradient *brush; GpMatrix *transform; REAL elements[6]; - GpRectF rectf; GpStatus status; - GpPointF pt1, pt2; + unsigned int i; + ARGB colors[2]; + GpRectF rectf;
status = GdipCreateMatrix(&transform); expect(Ok, status);
- pt1.X = pt1.Y = 1.0; - pt2.X = pt2.Y = 100.0; - status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush); - expect(Ok, status); - memset(&rectf, 0, sizeof(GpRectF)); - status = GdipGetLineRect(brush, &rectf); - expect(Ok, status); - expectf(1.0, rectf.X); - expectf(1.0, rectf.Y); - expectf(99.0, rectf.Width); - expectf(99.0, rectf.Height); - status = GdipGetLineTransform(brush, transform); - expect(Ok, status); - status = GdipGetMatrixElements(transform, elements); - expect(Ok, status); - expectf(1.0, elements[0]); - expectf(1.0, elements[1]); - expectf(-1.0, elements[2]); - expectf(1.0, elements[3]); - expectf(50.50, elements[4]); - expectf(-50.50, elements[5]); - status = GdipDeleteBrush((GpBrush*)brush); - expect(Ok, status); - - /* vertical gradient */ - pt1.X = pt1.Y = pt2.X = 0.0; - pt2.Y = 10.0; - status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush); - expect(Ok, status); - memset(&rectf, 0, sizeof(GpRectF)); - status = GdipGetLineRect(brush, &rectf); - expect(Ok, status); - expectf(-5.0, rectf.X); - expectf(0.0, rectf.Y); - expectf(10.0, rectf.Width); - expectf(10.0, rectf.Height); - status = GdipGetLineTransform(brush, transform); - expect(Ok, status); - status = GdipGetMatrixElements(transform, elements); - expect(Ok, status); - expectf(0.0, elements[0]); - expectf(1.0, elements[1]); - expectf(-1.0, elements[2]); - expectf(0.0, elements[3]); - expectf(5.0, elements[4]); - expectf(5.0, elements[5]); - status = GdipDeleteBrush((GpBrush*)brush); - expect(Ok, status); - - /* horizontal gradient */ - pt1.X = pt1.Y = pt2.Y = 0.0; - pt2.X = 10.0; - status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush); - expect(Ok, status); - memset(&rectf, 0, sizeof(GpRectF)); - status = GdipGetLineRect(brush, &rectf); - expect(Ok, status); - expectf(0.0, rectf.X); - expectf(-5.0, rectf.Y); - expectf(10.0, rectf.Width); - expectf(10.0, rectf.Height); - status = GdipGetLineTransform(brush, transform); - expect(Ok, status); - status = GdipGetMatrixElements(transform, elements); - expect(Ok, status); - expectf(1.0, elements[0]); - expectf(0.0, elements[1]); - expectf(0.0, elements[2]); - expectf(1.0, elements[3]); - expectf(0.0, elements[4]); - expectf(0.0, elements[5]); - status = GdipDeleteBrush((GpBrush*)brush); - expect(Ok, status); - - /* slope = -1 */ - pt1.X = pt1.Y = 0.0; - pt2.X = 20.0; - pt2.Y = -20.0; - status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush); - expect(Ok, status); - memset(&rectf, 0, sizeof(GpRectF)); - status = GdipGetLineRect(brush, &rectf); - expect(Ok, status); - expectf(0.0, rectf.X); - expectf(-20.0, rectf.Y); - expectf(20.0, rectf.Width); - expectf(20.0, rectf.Height); - status = GdipGetLineTransform(brush, transform); - expect(Ok, status); - status = GdipGetMatrixElements(transform, elements); - expect(Ok, status); - expectf(1.0, elements[0]); - expectf(-1.0, elements[1]); - expectf(1.0, elements[2]); - expectf(1.0, elements[3]); - expectf(10.0, elements[4]); - expectf(10.0, elements[5]); - status = GdipDeleteBrush((GpBrush*)brush); - expect(Ok, status); - - /* slope = 1/100 */ - pt1.X = pt1.Y = 0.0; - pt2.X = 100.0; - pt2.Y = 1.0; - status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush); - expect(Ok, status); - memset(&rectf, 0, sizeof(GpRectF)); - status = GdipGetLineRect(brush, &rectf); - expect(Ok, status); - expectf(0.0, rectf.X); - expectf(0.0, rectf.Y); - expectf(100.0, rectf.Width); - expectf(1.0, rectf.Height); - status = GdipGetLineTransform(brush, transform); - expect(Ok, status); - status = GdipGetMatrixElements(transform, elements); - expect(Ok,status); - expectf(1.0, elements[0]); - expectf(0.01, elements[1]); - expectf(-0.02, elements[2]); - /* expectf(2.0, elements[3]); */ - expectf(0.01, elements[4]); - /* expectf(-1.0, elements[5]); */ - status = GdipDeleteBrush((GpBrush*)brush); - expect(Ok,status); + for (i = 0; i < ARRAY_SIZE(create_from_pt); ++i) + { + status = GdipCreateLineBrush(&create_from_pt[i].pt1, &create_from_pt[i].pt2, 0x1, 0x2, WrapModeTile, &brush); + ok(status == Ok, "Failed to create a brush, %d.\n", status); + + memset(&rectf, 0, sizeof(rectf)); + status = GdipGetLineRect(brush, &rectf); + ok(status == Ok, "Failed to get brush rect, %d.\n", status); + ok(!memcmp(&rectf, &create_from_pt[i].rect, sizeof(rectf)), "Unexpected brush rect.\n"); + + status = GdipGetLineTransform(brush, transform); + ok(status == Ok, "Failed to get brush transform, %d.\n", status); + + status = GdipGetMatrixElements(transform, elements); + ok(status == Ok, "Failed to get matrix elements, %d.\n", status); + +#define expectf2(expected, got) ok(fabs(expected - got) < 0.001, "%u: expected %.3f, got %.3f.\n", i, expected, got) + expectf2(create_from_pt[i].transform[0], elements[0]); + expectf2(create_from_pt[i].transform[1], elements[1]); + expectf2(create_from_pt[i].transform[2], elements[2]); + expectf2(create_from_pt[i].transform[3], elements[3]); + expectf2(create_from_pt[i].transform[4], elements[4]); + expectf2(create_from_pt[i].transform[5], elements[5]); +#undef expect2f + + status = GdipGetLineColors(brush, colors); + ok(status == Ok, "Failed to get line colors, %d.\n", status); + ok(colors[0] == 0x1 && colors[1] == 0x2, "Unexpected brush colors.\n"); + + status = GdipDeleteBrush((GpBrush *)brush); + ok(status == Ok, "Failed to delete a brush, %d.\n", status); + }
/* zero height rect */ rectf.X = rectf.Y = 10.0; @@ -773,84 +735,96 @@ static void test_gradientgetrect(void) WrapModeTile, &brush); expect(OutOfMemory, status);
- /* from rect with LinearGradientModeHorizontal */ - rectf.X = rectf.Y = 10.0; - rectf.Width = rectf.Height = 100.0; - status = GdipCreateLineBrushFromRect(&rectf, 0, 0, LinearGradientModeHorizontal, - WrapModeTile, &brush); - expect(Ok, status); - memset(&rectf, 0, sizeof(GpRectF)); - status = GdipGetLineRect(brush, &rectf); - expect(Ok, status); - expectf(10.0, rectf.X); - expectf(10.0, rectf.Y); - expectf(100.0, rectf.Width); - expectf(100.0, rectf.Height); - status = GdipGetLineTransform(brush, transform); - expect(Ok, status); - status = GdipGetMatrixElements(transform, elements); - expect(Ok,status); - expectf(1.0, elements[0]); - expectf(0.0, elements[1]); - expectf(0.0, elements[2]); - expectf(1.0, elements[3]); - expectf(0.0, elements[4]); - expectf(0.0, elements[5]); - status = GdipDeleteBrush((GpBrush*)brush); - expect(Ok,status); + for (i = 0; i < ARRAY_SIZE(create_from_rect); ++i) + { + ARGB colors[2]; + BOOL ret;
- /* passing negative Width/Height to LinearGradientModeHorizontal */ - rectf.X = rectf.Y = 10.0; - rectf.Width = rectf.Height = -100.0; - status = GdipCreateLineBrushFromRect(&rectf, 0, 0, LinearGradientModeHorizontal, - WrapModeTile, &brush); - expect(Ok, status); - memset(&rectf, 0, sizeof(GpRectF)); - status = GdipGetLineRect(brush, &rectf); - expect(Ok, status); - expectf(10.0, rectf.X); - expectf(10.0, rectf.Y); - expectf(-100.0, rectf.Width); - expectf(-100.0, rectf.Height); - status = GdipGetLineTransform(brush, transform); - expect(Ok, status); - status = GdipGetMatrixElements(transform, elements); - expect(Ok,status); - expectf(1.0, elements[0]); - expectf(0.0, elements[1]); - expectf(0.0, elements[2]); - expectf(1.0, elements[3]); - expectf(0.0, elements[4]); - expectf(0.0, elements[5]); - status = GdipDeleteBrush((GpBrush*)brush); - expect(Ok,status); + status = GdipCreateLineBrushFromRect(&create_from_rect[i].rect, 0x1, 0x2, create_from_rect[i].mode, + WrapModeTile, &brush); + ok(status == Ok, "Failed to create a brush, %d.\n", status);
- /* reverse gradient line as immediately previous */ - pt1.X = 10.0; - pt1.Y = 10.0; - pt2.X = -90.0; - pt2.Y = 10.0; - status = GdipCreateLineBrush(&pt1, &pt2, 0, 0, WrapModeTile, &brush); - expect(Ok, status); - memset(&rectf, 0, sizeof(GpRectF)); - status = GdipGetLineRect(brush, &rectf); - expect(Ok, status); - expectf(-90.0, rectf.X); - expectf(-40.0, rectf.Y); - expectf(100.0, rectf.Width); - expectf(100.0, rectf.Height); - status = GdipGetLineTransform(brush, transform); - expect(Ok, status); - status = GdipGetMatrixElements(transform, elements); - expect(Ok, status); - expectf(-1.0, elements[0]); - expectf(0.0, elements[1]); - expectf(0.0, elements[2]); - expectf(-1.0, elements[3]); - expectf(-80.0, elements[4]); - expectf(20.0, elements[5]); - status = GdipDeleteBrush((GpBrush*)brush); - expect(Ok, status); + memset(&rectf, 0, sizeof(rectf)); + status = GdipGetLineRect(brush, &rectf); + ok(status == Ok, "Failed to get brush rect, %d.\n", status); + ok(!memcmp(&rectf, &create_from_rect[i].rect, sizeof(rectf)), "Unexpected brush rect.\n"); + + status = GdipGetLineTransform(brush, transform); + ok(status == Ok, "Failed to get brush transform, %d.\n", status); + + if (create_from_rect[i].mode == LinearGradientModeHorizontal) + { + status = GdipIsMatrixIdentity(transform, &ret); + ok(status == Ok, "Unexpected ret value %d.\n", status); + } + else + { + status = GdipGetMatrixElements(transform, elements); + ok(status == Ok, "Failed to get matrix elements, %d.\n", status); + +#define expectf2(expected, got) ok(fabs(expected - got) < 0.001, "%u: expected %.3f, got %.3f.\n", i, expected, got) + expectf2(create_from_rect[i].transform[0], elements[0]); + expectf2(create_from_rect[i].transform[1], elements[1]); + expectf2(create_from_rect[i].transform[2], elements[2]); + expectf2(create_from_rect[i].transform[3], elements[3]); + expectf2(create_from_rect[i].transform[4], elements[4]); + expectf2(create_from_rect[i].transform[5], elements[5]); +#undef expectf2 + } + + status = GdipGetLineColors(brush, colors); + ok(status == Ok, "Failed to get line colors, %d.\n", status); + ok(colors[0] == 0x1 && colors[1] == 0x2, "Unexpected brush colors.\n"); + + status = GdipDeleteBrush((GpBrush*)brush); + ok(status == Ok, "Failed to delete a brush, %d.\n", status); + } + + for (i = 0; i < ARRAY_SIZE(create_with_angle); ++i) + { + ARGB colors[2]; + BOOL ret; + + status = GdipCreateLineBrushFromRectWithAngle(&create_with_angle[i].rect, 0x1, 0x2, create_with_angle[i].angle, + create_with_angle[i].is_scalable, WrapModeTile, &brush); + ok(status == Ok, "Failed to create a brush, %d.\n", status); + + memset(&rectf, 0, sizeof(rectf)); + status = GdipGetLineRect(brush, &rectf); + ok(status == Ok, "Failed to get brush rect, %d.\n", status); + ok(!memcmp(&rectf, &create_with_angle[i].rect, sizeof(rectf)), "%u: unexpected brush rect {%f,%f,%f,%f}.\n", + i, rectf.X, rectf.Y, rectf.Width, rectf.Height); + + status = GdipGetLineTransform(brush, transform); + ok(status == Ok, "Failed to get brush transform, %d.\n", status); + + if (create_with_angle[i].angle == 0.0f) + { + status = GdipIsMatrixIdentity(transform, &ret); + ok(status == Ok, "Unexpected ret value %d.\n", status); + } + else + { + status = GdipGetMatrixElements(transform, elements); + ok(status == Ok, "Failed to get matrix elements, %d.\n", status); + +#define expectf2(expected, got) ok(fabs(expected - got) < 0.001, "%u: expected %.3f, got %.3f.\n", i, expected, got) + expectf2(create_with_angle[i].transform[0], elements[0]); + expectf2(create_with_angle[i].transform[1], elements[1]); + expectf2(create_with_angle[i].transform[2], elements[2]); + expectf2(create_with_angle[i].transform[3], elements[3]); + expectf2(create_with_angle[i].transform[4], elements[4]); + expectf2(create_with_angle[i].transform[5], elements[5]); +#undef expectf2 + } + + status = GdipGetLineColors(brush, colors); + ok(status == Ok, "Failed to get line colors, %d.\n", status); + ok(colors[0] == 0x1 && colors[1] == 0x2, "Unexpected brush colors.\n"); + + status = GdipDeleteBrush((GpBrush*)brush); + ok(status == Ok, "Failed to delete a brush, %d.\n", status); + }
GdipDeleteMatrix(transform); } diff --git a/modules/rostests/winetests/gdiplus/font.c b/modules/rostests/winetests/gdiplus/font.c index 961d8459cb..03e7a04e08 100644 --- a/modules/rostests/winetests/gdiplus/font.c +++ b/modules/rostests/winetests/gdiplus/font.c @@ -159,7 +159,8 @@ static void test_createfont(void) expect(Ok, stat); GdipGetFontSize (font, &size); ok (size == 24, "Expected 24, got %f (with unit: %d)\n", size, i); - GdipGetFontUnit (font, &unit); + stat = GdipGetFontUnit (font, &unit); + ok (stat == Ok, "Failed to get font unit, %d.\n", stat); expect (i, unit); GdipDeleteFont(font); } @@ -1238,6 +1239,27 @@ static void test_GdipGetFontCollectionFamilyList(void) GdipDeleteFontFamily(family2); }
+static void test_GdipGetFontCollectionFamilyCount(void) +{ + GpFontCollection *collection; + GpStatus status; + INT count; + + status = GdipGetFontCollectionFamilyCount(NULL, NULL); + ok(status == InvalidParameter, "Unexpected status %d.\n", status); + + count = 123; + status = GdipGetFontCollectionFamilyCount(NULL, &count); + ok(status == InvalidParameter, "Unexpected status %d.\n", status); + ok(count == 123, "Unexpected family count %d.\n", count); + + status = GdipNewInstalledFontCollection(&collection); + ok(status == Ok, "Failed to get system collection, status %d.\n", status); + + status = GdipGetFontCollectionFamilyCount(collection, NULL); + ok(status == InvalidParameter, "Unexpected status %d.\n", status); +} + START_TEST(font) { struct GdiplusStartupInput gdiplusStartupInput; @@ -1269,6 +1291,7 @@ START_TEST(font) test_installedfonts(); test_heightgivendpi(); test_GdipGetFontCollectionFamilyList(); + test_GdipGetFontCollectionFamilyCount();
GdiplusShutdown(gdiplusToken); } diff --git a/modules/rostests/winetests/gdiplus/graphics.c b/modules/rostests/winetests/gdiplus/graphics.c index b0e3d8232b..f2ff589ab5 100644 --- a/modules/rostests/winetests/gdiplus/graphics.c +++ b/modules/rostests/winetests/gdiplus/graphics.c @@ -347,7 +347,8 @@ static void test_save_restore(void) log_state(state_a, &state_log);
/* A state created by BeginContainer cannot be restored with RestoreGraphics. */ - GdipCreateFromHDC(hdc, &graphics1); + stat = GdipCreateFromHDC(hdc, &graphics1); + expect(Ok, stat); GdipSetInterpolationMode(graphics1, InterpolationModeBilinear); stat = GdipBeginContainer2(graphics1, &state_a); expect(Ok, stat); @@ -703,7 +704,8 @@ static void test_BeginContainer2(void) GdipGetTextContrast(graphics, &contrast); ok(defContrast == contrast, "Expected Text Contrast to be restored to %d, got %d\n", defContrast, contrast);
- GdipGetTextRenderingHint(graphics, &texthint); + status = GdipGetTextRenderingHint(graphics, &texthint); + expect(Ok, status); ok(defTexthint == texthint, "Expected Text Hint to be restored to %d, got %d\n", defTexthint, texthint);
/* test world transform */ @@ -722,7 +724,8 @@ static void test_BeginContainer2(void)
status = GdipCreateMatrix2(10, 20, 30, 40, 50, 60, &transform); expect(Ok, status); - GdipSetWorldTransform(graphics, transform); + status = GdipSetWorldTransform(graphics, transform); + expect(Ok, status); GdipDeleteMatrix(transform); transform = NULL;
@@ -731,7 +734,8 @@ static void test_BeginContainer2(void)
status = GdipCreateMatrix(&transform); expect(Ok, status); - GdipGetWorldTransform(graphics, transform); + status = GdipGetWorldTransform(graphics, transform); + expect(Ok, status); status = GdipGetMatrixElements(transform, elems); expect(Ok, status); ok(fabs(defTrans[0] - elems[0]) < 0.0001 && @@ -753,12 +757,14 @@ static void test_BeginContainer2(void) status = GdipBeginContainer2(graphics, &cont1); expect(Ok, status);
- GdipSetClipRect(graphics, defClip[0], defClip[1], defClip[2], defClip[3], CombineModeReplace); + status = GdipSetClipRect(graphics, defClip[0], defClip[1], defClip[2], defClip[3], CombineModeReplace); + expect(Ok, status);
status = GdipBeginContainer2(graphics, &cont2); expect(Ok, status);
- GdipSetClipRect(graphics, 2, 4, 6, 8, CombineModeReplace); + status = GdipSetClipRect(graphics, 2, 4, 6, 8, CombineModeReplace); + expect(Ok, status);
status = GdipEndContainer(graphics, cont2); expect(Ok, status); @@ -6572,12 +6578,18 @@ static void test_GdipFillRectanglesOnBitmapTextureBrush(void) GdipDeleteBrush((GpBrush*)brush); GdipDeleteGraphics(graphics);
- GdipBitmapGetPixel(dst_img.bitmap, 0, 0, &color[0]); - GdipBitmapGetPixel(dst_img.bitmap, 0, 1, &color[1]); - GdipBitmapGetPixel(dst_img.bitmap, 1, 0, &color[2]); - GdipBitmapGetPixel(dst_img.bitmap, width/2, 0, &color[3]); - GdipBitmapGetPixel(dst_img.bitmap, width/2, height/2, &color[4]); - GdipBitmapGetPixel(dst_img.bitmap, 0, height/2, &color[5]); + status = GdipBitmapGetPixel(dst_img.bitmap, 0, 0, &color[0]); + expect(Ok, status); + status = GdipBitmapGetPixel(dst_img.bitmap, 0, 1, &color[1]); + expect(Ok, status); + status = GdipBitmapGetPixel(dst_img.bitmap, 1, 0, &color[2]); + expect(Ok, status); + status = GdipBitmapGetPixel(dst_img.bitmap, width/2, 0, &color[3]); + expect(Ok, status); + status = GdipBitmapGetPixel(dst_img.bitmap, width/2, height/2, &color[4]); + expect(Ok, status); + status = GdipBitmapGetPixel(dst_img.bitmap, 0, height/2, &color[5]); + expect(Ok, status);
ok(is_blue_color(color[0]) && is_blue_color(color[1]) && is_blue_color(color[2]) && color[3] == 0 && color[4] == 0 && color[5] == 0, diff --git a/modules/rostests/winetests/gdiplus/image.c b/modules/rostests/winetests/gdiplus/image.c index 516e7129a6..1ad24cc88a 100644 --- a/modules/rostests/winetests/gdiplus/image.c +++ b/modules/rostests/winetests/gdiplus/image.c @@ -2736,7 +2736,7 @@ static void test_multiframegif(void) expect(Ok, stat);
color = 0xdeadbeef; - GdipBitmapGetPixel(bmp, 0, 0, &color); + stat = GdipBitmapGetPixel(bmp, 0, 0, &color); expect(Ok, stat); expect(0xff000000, color);
@@ -3236,7 +3236,7 @@ static LONG obj_refcount(void *obj) return IUnknown_Release((IUnknown *)obj); }
-static GpImage *load_image(const BYTE *image_data, UINT image_size) +static GpImage *load_image(const BYTE *image_data, UINT image_size, BOOL valid_data, BOOL todo_load) { IStream *stream; HGLOBAL hmem; @@ -3260,6 +3260,12 @@ static GpImage *load_image(const BYTE *image_data, UINT image_size) ok(refcount == 1, "expected stream refcount 1, got %d\n", refcount);
status = GdipLoadImageFromStream(stream, &image); + todo_wine_if(todo_load) + if (valid_data) + ok(status == Ok || broken(status == InvalidParameter), /* XP */ + "GdipLoadImageFromStream error %d\n", status); + else + ok(status != Ok, "GdipLoadImageFromStream should fail\n"); if (status != Ok) { IStream_Release(stream); @@ -3330,7 +3336,7 @@ static void test_image_properties(void)
for (i = 0; i < ARRAY_SIZE(td); i++) { - image = load_image(td[i].image_data, td[i].image_size); + image = load_image(td[i].image_data, td[i].image_size, TRUE, FALSE); if (!image) { trace("%u: failed to load image data\n", i); @@ -3623,7 +3629,7 @@ static void test_tiff_properties(void) PROPID *prop_id; PropertyItem *prop_item;
- image = load_image((const BYTE *)&TIFF_data, sizeof(TIFF_data)); + image = load_image((const BYTE *)&TIFF_data, sizeof(TIFF_data), TRUE, FALSE); if (!image) { win_skip("Failed to load TIFF image data. Might not be supported. Skipping.\n"); @@ -3735,7 +3741,7 @@ static void test_GdipGetAllPropertyItems(void) PropertyItem *prop_item; const char *item_data;
- image = load_image(tiffimage, sizeof(tiffimage)); + image = load_image(tiffimage, sizeof(tiffimage), TRUE, FALSE); ok(image != 0, "Failed to load TIFF image data\n"); if (!image) return;
@@ -3883,7 +3889,7 @@ static void test_tiff_palette(void) ARGB *entries = palette.pal.Entries;
/* 1bpp TIFF without palette */ - image = load_image((const BYTE *)&TIFF_data, sizeof(TIFF_data)); + image = load_image((const BYTE *)&TIFF_data, sizeof(TIFF_data), TRUE, FALSE); if (!image) { win_skip("Failed to load TIFF image data. Might not be supported. Skipping.\n"); @@ -4534,7 +4540,7 @@ static void test_gif_properties(void) PropertyItem *prop_item; const char *item_data;
- image = load_image(animatedgif, sizeof(animatedgif)); + image = load_image(animatedgif, sizeof(animatedgif), TRUE, FALSE); if (!image) /* XP fails to load this GIF image */ { trace("Failed to load GIF image data\n"); @@ -5116,65 +5122,208 @@ static void test_imageabort(void) static const char png_1x1_data[] = { 0x89,'P','N','G',0x0d,0x0a,0x1a,0x0a, 0x00,0x00,0x00,0x0d,'I','H','D','R',0x00,0x00,0x00,0x01,0x00,0x00,0x00,0x01,0x08,0x02,0x00,0x00,0x00,0x90,0x77,0x53,0xde, + 0x00,0x00,0x03,0x00,'P','L','T','E', + 0x01,0x01,0x01,0x02,0x02,0x02,0x03,0x03,0x03,0x04,0x04,0x04,0x05,0x05,0x05,0x06,0x06,0x06,0x07,0x07,0x07,0x08,0x08,0x08, + 0x09,0x09,0x09,0x0a,0x0a,0x0a,0x0b,0x0b,0x0b,0x0c,0x0c,0x0c,0x0d,0x0d,0x0d,0x0e,0x0e,0x0e,0x0f,0x0f,0x0f,0x10,0x10,0x10, + 0x11,0x11,0x11,0x12,0x12,0x12,0x13,0x13,0x13,0x14,0x14,0x14,0x15,0x15,0x15,0x16,0x16,0x16,0x17,0x17,0x17,0x18,0x18,0x18, + 0x19,0x19,0x19,0x1a,0x1a,0x1a,0x1b,0x1b,0x1b,0x1c,0x1c,0x1c,0x1d,0x1d,0x1d,0x1e,0x1e,0x1e,0x1f,0x1f,0x1f,0x20,0x20,0x20, + 0x21,0x21,0x21,0x22,0x22,0x22,0x23,0x23,0x23,0x24,0x24,0x24,0x25,0x25,0x25,0x26,0x26,0x26,0x27,0x27,0x27,0x28,0x28,0x28, + 0x29,0x29,0x29,0x2a,0x2a,0x2a,0x2b,0x2b,0x2b,0x2c,0x2c,0x2c,0x2d,0x2d,0x2d,0x2e,0x2e,0x2e,0x2f,0x2f,0x2f,0x30,0x30,0x30, + 0x31,0x31,0x31,0x32,0x32,0x32,0x33,0x33,0x33,0x34,0x34,0x34,0x35,0x35,0x35,0x36,0x36,0x36,0x37,0x37,0x37,0x38,0x38,0x38, + 0x39,0x39,0x39,0x3a,0x3a,0x3a,0x3b,0x3b,0x3b,0x3c,0x3c,0x3c,0x3d,0x3d,0x3d,0x3e,0x3e,0x3e,0x3f,0x3f,0x3f,0x40,0x40,0x40, + 0x41,0x41,0x41,0x42,0x42,0x42,0x43,0x43,0x43,0x44,0x44,0x44,0x45,0x45,0x45,0x46,0x46,0x46,0x47,0x47,0x47,0x48,0x48,0x48, + 0x49,0x49,0x49,0x4a,0x4a,0x4a,0x4b,0x4b,0x4b,0x4c,0x4c,0x4c,0x4d,0x4d,0x4d,0x4e,0x4e,0x4e,0x4f,0x4f,0x4f,0x50,0x50,0x50, + 0x51,0x51,0x51,0x52,0x52,0x52,0x53,0x53,0x53,0x54,0x54,0x54,0x55,0x55,0x55,0x56,0x56,0x56,0x57,0x57,0x57,0x58,0x58,0x58, + 0x59,0x59,0x59,0x5a,0x5a,0x5a,0x5b,0x5b,0x5b,0x5c,0x5c,0x5c,0x5d,0x5d,0x5d,0x5e,0x5e,0x5e,0x5f,0x5f,0x5f,0x60,0x60,0x60, + 0x61,0x61,0x61,0x62,0x62,0x62,0x63,0x63,0x63,0x64,0x64,0x64,0x65,0x65,0x65,0x66,0x66,0x66,0x67,0x67,0x67,0x68,0x68,0x68, + 0x69,0x69,0x69,0x6a,0x6a,0x6a,0x6b,0x6b,0x6b,0x6c,0x6c,0x6c,0x6d,0x6d,0x6d,0x6e,0x6e,0x6e,0x6f,0x6f,0x6f,0x70,0x70,0x70, + 0x71,0x71,0x71,0x72,0x72,0x72,0x73,0x73,0x73,0x74,0x74,0x74,0x75,0x75,0x75,0x76,0x76,0x76,0x77,0x77,0x77,0x78,0x78,0x78, + 0x79,0x79,0x79,0x7a,0x7a,0x7a,0x7b,0x7b,0x7b,0x7c,0x7c,0x7c,0x7d,0x7d,0x7d,0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x80,0x80,0x80, + 0x01,0x01,0x01,0x02,0x02,0x02,0x03,0x03,0x03,0x04,0x04,0x04,0x05,0x05,0x05,0x06,0x06,0x06,0x07,0x07,0x07,0x08,0x08,0x08, + 0x09,0x09,0x09,0x0a,0x0a,0x0a,0x0b,0x0b,0x0b,0x0c,0x0c,0x0c,0x0d,0x0d,0x0d,0x0e,0x0e,0x0e,0x0f,0x0f,0x0f,0x10,0x10,0x10, + 0x11,0x11,0x11,0x12,0x12,0x12,0x13,0x13,0x13,0x14,0x14,0x14,0x15,0x15,0x15,0x16,0x16,0x16,0x17,0x17,0x17,0x18,0x18,0x18, + 0x19,0x19,0x19,0x1a,0x1a,0x1a,0x1b,0x1b,0x1b,0x1c,0x1c,0x1c,0x1d,0x1d,0x1d,0x1e,0x1e,0x1e,0x1f,0x1f,0x1f,0x20,0x20,0x20, + 0x21,0x21,0x21,0x22,0x22,0x22,0x23,0x23,0x23,0x24,0x24,0x24,0x25,0x25,0x25,0x26,0x26,0x26,0x27,0x27,0x27,0x28,0x28,0x28, + 0x29,0x29,0x29,0x2a,0x2a,0x2a,0x2b,0x2b,0x2b,0x2c,0x2c,0x2c,0x2d,0x2d,0x2d,0x2e,0x2e,0x2e,0x2f,0x2f,0x2f,0x30,0x30,0x30, + 0x31,0x31,0x31,0x32,0x32,0x32,0x33,0x33,0x33,0x34,0x34,0x34,0x35,0x35,0x35,0x36,0x36,0x36,0x37,0x37,0x37,0x38,0x38,0x38, + 0x39,0x39,0x39,0x3a,0x3a,0x3a,0x3b,0x3b,0x3b,0x3c,0x3c,0x3c,0x3d,0x3d,0x3d,0x3e,0x3e,0x3e,0x3f,0x3f,0x3f,0x40,0x40,0x40, + 0x41,0x41,0x41,0x42,0x42,0x42,0x43,0x43,0x43,0x44,0x44,0x44,0x45,0x45,0x45,0x46,0x46,0x46,0x47,0x47,0x47,0x48,0x48,0x48, + 0x49,0x49,0x49,0x4a,0x4a,0x4a,0x4b,0x4b,0x4b,0x4c,0x4c,0x4c,0x4d,0x4d,0x4d,0x4e,0x4e,0x4e,0x4f,0x4f,0x4f,0x50,0x50,0x50, + 0x51,0x51,0x51,0x52,0x52,0x52,0x53,0x53,0x53,0x54,0x54,0x54,0x55,0x55,0x55,0x56,0x56,0x56,0x57,0x57,0x57,0x58,0x58,0x58, + 0x59,0x59,0x59,0x5a,0x5a,0x5a,0x5b,0x5b,0x5b,0x5c,0x5c,0x5c,0x5d,0x5d,0x5d,0x5e,0x5e,0x5e,0x5f,0x5f,0x5f,0x60,0x60,0x60, + 0x61,0x61,0x61,0x62,0x62,0x62,0x63,0x63,0x63,0x64,0x64,0x64,0x65,0x65,0x65,0x66,0x66,0x66,0x67,0x67,0x67,0x68,0x68,0x68, + 0x69,0x69,0x69,0x6a,0x6a,0x6a,0x6b,0x6b,0x6b,0x6c,0x6c,0x6c,0x6d,0x6d,0x6d,0x6e,0x6e,0x6e,0x6f,0x6f,0x6f,0x70,0x70,0x70, + 0x71,0x71,0x71,0x72,0x72,0x72,0x73,0x73,0x73,0x74,0x74,0x74,0x75,0x75,0x75,0x76,0x76,0x76,0x77,0x77,0x77,0x78,0x78,0x78, + 0x79,0x79,0x79,0x7a,0x7a,0x7a,0x7b,0x7b,0x7b,0x7c,0x7c,0x7c,0x7d,0x7d,0x7d,0x7e,0x7e,0x7e,0x7f,0x7f,0x7f,0x80,0x80,0x80, + 0x76,0xb6,0x24,0x31, + 0x00,0x00,0x00,0x02,'t','R','N','S',0xff,0x00,0xe5,0xb7,0x30,0x4a, 0x00,0x00,0x00,0x0c,'I','D','A','T',0x08,0xd7,0x63,0xf8,0xff,0xff,0x3f,0x00,0x05,0xfe,0x02,0xfe,0xdc,0xcc,0x59,0xe7, 0x00,0x00,0x00,0x00,'I','E','N','D',0xae,0x42,0x60,0x82 };
+#define PNG_COLOR_TYPE_GRAY 0 +#define PNG_COLOR_TYPE_RGB 2 +#define PNG_COLOR_TYPE_PALETTE 3 +#define PNG_COLOR_TYPE_GRAY_ALPHA 4 +#define PNG_COLOR_TYPE_RGB_ALPHA 6 + static void test_png_color_formats(void) { static const struct { char bit_depth, color_type; - PixelFormat format; - UINT flags; + struct { + PixelFormat format; + ImageFlags flags; + BOOL todo; + BOOL todo_load; + } t[3]; } td[] = { - /* 2 - PNG_COLOR_TYPE_RGB */ - { 8, 2, PixelFormat24bppRGB, ImageFlagsColorSpaceRGB }, - /* 0 - PNG_COLOR_TYPE_GRAY */ - { 1, 0, PixelFormat1bppIndexed, ImageFlagsColorSpaceRGB }, - { 2, 0, PixelFormat32bppARGB, ImageFlagsColorSpaceGRAY }, - { 4, 0, PixelFormat32bppARGB, ImageFlagsColorSpaceGRAY }, - { 8, 0, PixelFormat32bppARGB, ImageFlagsColorSpaceGRAY }, - { 16, 0, PixelFormat32bppARGB, ImageFlagsColorSpaceGRAY }, + /* 0 */ + { 1, PNG_COLOR_TYPE_RGB }, + { 2, PNG_COLOR_TYPE_RGB }, + { 4, PNG_COLOR_TYPE_RGB }, + { 8, PNG_COLOR_TYPE_RGB, + {{ PixelFormat32bppARGB, ImageFlagsColorSpaceRGB }, + { PixelFormat24bppRGB, ImageFlagsColorSpaceRGB }, + { PixelFormat24bppRGB, ImageFlagsColorSpaceRGB }}}, + /* libpng refuses to load our test image complaining about extra compressed data, + * but libpng is still able to load the image with other combination of type/depth + * making RGB 16 bpp case special for some reason. Therefore todo = TRUE. + */ + { 16, PNG_COLOR_TYPE_RGB, + {{ PixelFormat32bppARGB, ImageFlagsColorSpaceRGB, TRUE, TRUE }, + { PixelFormat32bppARGB, ImageFlagsColorSpaceRGB, TRUE, TRUE }, + { PixelFormat32bppARGB, ImageFlagsColorSpaceRGB, TRUE, TRUE }}}, + + /* 5 */ + { 1, PNG_COLOR_TYPE_GRAY, + {{ PixelFormat32bppARGB, ImageFlagsColorSpaceRGB }, + { PixelFormat1bppIndexed, ImageFlagsColorSpaceRGB }, + { PixelFormat1bppIndexed, ImageFlagsColorSpaceRGB }}}, + { 2, PNG_COLOR_TYPE_GRAY, + {{ PixelFormat32bppARGB, ImageFlagsColorSpaceRGB }, + { PixelFormat32bppARGB, ImageFlagsColorSpaceGRAY }, + { PixelFormat32bppARGB, ImageFlagsColorSpaceGRAY }}}, + { 4, PNG_COLOR_TYPE_GRAY, + {{ PixelFormat32bppARGB, ImageFlagsColorSpaceRGB }, + { PixelFormat32bppARGB, ImageFlagsColorSpaceGRAY }, + { PixelFormat32bppARGB, ImageFlagsColorSpaceGRAY }}}, + { 8, PNG_COLOR_TYPE_GRAY, + {{ PixelFormat32bppARGB, ImageFlagsColorSpaceRGB }, + { PixelFormat32bppARGB, ImageFlagsColorSpaceGRAY }, + { PixelFormat32bppARGB, ImageFlagsColorSpaceGRAY }}}, + { 16, PNG_COLOR_TYPE_GRAY, + {{ PixelFormat32bppARGB, ImageFlagsColorSpaceRGB }, + { PixelFormat32bppARGB, ImageFlagsColorSpaceGRAY }, + { PixelFormat32bppARGB, ImageFlagsColorSpaceGRAY }}}, + + /* 10 */ + { 1, PNG_COLOR_TYPE_PALETTE, + {{ PixelFormat32bppARGB, ImageFlagsColorSpaceRGB }, + { PixelFormat1bppIndexed, ImageFlagsColorSpaceRGB }, + { 0, 0 }}}, + { 2, PNG_COLOR_TYPE_PALETTE, + {{ PixelFormat32bppARGB, ImageFlagsColorSpaceRGB }, + { PixelFormat32bppARGB, ImageFlagsColorSpaceRGB }, + { 0, 0 }}}, + { 4, PNG_COLOR_TYPE_PALETTE, + {{ PixelFormat32bppARGB, ImageFlagsColorSpaceRGB }, + { PixelFormat4bppIndexed, ImageFlagsColorSpaceRGB }, + { 0, 0 }}}, + { 8, PNG_COLOR_TYPE_PALETTE, + {{ PixelFormat32bppARGB, ImageFlagsColorSpaceRGB }, + { PixelFormat8bppIndexed, ImageFlagsColorSpaceRGB }, + { 0, 0 }}}, + { 16, PNG_COLOR_TYPE_PALETTE }, }; BYTE buf[sizeof(png_1x1_data)]; GpStatus status; GpImage *image; ImageType type; PixelFormat format; - UINT flags; - int i; + ImageFlags flags; + BOOL valid; + int i, j, PLTE_off = 0, tRNS_off = 0; + const ImageFlags color_space_mask = ImageFlagsColorSpaceRGB | ImageFlagsColorSpaceCMYK | ImageFlagsColorSpaceGRAY | ImageFlagsColorSpaceYCBCR | ImageFlagsColorSpaceYCCK; + + memcpy(buf, png_1x1_data, sizeof(png_1x1_data)); + buf[24] = 2; + buf[25] = PNG_COLOR_TYPE_PALETTE; + image = load_image(buf, sizeof(buf), TRUE, FALSE); + status = GdipGetImageFlags(image, &flags); + expect(status, Ok); + ok((flags & color_space_mask) == ImageFlagsColorSpaceRGB || broken(flags == 0x12006) /* before win7 */, + "flags = %#x\n", flags); + if ((flags & color_space_mask) != ImageFlagsColorSpaceRGB) { + GdipDisposeImage(image); + win_skip("broken PNG color space support\n"); + return; + } + GdipDisposeImage(image);
- for (i = 0; i < ARRAY_SIZE(td); i++) + for (i = 0; i < sizeof(png_1x1_data) - 4; i++) { - memcpy(buf, png_1x1_data, sizeof(png_1x1_data)); - buf[24] = td[i].bit_depth; - buf[25] = td[i].color_type; + if (!memcmp(buf + i, "tRNS", 4)) + tRNS_off = i; + else if (!memcmp(buf + i, "PLTE", 4)) + PLTE_off = i; + }
- image = load_image(buf, sizeof(buf)); - ok(image != NULL, "%d: failed to load image data\n", i); - if (!image) continue; + ok(PLTE_off && tRNS_off, "PLTE offset %d, tRNS offset %d\n", PLTE_off, tRNS_off); + if (!PLTE_off || !tRNS_off) return;
- status = GdipGetImageType(image, &type); - ok(status == Ok, "%u: GdipGetImageType error %d\n", i, status); - ok(type == ImageTypeBitmap, "%d: wrong image type %d\n", i, type); + /* In order to test the image data with and without PLTE and tRNS + * chunks, we mask the chunk name with private one (tEST). + */
- status = GdipGetImagePixelFormat(image, &format); - expect(Ok, status); - ok(format == td[i].format || - broken(td[i].bit_depth == 1 && td[i].color_type == 0 && format == PixelFormat32bppARGB), /* XP */ - "%d: expected %#x, got %#x\n", i, td[i].format, format); + for (i = 0; i < ARRAY_SIZE(td); i++) + { + for (j = 0; j < 3; j++) + { + memcpy(buf, png_1x1_data, sizeof(png_1x1_data)); + buf[24] = td[i].bit_depth; + buf[25] = td[i].color_type; + if (j >=1) memcpy(buf + tRNS_off, "tEST", 4); + if (j >=2) memcpy(buf + PLTE_off, "tEST", 4); + + valid = (td[i].t[j].format != 0) || (td[i].t[j].flags != 0); + image = load_image(buf, sizeof(buf), valid, td[i].t[j].todo_load); + todo_wine_if(td[i].t[j].todo_load) + if (valid) + ok(image != NULL, "%d %d: failed to load image data\n", i, j); + else + { + ok(image == NULL, "%d %d: succeed to load image data\n", i, j); + if (image) GdipDisposeImage(image); + image = NULL; + } + if (!image) continue;
- status = GdipGetImageFlags(image, &flags); - expect(Ok, status); - ok((flags & td[i].flags) == td[i].flags || - broken(td[i].bit_depth == 1 && td[i].color_type == 0 && (flags & ImageFlagsColorSpaceGRAY)), /* XP */ - "%d: expected %#x, got %#x\n", i, td[i].flags, flags); + status = GdipGetImageType(image, &type); + ok(status == Ok, "%d %d: GdipGetImageType error %d\n", i, j, status); + ok(type == ImageTypeBitmap, "%d %d: wrong image type %d\n", i, j, type);
- GdipDisposeImage(image); + status = GdipGetImagePixelFormat(image, &format); + expect(Ok, status); + todo_wine_if(td[i].t[j].todo) + ok(format == td[i].t[j].format, + "%d %d: expected %#x, got %#x\n", i, j, td[i].t[j].format, format); + + status = GdipGetImageFlags(image, &flags); + expect(Ok, status); + ok((flags & color_space_mask) == td[i].t[j].flags, + "%d %d: expected %#x, got %#x\n", i, j, td[i].t[j].flags, flags); + GdipDisposeImage(image); + } } } +#undef PNG_COLOR_TYPE_GRAY +#undef PNG_COLOR_TYPE_RGB +#undef PNG_COLOR_TYPE_PALETTE +#undef PNG_COLOR_TYPE_GRAY_ALPHA +#undef PNG_COLOR_TYPE_RGB_ALPHA
static void test_GdipLoadImageFromStream(void) { @@ -5508,7 +5657,7 @@ static void test_tiff_color_formats(void) continue; }
- image = load_image(buf, sizeof(buf)); + image = load_image(buf, sizeof(buf), TRUE, FALSE); if (!td[i].format) ok(!image, "%u: (%d,%d,%d) TIFF image loading should have failed\n", i, td[i].photometric, td[i].samples, td[i].bps); diff --git a/modules/rostests/winetests/gdiplus/pen.c b/modules/rostests/winetests/gdiplus/pen.c index be3d76d655..ceab92acff 100644 --- a/modules/rostests/winetests/gdiplus/pen.c +++ b/modules/rostests/winetests/gdiplus/pen.c @@ -389,6 +389,22 @@ todo_wine { GdipDeletePen(pen); }
+static void get_pen_transform(GpPen *pen, REAL *values) +{ + GpMatrix *matrix; + GpStatus status; + + status = GdipCreateMatrix(&matrix); + expect(Ok, status); + + status = GdipGetPenTransform(pen, matrix); + expect(Ok, status); + status = GdipGetMatrixElements(matrix, values); + expect(Ok, status); + + GdipDeleteMatrix(matrix); +} + static void test_transform(void) { GpStatus status; @@ -478,6 +494,138 @@ static void test_transform(void) expectf(0.0, values[4]); expectf(0.0, values[5]);
+ /* Scale */ + status = GdipScalePenTransform(NULL, 1.0, 1.0, MatrixOrderPrepend); + expect(InvalidParameter, status); + + status = GdipScalePenTransform(pen, 1.0, 1.0, MatrixOrderPrepend); + expect(Ok, status); + + get_pen_transform(pen, values); + expectf(1.0, values[0]); + expectf(0.0, values[1]); + expectf(0.0, values[2]); + expectf(1.0, values[3]); + expectf(0.0, values[4]); + expectf(0.0, values[5]); + + status = GdipScalePenTransform(pen, 2.0, -10.0, MatrixOrderPrepend); + expect(Ok, status); + + get_pen_transform(pen, values); + expectf(2.0, values[0]); + expectf(0.0, values[1]); + expectf(0.0, values[2]); + expectf(-10.0, values[3]); + expectf(0.0, values[4]); + expectf(0.0, values[5]); + + status = GdipScalePenTransform(pen, 2.0, -10.0, MatrixOrderAppend); + expect(Ok, status); + + get_pen_transform(pen, values); + expectf(4.0, values[0]); + expectf(0.0, values[1]); + expectf(0.0, values[2]); + expectf(100.0, values[3]); + expectf(0.0, values[4]); + expectf(0.0, values[5]); + + status = GdipTranslatePenTransform(pen, 1.0, -2.0, MatrixOrderAppend); + expect(Ok, status); + + get_pen_transform(pen, values); + expectf(4.0, values[0]); + expectf(0.0, values[1]); + expectf(0.0, values[2]); + expectf(100.0, values[3]); + expectf(1.0, values[4]); + expectf(-2.0, values[5]); + + status = GdipScalePenTransform(pen, 2.0, -10.0, MatrixOrderPrepend); + expect(Ok, status); + + get_pen_transform(pen, values); + expectf(8.0, values[0]); + expectf(0.0, values[1]); + expectf(0.0, values[2]); + expectf(-1000.0, values[3]); + expectf(1.0, values[4]); + expectf(-2.0, values[5]); + + /* Multiply */ + status = GdipResetPenTransform(pen); + expect(Ok, status); + + status = GdipSetMatrixElements(matrix, 2.0, 1.0, 1.0, 4.0, 1.0, 2.0); + expect(Ok, status); + + status = GdipMultiplyPenTransform(NULL, matrix, MatrixOrderPrepend); + expect(InvalidParameter, status); + + status = GdipMultiplyPenTransform(pen, matrix, MatrixOrderPrepend); + expect(Ok, status); + + get_pen_transform(pen, values); + expectf(2.0, values[0]); + expectf(1.0, values[1]); + expectf(1.0, values[2]); + expectf(4.0, values[3]); + expectf(1.0, values[4]); + expectf(2.0, values[5]); + + status = GdipScalePenTransform(pen, 2.0, -10.0, MatrixOrderAppend); + expect(Ok, status); + + status = GdipMultiplyPenTransform(pen, matrix, MatrixOrderAppend); + expect(Ok, status); + + get_pen_transform(pen, values); + expectf(-2.0, values[0]); + expectf(-36.0, values[1]); + expectf(-36.0, values[2]); + expectf(-158.0, values[3]); + expectf(-15.0, values[4]); + expectf(-76.0, values[5]); + + /* Rotate */ + status = GdipResetPenTransform(pen); + expect(Ok, status); + + status = GdipSetMatrixElements(matrix, 2.0, 1.0, 1.0, 4.0, 1.0, 2.0); + expect(Ok, status); + + status = GdipSetPenTransform(pen, matrix); + expect(Ok, status); + + status = GdipRotatePenTransform(NULL, 10.0, MatrixOrderPrepend); + expect(InvalidParameter, status); + + status = GdipRotatePenTransform(pen, 45.0, MatrixOrderPrepend); + expect(Ok, status); + + get_pen_transform(pen, values); + expectf(2.12, values[0]); + expectf(3.54, values[1]); + expectf(-0.71, values[2]); + expectf(2.12, values[3]); + expectf(1.0, values[4]); + expectf(2.0, values[5]); + + status = GdipScalePenTransform(pen, 2.0, -10.0, MatrixOrderAppend); + expect(Ok, status); + + status = GdipRotatePenTransform(pen, 180.0, MatrixOrderAppend); + expect(Ok, status); + + get_pen_transform(pen, values); + expectf(-4.24, values[0]); + expectf(35.36, values[1]); + expectf(1.41, values[2]); + expectf(21.21, values[3]); + expectf(-2.0, values[4]); + expectf(20.0, values[5]); + GdipDeletePen(pen);
GdipDeleteMatrix(matrix); diff --git a/modules/rostests/winetests/gdiplus/region.c b/modules/rostests/winetests/gdiplus/region.c index c2cbff01f6..d69f09db60 100644 --- a/modules/rostests/winetests/gdiplus/region.c +++ b/modules/rostests/winetests/gdiplus/region.c @@ -814,7 +814,8 @@ static void test_isinfinite(void)
status = GdipCreateFromHDC(hdc, &graphics); expect(Ok, status); - GdipCreateRegion(®ion); + status = GdipCreateRegion(®ion); + expect(Ok, status);
GdipCreateMatrix2(3.0, 0.0, 0.0, 1.0, 20.0, 30.0, &m);
@@ -860,7 +861,8 @@ static void test_isempty(void)
status = GdipCreateFromHDC(hdc, &graphics); expect(Ok, status); - GdipCreateRegion(®ion); + status = GdipCreateRegion(®ion); + expect(Ok, status);
/* NULL arguments */ status = GdipIsEmptyRegion(NULL, NULL, NULL); @@ -1779,7 +1781,8 @@ static void test_getbounds(void) ok(rectf.Height == 100.0, "Expected height = 0.0, got %.2f\n", rectf.Height);
/* the world and page transforms are ignored */ - GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend); + status = GdipScaleWorldTransform(graphics, 2.0, 2.0, MatrixOrderPrepend); + ok(status == Ok, "status %08x\n", status); GdipSetPageUnit(graphics, UnitInch); GdipSetPageScale(graphics, 2.0); status = GdipGetRegionBounds(region, graphics, &rectf);