Ejemplo n.º 1
0
GpPath *gdip_create_path(GF_Path *_this)
{
	GpPath *p;
	u32 j, i, nb_pts, cur;
	if (!_this || !_this->n_points) return NULL;
	GdipCreatePath(FillModeAlternate, &p);

	GdipSetPathFillMode(p, (_this->flags & GF_PATH_FILL_ZERO_NONZERO) ? FillModeWinding : FillModeAlternate);

	cur = 0;
	for (i=0; i<_this->n_contours; i++) {
		nb_pts = 1+_this->contours[i] - cur;
		GdipStartPathFigure(p);
		for (j=cur+1; j<cur+nb_pts; ) {
			switch (_this->tags[j]) {
			case GF_PATH_CURVE_ON:
				GdipAddPathLine(p, FIX2FLT(_this->points[j-1].x), FIX2FLT(_this->points[j-1].y), FIX2FLT(_this->points[j].x), FIX2FLT(_this->points[j].y));
				j++;
				break;
			case GF_PATH_CLOSE:
				GdipAddPathLine(p, FIX2FLT(_this->points[j].x), FIX2FLT(_this->points[j].y), FIX2FLT(_this->points[cur].x), FIX2FLT(_this->points[cur].y));
				j++;
				break;
			case GF_PATH_CURVE_CUBIC:
				GdipAddPathBezier(p,
				                  FIX2FLT(_this->points[j-1].x), FIX2FLT(_this->points[j-1].y),
				                  FIX2FLT(_this->points[j].x), FIX2FLT(_this->points[j].y),
				                  FIX2FLT(_this->points[j+1].x), FIX2FLT(_this->points[j+1].y),
				                  FIX2FLT(_this->points[j+2].x), FIX2FLT(_this->points[j+2].y)
				                 );
				j+=3;
				break;
			case GF_PATH_CURVE_CONIC:
			{
				GF_Point2D ctl, end, c1, c2, start;
				start = _this->points[j-1];
				ctl = _this->points[j];
				end = _this->points[j+1];
				c1.x = start.x + 2*(ctl.x - start.x) / 3;
				c1.y = start.y + 2*(ctl.y - start.y) / 3;
				c2.x = c1.x + (end.x - start.x) / 3;
				c2.y = c1.y + (end.y - start.y) / 3;
				GdipAddPathBezier(p,
				                  FIX2FLT(start.x), FIX2FLT(start.y),
				                  FIX2FLT(c1.x), FIX2FLT(c1.y),
				                  FIX2FLT(c2.x), FIX2FLT(c2.y),
				                  FIX2FLT(end.x), FIX2FLT(end.y)
				                 );
				j+=2;
			}
			break;
			}
		}
		GdipClosePathFigure(p);
		cur += nb_pts;
	}
	return p;
}
Ejemplo n.º 2
0
static void test_getpathdata(void)
{
    GpPath *path;
    GpPathData data;
    GpStatus status;
    INT count;

    status = GdipCreatePath(FillModeAlternate, &path);
    expect(Ok, status);
    status = GdipAddPathLine(path, 5.0, 5.0, 100.0, 50.0);
    expect(Ok, status);

    status = GdipGetPointCount(path, &count);
    expect(Ok, status);
    expect(2, count);

    data.Count  = count;
    data.Types  = GdipAlloc(sizeof(BYTE) * count);
    data.Points = GdipAlloc(sizeof(PointF) * count);

    status = GdipGetPathData(path, &data);
    expect(Ok, status);
    expect((data.Points[0].X == 5.0) && (data.Points[0].Y == 5.0) &&
           (data.Points[1].X == 100.0) && (data.Points[1].Y == 50.0), TRUE);
    expect((data.Types[0] == PathPointTypeStart) && (data.Types[1] == PathPointTypeLine), TRUE);

    GdipFree(data.Points);
    GdipFree(data.Types);
    GdipDeletePath(path);
}
Ejemplo n.º 3
0
static void test_flatten(void)
{
    GpStatus status;
    GpPath *path;
    GpMatrix *m;

    status = GdipCreatePath(FillModeAlternate, &path);
    expect(Ok, status);
    status = GdipCreateMatrix(&m);
    expect(Ok, status);

    /* NULL arguments */
    status = GdipFlattenPath(NULL, NULL, 0.0);
    expect(InvalidParameter, status);
    status = GdipFlattenPath(NULL, m, 0.0);
    expect(InvalidParameter, status);

    /* flatten empty path */
    status = GdipFlattenPath(path, NULL, 1.0);
    expect(Ok, status);

    status = GdipTransformPath(path, 0);
    expect(Ok, status);

    status = GdipAddPathEllipse(path, 0.0, 0.0, 100.0, 50.0);
    expect(Ok, status);

    status = GdipFlattenPath(path, NULL, 1.0);
    expect(Ok, status);
    ok_path(path, flattenellipse_path, sizeof(flattenellipse_path)/sizeof(path_test_t), TRUE);

    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 100.0);
    expect(Ok, status);
    status = GdipFlattenPath(path, NULL, 1.0);
    expect(Ok, status);
    ok_path(path, flattenline_path, sizeof(flattenline_path)/sizeof(path_test_t), FALSE);

    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipAddPathArc(path, 0.0, 0.0, 100.0, 50.0, 0.0, 90.0);
    expect(Ok, status);
    status = GdipFlattenPath(path, NULL, 1.0);
    expect(Ok, status);
    ok_path(path, flattenarc_path, sizeof(flattenarc_path)/sizeof(path_test_t), TRUE);

    /* easy case - quater of a full circle */
    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipAddPathArc(path, 0.0, 0.0, 100.0, 100.0, 0.0, 90.0);
    expect(Ok, status);
    status = GdipFlattenPath(path, NULL, 1.0);
    expect(Ok, status);
    ok_path(path, flattenquater_path, sizeof(flattenquater_path)/sizeof(path_test_t), FALSE);

    GdipDeleteMatrix(m);
    GdipDeletePath(path);
}
Ejemplo n.º 4
0
GpStatus WINGDIPAPI GdipAddPathRectangle(GpPath *path, REAL x, REAL y,
    REAL width, REAL height)
{
    GpPath *backup;
    GpPointF ptf[2];
    GpStatus retstat;
    BOOL old_new;

    if(!path || width < 0.0 || height < 0.0)
        return InvalidParameter;

    /* make a backup copy of path data */
    if((retstat = GdipClonePath(path, &backup)) != Ok)
        return retstat;

    /* rectangle should start as new path */
    old_new = path->newfigure;
    path->newfigure = TRUE;
    if((retstat = GdipAddPathLine(path,x,y,x+width,y)) != Ok){
        path->newfigure = old_new;
        goto fail;
    }

    ptf[0].X = x+width;
    ptf[0].Y = y+height;
    ptf[1].X = x;
    ptf[1].Y = y+height;

    if((retstat = GdipAddPathLine2(path,(GDIPCONST GpPointF*)&ptf,2)) != Ok)  goto fail;
    path->pathdata.Types[path->pathdata.Count-1] |= PathPointTypeCloseSubpath;

    /* free backup */
    GdipDeletePath(backup);
    return Ok;

fail:
    /* reverting */
    GdipDeletePath(path);
    GdipClonePath(backup, &path);
    GdipDeletePath(backup);

    return retstat;
}
Ejemplo n.º 5
0
static void test_polygon(void)
{
    GpStatus status;
    GpPath *path;
    GpPointF points[5];

    points[0].X = 0.0;
    points[0].Y = 0.0;
    points[1].X = 10.0;
    points[1].Y = 10.0;
    points[2].X = 10.0;
    points[2].Y = 20.0;
    points[3].X = 30.0;
    points[3].Y = 10.0;
    points[4].X = 20.0;
    points[4].Y = 0.0;

    GdipCreatePath(FillModeAlternate, &path);

    /* NULL args */
    status = GdipAddPathPolygon(NULL, points, 5);
    expect(InvalidParameter, status);
    status = GdipAddPathPolygon(path, NULL, 5);
    expect(InvalidParameter, status);
    /* Polygon should have 3 points at least */
    status = GdipAddPathPolygon(path, points, 2);
    expect(InvalidParameter, status);

    /* to test how it prolongs not empty path */
    status = GdipAddPathLine(path, 5.0, 5.0, 6.0, 8.0);
    expect(Ok, status);
    status = GdipAddPathPolygon(path, points, 5);
    expect(Ok, status);
    /* check resulting path */
    ok_path(path, poly_path, sizeof(poly_path)/sizeof(path_test_t), FALSE);

    GdipDeletePath(path);
}
Ejemplo n.º 6
0
GpStatus WINGDIPAPI GdipAddPathLineI(GpPath *path, INT x1, INT y1, INT x2, INT y2)
{
    return GdipAddPathLine(path, (REAL)x1, (REAL)y1, (REAL)x2, (REAL)y2);
}
Ejemplo n.º 7
0
static void test_addcurve(void)
{
    GpStatus status;
    GpPath *path;
    GpPointF points[4];

    points[0].X = 0.0;
    points[0].Y = 0.0;
    points[1].X = 10.0;
    points[1].Y = 10.0;
    points[2].X = 10.0;
    points[2].Y = 20.0;
    points[3].X = 30.0;
    points[3].Y = 10.0;

    GdipCreatePath(FillModeAlternate, &path);

    /* NULL args */
    status = GdipAddPathCurve2(NULL, NULL, 0, 0.0);
    expect(InvalidParameter, status);
    status = GdipAddPathCurve2(path, NULL, 0, 0.0);
    expect(InvalidParameter, status);
    status = GdipAddPathCurve2(path, points, -1, 0.0);
    expect(InvalidParameter, status);
    status = GdipAddPathCurve2(path, points, 1, 1.0);
    expect(InvalidParameter, status);

    /* add to empty path */
    status = GdipAddPathCurve2(path, points, 4, 1.0);
    expect(Ok, status);
    ok_path(path, addcurve_path, sizeof(addcurve_path)/sizeof(path_test_t), FALSE);
    GdipDeletePath(path);

    /* add to notempty path and opened figure */
    GdipCreatePath(FillModeAlternate, &path);
    GdipAddPathLine(path, 100.0, 120.0, 123.0, 10.0);
    status = GdipAddPathCurve2(path, points, 4, 1.0);
    expect(Ok, status);
    ok_path(path, addcurve_path2, sizeof(addcurve_path2)/sizeof(path_test_t), FALSE);

    /* NULL args */
    GdipResetPath(path);
    status = GdipAddPathCurve3(NULL, NULL, 0, 0, 0, 0.0);
    expect(InvalidParameter, status);
    status = GdipAddPathCurve3(path, NULL, 0, 0, 0, 0.0);
    expect(InvalidParameter, status);
    /* wrong count, offset.. */
    status = GdipAddPathCurve3(path, points, 0, 0, 0, 0.0);
    expect(InvalidParameter, status);
    status = GdipAddPathCurve3(path, points, 4, 0, 0, 0.0);
    expect(InvalidParameter, status);
    status = GdipAddPathCurve3(path, points, 4, 0, 4, 0.0);
    expect(InvalidParameter, status);
    status = GdipAddPathCurve3(path, points, 4, 1, 3, 0.0);
    expect(InvalidParameter, status);
    status = GdipAddPathCurve3(path, points, 4, 1, 0, 0.0);
    expect(InvalidParameter, status);
    status = GdipAddPathCurve3(path, points, 4, 3, 1, 0.0);
    expect(InvalidParameter, status);

    /* use all points */
    status = GdipAddPathCurve3(path, points, 4, 0, 3, 1.0);
    expect(Ok, status);
    ok_path(path, addcurve_path, sizeof(addcurve_path)/sizeof(path_test_t), FALSE);
    GdipResetPath(path);

    status = GdipAddPathCurve3(path, points, 4, 1, 2, 1.0);
    expect(Ok, status);
    ok_path(path, addcurve_path3, sizeof(addcurve_path3)/sizeof(path_test_t), FALSE);

    GdipDeletePath(path);
}
Ejemplo n.º 8
0
static void test_widen(void)
{
    GpStatus status;
    GpPath *path;
    GpPen *pen;
    GpMatrix *m;
    INT count=-1;

    status = GdipCreatePath(FillModeAlternate, &path);
    expect(Ok, status);
    status = GdipCreatePen1(0xffffffff, 10.0, UnitPixel, &pen);
    expect(Ok, status);
    status = GdipCreateMatrix(&m);
    expect(Ok, status);

    /* NULL arguments */
    status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0);
    expect(Ok, status);
    status = GdipWidenPath(NULL, NULL, NULL, 0.0);
    expect(InvalidParameter, status);
    status = GdipWidenPath(path, pen, m, 0.0);
    expect(Ok, status);
    status = GdipWidenPath(path, pen, NULL, 1.0);
    expect(Ok, status);
    status = GdipWidenPath(path, NULL, m, 1.0);
    expect(InvalidParameter, status);
    status = GdipWidenPath(NULL, pen, m, 1.0);
    expect(InvalidParameter, status);

    /* widen empty path */
    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipWidenPath(path, pen, m, 1.0);
    expect(OutOfMemory, status);

    /* horizontal line */
    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0);
    expect(Ok, status);

    status = GdipWidenPath(path, pen, m, 1.0);
    expect(Ok, status);
    ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE);

    /* horizontal 2x stretch */
    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipAddPathLine(path, 2.5, 10.0, 25.0, 10.0);
    expect(Ok, status);

    status = GdipScaleMatrix(m, 2.0, 1.0, MatrixOrderAppend);
    expect(Ok, status);

    status = GdipWidenPath(path, pen, m, 1.0);
    expect(Ok, status);
    ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE);

    /* vertical 2x stretch */
    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipAddPathLine(path, 5.0, 5.0, 50.0, 5.0);
    expect(Ok, status);

    status = GdipScaleMatrix(m, 0.5, 2.0, MatrixOrderAppend);
    expect(Ok, status);

    status = GdipWidenPath(path, pen, m, 1.0);
    expect(Ok, status);
    ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE);

    status = GdipScaleMatrix(m, 1.0, 0.5, MatrixOrderAppend);
    expect(Ok, status);

    /* dashed line */
    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipAddPathLine(path, 5.0, 5.0, 50.0, 5.0);
    expect(Ok, status);

    status = GdipSetPenDashStyle(pen, DashStyleDash);
    expect(Ok, status);

    status = GdipWidenPath(path, pen, m, 1.0);
    expect(Ok, status);
    ok_path(path, widenline_dash_path, sizeof(widenline_dash_path)/sizeof(path_test_t), FALSE);

    status = GdipSetPenDashStyle(pen, DashStyleSolid);
    expect(Ok, status);

    /* pen width in UnitWorld */
    GdipDeletePen(pen);
    status = GdipCreatePen1(0xffffffff, 10.0, UnitWorld, &pen);
    expect(Ok, status);

    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0);
    expect(Ok, status);

    status = GdipWidenPath(path, pen, m, 1.0);
    expect(Ok, status);
    ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE);

    /* horizontal 2x stretch */
    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipAddPathLine(path, 2.5, 10.0, 25.0, 10.0);
    expect(Ok, status);

    status = GdipScaleMatrix(m, 2.0, 1.0, MatrixOrderAppend);
    expect(Ok, status);

    status = GdipWidenPath(path, pen, m, 1.0);
    expect(Ok, status);
    ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE);

    /* vertical 2x stretch */
    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipAddPathLine(path, 5.0, 5.0, 50.0, 5.0);
    expect(Ok, status);

    status = GdipScaleMatrix(m, 0.5, 2.0, MatrixOrderAppend);
    expect(Ok, status);

    status = GdipWidenPath(path, pen, m, 1.0);
    expect(Ok, status);
    ok_path(path, widenline_wide_path, sizeof(widenline_wide_path)/sizeof(path_test_t), FALSE);

    status = GdipScaleMatrix(m, 1.0, 0.5, MatrixOrderAppend);
    expect(Ok, status);

    /* pen width in UnitInch */
    GdipDeletePen(pen);
    status = GdipCreatePen1(0xffffffff, 10.0, UnitWorld, &pen);
    expect(Ok, status);

    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0);
    expect(Ok, status);

    status = GdipWidenPath(path, pen, m, 1.0);
    expect(Ok, status);
    ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE);

    /* pen width = 0 pixels - native fails to widen but can draw with this pen */
    GdipDeletePen(pen);
    status = GdipCreatePen1(0xffffffff, 0.0, UnitPixel, &pen);
    expect(Ok, status);

    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0);
    expect(Ok, status);

    status = GdipWidenPath(path, pen, m, 1.0);
    expect(Ok, status);

    status = GdipGetPointCount(path, &count);
    expect(Ok, status);
    todo_wine expect(0, count);

    GdipDeleteMatrix(m);
    GdipDeletePen(pen);
    GdipDeletePath(path);
}
Ejemplo n.º 9
0
static void test_widen(void)
{
    GpStatus status;
    GpPath *path;
    GpPen *pen;
    GpMatrix *m;

    status = GdipCreatePath(FillModeAlternate, &path);
    expect(Ok, status);
    status = GdipCreatePen1(0xffffffff, 10.0, UnitPixel, &pen);
    expect(Ok, status);
    status = GdipCreateMatrix(&m);
    expect(Ok, status);

    /* NULL arguments */
    status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0);
    expect(Ok, status);
    status = GdipWidenPath(NULL, NULL, NULL, 0.0);
    expect(InvalidParameter, status);
    status = GdipWidenPath(path, pen, m, 0.0);
    expect(Ok, status);
    status = GdipWidenPath(path, pen, NULL, 1.0);
    expect(Ok, status);
    status = GdipWidenPath(path, NULL, m, 1.0);
    expect(InvalidParameter, status);
    status = GdipWidenPath(NULL, pen, m, 1.0);
    expect(InvalidParameter, status);

    /* widen empty path */
    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipWidenPath(path, pen, m, 1.0);
    expect(OutOfMemory, status);

    /* horizontal line */
    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0);
    expect(Ok, status);

    status = GdipWidenPath(path, pen, m, 1.0);
    expect(Ok, status);
    ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE);

    /* horizontal 2x stretch */
    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipAddPathLine(path, 2.5, 10.0, 25.0, 10.0);
    expect(Ok, status);

    status = GdipScaleMatrix(m, 2.0, 1.0, MatrixOrderAppend);
    expect(Ok, status);

    status = GdipWidenPath(path, pen, m, 1.0);
    expect(Ok, status);
    ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE);

    /* vertical 2x stretch */
    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipAddPathLine(path, 5.0, 5.0, 50.0, 5.0);
    expect(Ok, status);

    status = GdipScaleMatrix(m, 0.5, 2.0, MatrixOrderAppend);
    expect(Ok, status);

    status = GdipWidenPath(path, pen, m, 1.0);
    expect(Ok, status);
    ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE);

    status = GdipScaleMatrix(m, 1.0, 0.5, MatrixOrderAppend);
    expect(Ok, status);

    /* pen width in UnitWorld */
    GdipDeletePen(pen);
    status = GdipCreatePen1(0xffffffff, 10.0, UnitWorld, &pen);
    expect(Ok, status);

    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0);
    expect(Ok, status);

    status = GdipWidenPath(path, pen, m, 1.0);
    expect(Ok, status);
    ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE);

    /* horizontal 2x stretch */
    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipAddPathLine(path, 2.5, 10.0, 25.0, 10.0);
    expect(Ok, status);

    status = GdipScaleMatrix(m, 2.0, 1.0, MatrixOrderAppend);
    expect(Ok, status);

    status = GdipWidenPath(path, pen, m, 1.0);
    expect(Ok, status);
    ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE);

    /* vertical 2x stretch */
    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipAddPathLine(path, 5.0, 5.0, 50.0, 5.0);
    expect(Ok, status);

    status = GdipScaleMatrix(m, 0.5, 2.0, MatrixOrderAppend);
    expect(Ok, status);

    status = GdipWidenPath(path, pen, m, 1.0);
    expect(Ok, status);
    ok_path(path, widenline_wide_path, sizeof(widenline_wide_path)/sizeof(path_test_t), FALSE);

    status = GdipScaleMatrix(m, 1.0, 0.5, MatrixOrderAppend);
    expect(Ok, status);

    /* pen width in UnitInch */
    GdipDeletePen(pen);
    status = GdipCreatePen1(0xffffffff, 10.0, UnitWorld, &pen);
    expect(Ok, status);

    status = GdipResetPath(path);
    expect(Ok, status);
    status = GdipAddPathLine(path, 5.0, 10.0, 50.0, 10.0);
    expect(Ok, status);

    status = GdipWidenPath(path, pen, m, 1.0);
    expect(Ok, status);
    ok_path(path, widenline_path, sizeof(widenline_path)/sizeof(path_test_t), FALSE);

    GdipDeleteMatrix(m);
    GdipDeletePen(pen);
    GdipDeletePath(path);
}
Ejemplo n.º 10
0
static void test_getregiondata(void)
{
    GpStatus status;
    GpRegion *region, *region2;
    RegionDataPoint *point;
    UINT needed;
    DWORD buf[100];
    GpRect rect;
    GpPath *path;

    memset(buf, 0xee, sizeof(buf));

    status = GdipCreateRegion(&region);
    ok(status == Ok, "status %08x\n", status);

    status = GdipGetRegionDataSize(region, &needed);
    ok(status == Ok, "status %08x\n", status);
    expect(20, needed);
    status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
    ok(status == Ok, "status %08x\n", status);
    expect(20, needed);
    expect_dword(buf, 12);
    trace("buf[1] = %08x\n", buf[1]);
    expect_magic((DWORD*)(buf + 2));
    expect_dword(buf + 3, 0);
    expect_dword(buf + 4, RGNDATA_INFINITE_RECT);

    status = GdipSetEmpty(region);
    ok(status == Ok, "status %08x\n", status);
    status = GdipGetRegionDataSize(region, &needed);
    ok(status == Ok, "status %08x\n", status);
    expect(20, needed);
    status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
    ok(status == Ok, "status %08x\n", status);
    expect(20, needed);
    expect_dword(buf, 12);
    trace("buf[1] = %08x\n", buf[1]);
    expect_magic((DWORD*)(buf + 2));
    expect_dword(buf + 3, 0);
    expect_dword(buf + 4, RGNDATA_EMPTY_RECT);

    status = GdipSetInfinite(region);
    ok(status == Ok, "status %08x\n", status);
    status = GdipGetRegionDataSize(region, &needed);
    ok(status == Ok, "status %08x\n", status);
    expect(20, needed);
    status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
    ok(status == Ok, "status %08x\n", status);
    expect(20, needed);
    expect_dword(buf, 12);
    trace("buf[1] = %08x\n", buf[1]);
    expect_magic((DWORD*)(buf + 2));
    expect_dword(buf + 3, 0);
    expect_dword(buf + 4, RGNDATA_INFINITE_RECT);

    status = GdipDeleteRegion(region);
    ok(status == Ok, "status %08x\n", status);

    rect.X = 10;
    rect.Y = 20;
    rect.Width = 100;
    rect.Height = 200;
    status = GdipCreateRegionRectI(&rect, &region);
    ok(status == Ok, "status %08x\n", status);
    status = GdipGetRegionDataSize(region, &needed);
    ok(status == Ok, "status %08x\n", status);
    expect(36, needed);
    status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
    ok(status == Ok, "status %08x\n", status);
    expect(36, needed);
    expect_dword(buf, 28);
    trace("buf[1] = %08x\n", buf[1]);
    expect_magic((DWORD*)(buf + 2));
    expect_dword(buf + 3, 0);
    expect_dword(buf + 4, RGNDATA_RECT);
    expect_float(buf + 5, 10.0);
    expect_float(buf + 6, 20.0);
    expect_float(buf + 7, 100.0);
    expect_float(buf + 8, 200.0);

    rect.X = 50;
    rect.Y = 30;
    rect.Width = 10;
    rect.Height = 20;
    status = GdipCombineRegionRectI(region, &rect, CombineModeIntersect);
    ok(status == Ok, "status %08x\n", status);
    rect.X = 100;
    rect.Y = 300;
    rect.Width = 30;
    rect.Height = 50;
    status = GdipCombineRegionRectI(region, &rect, CombineModeXor);
    ok(status == Ok, "status %08x\n", status);

    rect.X = 200;
    rect.Y = 100;
    rect.Width = 133;
    rect.Height = 266;
    status = GdipCreateRegionRectI(&rect, &region2);
    ok(status == Ok, "status %08x\n", status);
    rect.X = 20;
    rect.Y = 10;
    rect.Width = 40;
    rect.Height = 66;
    status = GdipCombineRegionRectI(region2, &rect, CombineModeUnion);
    ok(status == Ok, "status %08x\n", status);

    status = GdipCombineRegionRegion(region, region2, CombineModeComplement);
    ok(status == Ok, "status %08x\n", status);

    rect.X = 400;
    rect.Y = 500;
    rect.Width = 22;
    rect.Height = 55;
    status = GdipCombineRegionRectI(region, &rect, CombineModeExclude);
    ok(status == Ok, "status %08x\n", status);

    status = GdipGetRegionDataSize(region, &needed);
    ok(status == Ok, "status %08x\n", status);
    expect(156, needed);
    status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
    ok(status == Ok, "status %08x\n", status);
    expect(156, needed);
    expect_dword(buf, 148);
    trace("buf[1] = %08x\n", buf[1]);
    expect_magic((DWORD*)(buf + 2));
    expect_dword(buf + 3, 10);
    expect_dword(buf + 4, CombineModeExclude);
    expect_dword(buf + 5, CombineModeComplement);
    expect_dword(buf + 6, CombineModeXor);
    expect_dword(buf + 7, CombineModeIntersect);
    expect_dword(buf + 8, RGNDATA_RECT);
    expect_float(buf + 9, 10.0);
    expect_float(buf + 10, 20.0);
    expect_float(buf + 11, 100.0);
    expect_float(buf + 12, 200.0);
    expect_dword(buf + 13, RGNDATA_RECT);
    expect_float(buf + 14, 50.0);
    expect_float(buf + 15, 30.0);
    expect_float(buf + 16, 10.0);
    expect_float(buf + 17, 20.0);
    expect_dword(buf + 18, RGNDATA_RECT);
    expect_float(buf + 19, 100.0);
    expect_float(buf + 20, 300.0);
    expect_float(buf + 21, 30.0);
    expect_float(buf + 22, 50.0);
    expect_dword(buf + 23, CombineModeUnion);
    expect_dword(buf + 24, RGNDATA_RECT);
    expect_float(buf + 25, 200.0);
    expect_float(buf + 26, 100.0);
    expect_float(buf + 27, 133.0);
    expect_float(buf + 28, 266.0);
    expect_dword(buf + 29, RGNDATA_RECT);
    expect_float(buf + 30, 20.0);
    expect_float(buf + 31, 10.0);
    expect_float(buf + 32, 40.0);
    expect_float(buf + 33, 66.0);
    expect_dword(buf + 34, RGNDATA_RECT);
    expect_float(buf + 35, 400.0);
    expect_float(buf + 36, 500.0);
    expect_float(buf + 37, 22.0);
    expect_float(buf + 38, 55.0);

    status = GdipDeleteRegion(region2);
    ok(status == Ok, "status %08x\n", status);
    status = GdipDeleteRegion(region);
    ok(status == Ok, "status %08x\n", status);

    /* Try some paths */

    status = GdipCreatePath(FillModeAlternate, &path);
    ok(status == Ok, "status %08x\n", status);
    GdipAddPathRectangle(path, 12.5, 13.0, 14.0, 15.0);

    status = GdipCreateRegionPath(path, &region);
    ok(status == Ok, "status %08x\n", status);
    status = GdipGetRegionDataSize(region, &needed);
    ok(status == Ok, "status %08x\n", status);
    expect(72, needed);
    status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
    ok(status == Ok, "status %08x\n", status);
    expect(72, needed);
    expect_dword(buf, 64);
    trace("buf[1] = %08x\n", buf[1]);
    expect_magic((DWORD*)(buf + 2));
    expect_dword(buf + 3, 0);
    expect_dword(buf + 4, RGNDATA_PATH);
    expect_dword(buf + 5, 0x00000030);
    expect_magic((DWORD*)(buf + 6));
    expect_dword(buf + 7, 0x00000004);
    expect_dword(buf + 8, 0x00000000);
    expect_float(buf + 9, 12.5);
    expect_float(buf + 10, 13.0);
    expect_float(buf + 11, 26.5);
    expect_float(buf + 12, 13.0);
    expect_float(buf + 13, 26.5);
    expect_float(buf + 14, 28.0);
    expect_float(buf + 15, 12.5);
    expect_float(buf + 16, 28.0);
    expect_dword(buf + 17, 0x81010100);


    rect.X = 50;
    rect.Y = 30;
    rect.Width = 10;
    rect.Height = 20;
    status = GdipCombineRegionRectI(region, &rect, CombineModeIntersect);
    ok(status == Ok, "status %08x\n", status);
    status = GdipGetRegionDataSize(region, &needed);
    ok(status == Ok, "status %08x\n", status);
    expect(96, needed);
    status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
    ok(status == Ok, "status %08x\n", status);
    expect(96, needed);
    expect_dword(buf, 88);
    trace("buf[1] = %08x\n", buf[1]);
    expect_magic((DWORD*)(buf + 2));
    expect_dword(buf + 3, 2);
    expect_dword(buf + 4, CombineModeIntersect);
    expect_dword(buf + 5, RGNDATA_PATH);
    expect_dword(buf + 6, 0x00000030);
    expect_magic((DWORD*)(buf + 7));
    expect_dword(buf + 8, 0x00000004);
    expect_dword(buf + 9, 0x00000000);
    expect_float(buf + 10, 12.5);
    expect_float(buf + 11, 13.0);
    expect_float(buf + 12, 26.5);
    expect_float(buf + 13, 13.0);
    expect_float(buf + 14, 26.5);
    expect_float(buf + 15, 28.0);
    expect_float(buf + 16, 12.5);
    expect_float(buf + 17, 28.0);
    expect_dword(buf + 18, 0x81010100);
    expect_dword(buf + 19, RGNDATA_RECT);
    expect_float(buf + 20, 50.0);
    expect_float(buf + 21, 30.0);
    expect_float(buf + 22, 10.0);
    expect_float(buf + 23, 20.0);

    status = GdipDeleteRegion(region);
    ok(status == Ok, "status %08x\n", status);
    status = GdipDeletePath(path);
    ok(status == Ok, "status %08x\n", status);

    /* Test an empty path */
    status = GdipCreatePath(FillModeAlternate, &path);
    expect(Ok, status);
    status = GdipCreateRegionPath(path, &region);
    expect(Ok, status);
    status = GdipGetRegionDataSize(region, &needed);
    expect(Ok, status);
    expect(36, needed);
    status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
    expect(Ok, status);
    expect(36, needed);
    expect_dword(buf, 28);
    trace("buf[1] = %08x\n", buf[1]);
    expect_magic((DWORD*)(buf + 2));
    expect_dword(buf + 3, 0);
    expect_dword(buf + 4, RGNDATA_PATH);

    /* Second signature for pathdata */
    expect_dword(buf + 5, 12);
    expect_magic((DWORD*)(buf + 6));
    expect_dword(buf + 7, 0);
    expect_dword(buf + 8, 0x00004000);

    status = GdipDeleteRegion(region);
    expect(Ok, status);

    /* Test a simple triangle of INTs */
    status = GdipAddPathLine(path, 5, 6, 7, 8);
    expect(Ok, status);
    status = GdipAddPathLine(path, 8, 1, 5, 6);
    expect(Ok, status);
    status = GdipClosePathFigure(path);
    expect(Ok, status);
    status = GdipCreateRegionPath(path, &region);
    expect(Ok, status);
    status = GdipGetRegionDataSize(region, &needed);
    expect(Ok, status);
    expect(56, needed);
    status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
    expect(Ok, status);
    expect(56, needed);
    expect_dword(buf, 48);
    trace("buf[1] = %08x\n", buf[1]);
    expect_magic((DWORD*)(buf + 2));
    expect_dword(buf + 3 , 0);
    expect_dword(buf + 4 , RGNDATA_PATH);

    expect_dword(buf + 5, 32);
    expect_magic((DWORD*)(buf + 6));
    expect_dword(buf + 7, 4);
    expect_dword(buf + 8, 0x00004000); /* ?? */

    point = (RegionDataPoint*)buf + 9;
    expect(5, point[0].X);
    expect(6, point[0].Y);
    expect(7, point[1].X); /* buf + 10 */
    expect(8, point[1].Y);
    expect(8, point[2].X); /* buf + 11 */
    expect(1, point[2].Y);
    expect(5, point[3].X); /* buf + 12 */
    expect(6, point[3].Y);
    expect_dword(buf + 13, 0x81010100); /* 0x01010100 if we don't close the path */

    status = GdipDeletePath(path);
    expect(Ok, status);
    status = GdipDeleteRegion(region);
    expect(Ok, status);

    /* Test a floating-point triangle */
    status = GdipCreatePath(FillModeAlternate, &path);
    expect(Ok, status);
    status = GdipAddPathLine(path, 5.6, 6.2, 7.2, 8.9);
    expect(Ok, status);
    status = GdipAddPathLine(path, 8.1, 1.6, 5.6, 6.2);
    expect(Ok, status);
    status = GdipCreateRegionPath(path, &region);
    expect(Ok, status);
    status = GdipGetRegionDataSize(region, &needed);
    expect(Ok, status);
    expect(72, needed);
    status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
    expect(Ok, status);
    expect(72, needed);
    expect_dword(buf, 64);
    trace("buf[1] = %08x\n", buf[1]);
    expect_magic((DWORD*)(buf + 2));
    expect_dword(buf + 3, 0);
    expect_dword(buf + 4, RGNDATA_PATH);

    expect_dword(buf + 5, 48);
    expect_magic((DWORD*)(buf + 6));
    expect_dword(buf + 7, 4);
    expect_dword(buf + 8, 0);
    expect_float(buf + 9, 5.6);
    expect_float(buf + 10, 6.2);
    expect_float(buf + 11, 7.2);
    expect_float(buf + 12, 8.9);
    expect_float(buf + 13, 8.1);
    expect_float(buf + 14, 1.6);
    expect_float(buf + 15, 5.6);
    expect_float(buf + 16, 6.2);

    status = GdipDeletePath(path);
    expect(Ok, status);
    status = GdipDeleteRegion(region);
    expect(Ok, status);

    /* Test for a path with > 4 points, and CombineRegionPath */
    GdipCreatePath(FillModeAlternate, &path);
    status = GdipAddPathLine(path, 50, 70.2, 60, 102.8);
    expect(Ok, status);
    status = GdipAddPathLine(path, 55.4, 122.4, 40.4, 60.2);
    expect(Ok, status);
    status = GdipAddPathLine(path, 45.6, 20.2, 50, 70.2);
    expect(Ok, status);
    rect.X = 20;
    rect.Y = 25;
    rect.Width = 60;
    rect.Height = 120;
    status = GdipCreateRegionRectI(&rect, &region);
    expect(Ok, status);
    status = GdipCombineRegionPath(region, path, CombineModeUnion);
    expect(Ok, status);

    status = GdipGetRegionDataSize(region, &needed);
    expect(Ok, status);
    expect(116, needed);
    status = GdipGetRegionData(region, (BYTE*)buf, sizeof(buf), &needed);
    expect(Ok, status);
    expect(116, needed);
    expect_dword(buf, 108);
    trace("buf[1] = %08x\n", buf[1]);
    expect_magic((DWORD*)(buf + 2));
    expect_dword(buf + 3, 2);
    expect_dword(buf + 4, CombineModeUnion);
    expect_dword(buf + 5, RGNDATA_RECT);
    expect_float(buf + 6, 20);
    expect_float(buf + 7, 25);
    expect_float(buf + 8, 60);
    expect_float(buf + 9, 120);
    expect_dword(buf + 10, RGNDATA_PATH);

    expect_dword(buf + 11, 68);
    expect_magic((DWORD*)(buf + 12));
    expect_dword(buf + 13, 6);
    expect_float(buf + 14, 0x0);

    expect_float(buf + 15, 50);
    expect_float(buf + 16, 70.2);
    expect_float(buf + 17, 60);
    expect_float(buf + 18, 102.8);
    expect_float(buf + 19, 55.4);
    expect_float(buf + 20, 122.4);
    expect_float(buf + 21, 40.4);
    expect_float(buf + 22, 60.2);
    expect_float(buf + 23, 45.6);
    expect_float(buf + 24, 20.2);
    expect_float(buf + 25, 50);
    expect_float(buf + 26, 70.2);
    expect_dword(buf + 27, 0x01010100);
    expect_dword(buf + 28, 0x00000101);

    status = GdipDeletePath(path);
    expect(Ok, status);
    status = GdipDeleteRegion(region);
    expect(Ok, status);
}