From 73d6e2afd82d55180bf431c667cb6f4a498012b5 Mon Sep 17 00:00:00 2001 From: Vincent Povirk Date: Mon, 24 Nov 2008 16:06:32 -0600 Subject: [PATCH] gdiplus: implement GdipGetRegionHRgn for rects --- dlls/gdiplus/region.c | 18 ++++++++++++++++++ dlls/gdiplus/tests/region.c | 13 +++++++++++++ 2 files changed, 31 insertions(+), 0 deletions(-) diff --git a/dlls/gdiplus/region.c b/dlls/gdiplus/region.c index 5580319..509c7ce 100644 --- a/dlls/gdiplus/region.c +++ b/dlls/gdiplus/region.c @@ -823,6 +823,24 @@ static GpStatus get_region_hrgn(struct region_element *element, GpGraphics *grap return *hrgn ? Ok : OutOfMemory; case RegionDataPath: return get_path_hrgn(element->elementdata.pathdata.path, graphics, hrgn); + case RegionDataRect: + { + GpPath* path; + GpStatus stat; + GpRectF* rc = &element->elementdata.rect; + + stat = GdipCreatePath(FillModeAlternate, &path); + if (stat != Ok) + return stat; + stat = GdipAddPathRectangle(path, rc->X, rc->Y, rc->Width, rc->Height); + + if (stat == Ok) + stat = get_path_hrgn(path, graphics, hrgn); + + GdipDeletePath(path); + + return stat; + } default: FIXME("GdipGetRegionHRgn unimplemented for region type=%x\n", element->type); *hrgn = NULL; diff --git a/dlls/gdiplus/tests/region.c b/dlls/gdiplus/tests/region.c index 45ef0b1..34024be 100644 --- a/dlls/gdiplus/tests/region.c +++ b/dlls/gdiplus/tests/region.c @@ -804,6 +804,7 @@ static void test_gethrgn(void) HDC hdc=GetDC(0); static const RECT empty_rect = {0,0,0,0}; static const RECT test_rect = {10, 11, 20, 21}; + static const GpRectF test_rectF = {10.0, 11.0, 10.0, 10.0}; static const RECT scaled_rect = {20, 22, 40, 42}; status = GdipCreateFromHDC(hdc, &graphics); @@ -854,6 +855,18 @@ static void test_gethrgn(void) verify_region(hrgn, &scaled_rect); DeleteObject(hrgn); + status = GdipCombineRegionRect(region2, &test_rectF, CombineModeReplace); + ok(status == Ok, "status %08x\n", status); + status = GdipGetRegionHRgn(region2, NULL, &hrgn); + ok(status == Ok, "status %08x\n", status); + verify_region(hrgn, &test_rect); + DeleteObject(hrgn); + + status = GdipGetRegionHRgn(region2, graphics, &hrgn); + ok(status == Ok, "status %08x\n", status); + verify_region(hrgn, &scaled_rect); + DeleteObject(hrgn); + status = GdipDeletePath(path); ok(status == Ok, "status %08x\n", status); status = GdipDeleteRegion(region); -- 1.5.6.3