Commit dc3908a3 authored by Nikolay Sivov's avatar Nikolay Sivov Committed by Alexandre Julliard

gdiplus: Implemented GdipGetRegionBounds/GdipGetRegionBoundsI.

parent cb8f4eb1
......@@ -634,18 +634,66 @@ GpStatus WINGDIPAPI GdipDeleteRegion(GpRegion *region)
return Ok;
}
/*****************************************************************************
* GdipGetRegionBounds [GDIPLUS.@]
*/
GpStatus WINGDIPAPI GdipGetRegionBounds(GpRegion *region, GpGraphics *graphics, GpRectF *rect)
{
FIXME("(%p, %p, %p): stub\n", region, graphics, rect);
HRGN hrgn;
RECT r;
GpStatus status;
return NotImplemented;
TRACE("(%p, %p, %p)\n", region, graphics, rect);
if(!region || !graphics || !rect)
return InvalidParameter;
status = GdipGetRegionHRgn(region, graphics, &hrgn);
if(status != Ok)
return status;
/* infinite */
if(!hrgn){
rect->X = rect->Y = -(REAL)(1 << 22);
rect->Width = rect->Height = (REAL)(1 << 23);
return Ok;
}
if(!GetRgnBox(hrgn, &r)){
DeleteObject(hrgn);
return GenericError;
}
rect->X = r.left;
rect->Y = r.top;
rect->Width = r.right - r.left;
rect->Height = r.bottom - r.top;
return Ok;
}
/*****************************************************************************
* GdipGetRegionBoundsI [GDIPLUS.@]
*/
GpStatus WINGDIPAPI GdipGetRegionBoundsI(GpRegion *region, GpGraphics *graphics, GpRect *rect)
{
FIXME("(%p, %p, %p): stub\n", region, graphics, rect);
GpRectF rectf;
GpStatus status;
return NotImplemented;
TRACE("(%p, %p, %p)\n", region, graphics, rect);
if(!rect)
return InvalidParameter;
status = GdipGetRegionBounds(region, graphics, &rectf);
if(status == Ok){
rect->X = roundr(rectf.X);
rect->Y = roundr(rectf.X);
rect->Width = roundr(rectf.Width);
rect->Height = roundr(rectf.Height);
}
return status;
}
static inline void write_dword(DWORD* location, INT* offset, const DWORD write)
......
......@@ -1120,6 +1120,67 @@ static void test_translate(void)
ReleaseDC(0, hdc);
}
static void test_getbounds(void)
{
GpRegion *region;
GpGraphics *graphics;
GpStatus status;
GpRectF rectf;
HDC hdc = GetDC(0);
status = GdipCreateFromHDC(hdc, &graphics);
ok(status == Ok, "status %08x\n", status);
status = GdipCreateRegion(&region);
ok(status == Ok, "status %08x\n", status);
/* NULL */
status = GdipGetRegionBounds(NULL, NULL, NULL);
ok(status == InvalidParameter, "status %08x\n", status);
status = GdipGetRegionBounds(region, NULL, NULL);
ok(status == InvalidParameter, "status %08x\n", status);
status = GdipGetRegionBounds(region, graphics, NULL);
ok(status == InvalidParameter, "status %08x\n", status);
/* infinite */
rectf.X = rectf.Y = 0.0;
rectf.Height = rectf.Width = 100.0;
status = GdipGetRegionBounds(region, graphics, &rectf);
ok(status == Ok, "status %08x\n", status);
ok(rectf.X == -(REAL)(1 << 22), "Expected X = %.2f, got %.2f\n", -(REAL)(1 << 22), rectf.X);
ok(rectf.Y == -(REAL)(1 << 22), "Expected Y = %.2f, got %.2f\n", -(REAL)(1 << 22), rectf.Y);
ok(rectf.Width == (REAL)(1 << 23), "Expected width = %.2f, got %.2f\n", (REAL)(1 << 23), rectf.Width);
ok(rectf.Height == (REAL)(1 << 23), "Expected height = %.2f, got %.2f\n",(REAL)(1 << 23), rectf.Height);
/* empty */
rectf.X = rectf.Y = 0.0;
rectf.Height = rectf.Width = 100.0;
status = GdipSetEmpty(region);
ok(status == Ok, "status %08x\n", status);
status = GdipGetRegionBounds(region, graphics, &rectf);
ok(status == Ok, "status %08x\n", status);
ok(rectf.X == 0.0, "Expected X = 0.0, got %.2f\n", rectf.X);
ok(rectf.Y == 0.0, "Expected Y = 0.0, got %.2f\n", rectf.Y);
ok(rectf.Width == 0.0, "Expected width = 0.0, got %.2f\n", rectf.Width);
ok(rectf.Height == 0.0, "Expected height = 0.0, got %.2f\n", rectf.Height);
/* rect */
rectf.X = 10.0; rectf.Y = 0.0;
rectf.Width = rectf.Height = 100.0;
status = GdipCombineRegionRect(region, &rectf, CombineModeReplace);
ok(status == Ok, "status %08x\n", status);
rectf.X = rectf.Y = 0.0;
rectf.Height = rectf.Width = 0.0;
status = GdipGetRegionBounds(region, graphics, &rectf);
ok(status == Ok, "status %08x\n", status);
ok(rectf.X == 10.0, "Expected X = 0.0, got %.2f\n", rectf.X);
ok(rectf.Y == 0.0, "Expected Y = 0.0, got %.2f\n", rectf.Y);
ok(rectf.Width == 100.0, "Expected width = 0.0, got %.2f\n", rectf.Width);
ok(rectf.Height == 100.0, "Expected height = 0.0, got %.2f\n", rectf.Height);
status = GdipDeleteRegion(region);
ok(status == Ok, "status %08x\n", status);
status = GdipDeleteGraphics(graphics);
ok(status == Ok, "status %08x\n", status);
ReleaseDC(0, hdc);
}
START_TEST(region)
{
struct GdiplusStartupInput gdiplusStartupInput;
......@@ -1140,6 +1201,7 @@ START_TEST(region)
test_gethrgn();
test_isequal();
test_translate();
test_getbounds();
GdiplusShutdown(gdiplusToken);
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment