Beispiel #1
0
GpStatus WINGDIPAPI GdipClonePen(GpPen *pen, GpPen **clonepen)
{
    GpStatus stat;

    TRACE("(%p, %p)\n", pen, clonepen);

    if(!pen || !clonepen)
        return InvalidParameter;

    *clonepen = heap_alloc_zero(sizeof(GpPen));
    if(!*clonepen)  return OutOfMemory;

    **clonepen = *pen;

    (*clonepen)->customstart = NULL;
    (*clonepen)->customend = NULL;
    (*clonepen)->brush = NULL;
    (*clonepen)->dashes = NULL;

    stat = GdipCloneBrush(pen->brush, &(*clonepen)->brush);

    if (stat == Ok && pen->customstart)
        stat = GdipCloneCustomLineCap(pen->customstart, &(*clonepen)->customstart);

    if (stat == Ok && pen->customend)
        stat = GdipCloneCustomLineCap(pen->customend, &(*clonepen)->customend);

    if (stat == Ok && pen->dashes)
    {
        (*clonepen)->dashes = heap_alloc_zero(pen->numdashes * sizeof(REAL));
        if ((*clonepen)->dashes)
            memcpy((*clonepen)->dashes, pen->dashes, pen->numdashes * sizeof(REAL));
        else
            stat = OutOfMemory;
    }

    if (stat != Ok)
    {
        GdipDeletePen(*clonepen);
        *clonepen = NULL;
        return stat;
    }

    TRACE("<-- %p\n", *clonepen);

    return Ok;
}
Beispiel #2
0
LRESULT CALLBACK WndProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
    HDC hdc;
    PAINTSTRUCT ps;
    switch (uMsg)
    {

        case WM_PAINT:
            
            
            hdc = BeginPaint(hwnd, &ps);

            int graphics;
            GdipCreateFromHDC(hdc, &graphics);//创建Graphics对象
            GdipCreatePen1(0x60FF2015, 1, 2, &pen);//创建画笔
            GdipDrawRectangle(graphics, pen, 20, 20, 120, 120);//画矩形
            GdipDrawLine(graphics, pen, 50, 60, 170, 340);//画直线

            GdipDeletePen(pen);//销毁画笔
            GdipDeleteGraphics(graphics);//销毁Graphics对象

            EndPaint(hwnd, &ps);
            return 0;//告诉系统,WM_PAINT消息我已经处理了,你那儿凉快哪儿玩去吧。
        case WM_CREATE:
            break;
        case WM_DESTROY://窗口已经销毁
            PostQuitMessage(0);//退出消息循环,结束应用程序
            return 0;
            break;
        case WM_LBUTTONDOWN://鼠标左键按下
                            //让无边框窗口能够拖动(在窗口客户区拖动)
            PostMessage(hwnd, WM_SYSCOMMAND, 61458, 0);
            break;
            /*case WM_MOUSEMOVE://鼠标移动
            int xPos, yPos;
            xPos = GET_X_LPARAM(lParam);//鼠标位置X坐标
            yPos = GET_Y_LPARAM(lParam);//鼠标位置Y坐标
            //不要用LOWORD和HIWORD获取坐标,因为坐标有可能是负的
            break;*/
        default:
            break;
    }
    return DefWindowProc(hwnd, uMsg, wParam, lParam);//其他消息交给系统处理
}
Beispiel #3
0
static void test_brushfill(void)
{
    GpStatus status;
    GpPen *pen;
    GpBrush *brush, *brush2;
    GpBrushType type;
    ARGB color = 0;

    /* default solid */
    GdipCreatePen1(0xdeadbeef, 4.5, UnitWorld, &pen);
    status = GdipGetPenBrushFill(pen, &brush);
    expect(Ok, status);
    GdipGetBrushType(brush, &type);
    expect(BrushTypeSolidColor, type);
    GdipGetPenColor(pen, &color);
    expect(0xdeadbeef, color);
    GdipDeleteBrush(brush);

    /* color controlled by brush */
    GdipCreateSolidFill(0xabaddeed, (GpSolidFill**)&brush);
    status = GdipSetPenBrushFill(pen, brush);
    expect(Ok, status);
    GdipGetPenColor(pen, &color);
    expect(0xabaddeed, color);
    GdipDeleteBrush(brush);
    color = 0;

    /* get returns a clone, not a reference */
    GdipGetPenBrushFill(pen, &brush);
    GdipSetSolidFillColor((GpSolidFill*)brush, 0xbeadfeed);
    GdipGetPenBrushFill(pen, &brush2);
    ok(brush != brush2, "Expected to get a clone, not a copy of the reference\n");
    GdipGetSolidFillColor((GpSolidFill*)brush2, &color);
    expect(0xabaddeed, color);
    GdipDeleteBrush(brush);
    GdipDeleteBrush(brush2);

    /* brush cannot be NULL */
    status = GdipSetPenBrushFill(pen, NULL);
    expect(InvalidParameter, status);

    GdipDeletePen(pen);
}
Beispiel #4
0
// coverity[+alloc : arg-*3]
GpStatus WINGDIPAPI
GdipCreatePen2 (GpBrush *brush, REAL width, GpUnit unit, GpPen **pen)
{
	GpPen *result;
	GpStatus status;
	GpBrushType type;
	ARGB color;

	if (!gdiplusInitialized)
		return GdiplusNotInitialized;

	if (!brush || !pen || unit > UnitCairoPoint || unit == UnitDisplay)
		return InvalidParameter;

	result = gdip_pen_new ();
	if (!result) {
		*pen = NULL;
		return OutOfMemory;
	}

	result->width = width;
	result->unit = unit;
	result->own_brush = TRUE;

	/* The user supplied brush can be disposed, we must clone it to ensure
	 * it's valid when we need to set the pen. */
	status = GdipCloneBrush (brush, &result->brush);
	if (status != Ok) {
		GdipDeletePen (result);
		*pen = NULL;
		return status;
	}

	GdipGetBrushType (brush, &type);
	if (type == BrushTypeSolidColor) {
		GdipGetSolidFillColor ((GpSolidFill *) brush, &color);
		result->color = color;
	}

	*pen = result;
	return Ok;
}
Beispiel #5
0
static void test_startup(void)
{
    GpPen *pen = NULL;
    Status status;
    struct GdiplusStartupInput gdiplusStartupInput;
    ULONG_PTR gdiplusToken;
    int gpversion;

    gdiplusStartupInput.DebugEventCallback          = NULL;
    gdiplusStartupInput.SuppressBackgroundThread    = 0;
    gdiplusStartupInput.SuppressExternalCodecs      = 0;

    for (gpversion=1; gpversion<256; gpversion++)
    {
        gdiplusStartupInput.GdiplusVersion = gpversion;
        status = GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
        ok(status == Ok || status == UnsupportedGdiplusVersion,
            "GdiplusStartup returned %x\n", status);
        GdiplusShutdown(gdiplusToken);
        if (status != Ok)
        {
            gpversion--;
            break;
        }
    }

    ok(gpversion > 0 && gpversion <= 2, "unexpected gdiplus version %i\n", gpversion);
    trace("gdiplus version is %i\n", gpversion);

    status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);

    todo_wine
        expect(GdiplusNotInitialized, status);

    GdipDeletePen(pen);
}
Beispiel #6
0
static void test_transform(void)
{
    GpStatus status;
    GpPen *pen;
    GpMatrix *matrix, *matrix2;
    REAL values[6];

    status = GdipCreatePen1((ARGB)0xffff00ff, 10.0f, UnitPixel, &pen);
    expect(Ok, status);

    status = GdipCreateMatrix(&matrix);
    expect(Ok, status);

    status = GdipGetPenTransform(pen, matrix);
    todo_wine expect(Ok, status);

    status = GdipGetMatrixElements(matrix, values);
    expect(Ok, status);

    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]);

    GdipCreateMatrix2(3.0, -2.0, 5.0, 2.0, 6.0, 3.0, &matrix2);
    status = GdipSetPenTransform(pen, matrix2);
    todo_wine expect(Ok, status);
    GdipDeleteMatrix(matrix2);

    status = GdipGetPenTransform(pen, matrix);
    todo_wine expect(Ok, status);
    status = GdipGetMatrixElements(matrix, values);
    expect(Ok, status);
todo_wine {
    expectf(3.0,  values[0]);
    expectf(-2.0,  values[1]);
    expectf(5.0,  values[2]);
    expectf(2.0, values[3]);
    expectf(6.0, values[4]);
    expectf(3.0,  values[5]);
}
    status = GdipResetPenTransform(pen);
    todo_wine expect(Ok, status);

    status = GdipGetPenTransform(pen, matrix);
    todo_wine expect(Ok, status);
    status = GdipGetMatrixElements(matrix, values);
    expect(Ok, status);

    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]);

    GdipDeletePen(pen);

    GdipDeleteMatrix(matrix);
}
Beispiel #7
0
static void test_dasharray(void)
{
    GpPen *pen;
    GpDashStyle style;
    GpStatus status;
    REAL dashes[12];

    GdipCreatePen1(0xdeadbeef, 10.0, UnitWorld, &pen);
    dashes[0] = 10.0;
    dashes[1] = 11.0;
    dashes[2] = 12.0;
    dashes[3] = 13.0;
    dashes[4] = 14.0;
    dashes[5] = -100.0;
    dashes[6] = -100.0;
    dashes[7] = dashes[8] = dashes[9] = dashes[10] = dashes[11] = 0.0;

    /* setting the array sets the type to custom */
    GdipGetPenDashStyle(pen, &style);
    expect(DashStyleSolid, style);
    status = GdipSetPenDashArray(pen, dashes, 2);
    expect(Ok, status);
    GdipGetPenDashStyle(pen, &style);
    expect(DashStyleCustom, style);

    /* Getting the array on a non-custom pen returns invalid parameter (unless
     * you are getting 0 elements).*/
    GdipSetPenDashStyle(pen, DashStyleSolid);
    status = GdipGetPenDashArray(pen, &dashes[5], 2);
    expect(InvalidParameter, status);
    status = GdipGetPenDashArray(pen, &dashes[5], 0);
    expect(Ok, status);

    /* What does setting DashStyleCustom do to the array length? */
    GdipSetPenDashArray(pen, dashes, 2);
    GdipSetPenDashStyle(pen, DashStyleCustom);
    status = GdipGetPenDashArray(pen, &dashes[5], 2);
    expect(Ok, status);
    expectf(10.0, dashes[5]);
    expectf(11.0, dashes[6]);

    /* Set the array, then get with different sized buffers. */
    status = GdipSetPenDashArray(pen, dashes, 5);
    expect(Ok, status);
    dashes[5] = -100.0;
    dashes[6] = -100.0;
    status = GdipGetPenDashArray(pen, &dashes[5], 1);
    expect(Ok, status); /* not InsufficientBuffer! */
    expectf(10.0, dashes[5]);
    expectf(-100.0, dashes[6]);
    dashes[5] = -100.0;
    status = GdipGetPenDashArray(pen, &dashes[5], 6);
    expect(InvalidParameter, status); /* not Ok! */
    expectf(-100.0, dashes[5]);
    expectf(-100.0, dashes[6]);

    /* Some invalid array values. */
    status = GdipSetPenDashArray(pen, &dashes[7], 5);
    expect(InvalidParameter, status);
    dashes[9] = -1.0;
    status = GdipSetPenDashArray(pen, &dashes[7], 5);
    expect(InvalidParameter, status);

    /* Try to set with count = 0. */
    GdipSetPenDashStyle(pen, DashStyleDot);
    if (0)  /* corrupts stack on 64-bit Vista */
    {
    status = GdipSetPenDashArray(pen, dashes, 0);
    ok(status == OutOfMemory || status == InvalidParameter,
       "Expected OutOfMemory or InvalidParameter, got %.8x\n", status);
    }
    status = GdipSetPenDashArray(pen, dashes, -1);
    ok(status == OutOfMemory || status == InvalidParameter,
       "Expected OutOfMemory or InvalidParameter, got %.8x\n", status);
    GdipGetPenDashStyle(pen, &style);
    expect(DashStyleDot, style);

    GdipDeletePen(pen);
}
Beispiel #8
0
// coverity[+alloc : arg-*1]
GpStatus WINGDIPAPI
GdipClonePen (GpPen *pen, GpPen **clonepen)
{
	GpPen *result;

	if (!pen || !clonepen)
		return InvalidParameter;

	result = gdip_pen_new ();
	if (!result) {
		*clonepen = NULL;
		return OutOfMemory;
	}

	result->own_brush = pen->own_brush;
	result->color = pen->color;
	result->width = pen->width;
	result->miter_limit = pen->miter_limit;
	result->line_join = pen->line_join;
	result->dash_style = pen->dash_style;
	result->line_cap = pen->line_cap;
	result->end_cap = pen->end_cap;
	result->mode = pen->mode;
	result->dash_offset = pen->dash_offset;
	result->dash_count = pen->dash_count;
	result->own_dash_array = pen->own_dash_array;
	result->compound_count = pen->compound_count;
	result->unit = pen->unit;
	gdip_cairo_matrix_copy (&result->matrix, &pen->matrix);
	result->changed = pen->changed;

	/* Make a copy of dash array only if it is owned by the pen - i.e. it is not
	 * a global array. */
	if (pen->dash_count > 0 && pen->own_dash_array) {
		result->dash_array = (float *) GdipAlloc (pen->dash_count * sizeof (float));
		if (!result->dash_array)
			goto error;

		memcpy (result->dash_array, pen->dash_array, pen->dash_count * sizeof (float));
	}
	else
		result->dash_array = pen->dash_array;

	if (pen->compound_count > 0) {
		result->compound_array = (float *) GdipAlloc (pen->compound_count * sizeof (float));
		if (!result->compound_array)
			goto error;

		memcpy (result->compound_array, pen->compound_array, pen->compound_count * sizeof (float));
	}

	if (pen->custom_start_cap) {
		GpStatus status = GdipCloneCustomLineCap (pen->custom_start_cap, &result->custom_start_cap);
		if (status != Ok)
			goto error;
	}

	if (pen->custom_end_cap) {
		GpStatus status = GdipCloneCustomLineCap (pen->custom_end_cap, &result->custom_end_cap);
		if (status != Ok)
			goto error;
	}

	if (pen->own_brush) {
		GpSolidFill *oldBrush = (GpSolidFill *) pen->brush;
		GpStatus status = GdipCreateSolidFill (oldBrush->color, (GpSolidFill **) &result->brush);
		if (status != Ok)
			goto error;
	} else {
		result->brush = pen->brush;
	}

	*clonepen = result;
	return Ok;

error:
	GdipDeletePen (result);
	*clonepen = NULL;
	return OutOfMemory;
}
Beispiel #9
0
static void test_worldbounds(void)
{
    GpStatus status;
    GpPath *path;
    GpPen *pen;
    GpMatrix *matrix;
    GpRectF bounds;
    GpPointF line2_points[10];
    int i;

    for(i = 0; i < 10; i ++){
        line2_points[i].X = 200.0 + i * 50.0 * (i % 2);
        line2_points[i].Y = 200.0 + i * 50.0 * !(i % 2);
    }
    GdipCreatePen1((ARGB)0xdeadbeef, 20.0, UnitWorld, &pen);
    GdipSetPenEndCap(pen, LineCapSquareAnchor);
    GdipCreateMatrix2(1.5, 0.0, 1.0, 1.2, 10.4, 10.2, &matrix);

    GdipCreatePath(FillModeAlternate, &path);
    GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0);
    GdipAddPathLine2(path, &(line2_points[0]), 10);
    status = GdipGetPathWorldBounds(path, &bounds, NULL, NULL);
    expect(Ok, status);
    GdipDeletePath(path);

    expectf(200.0, bounds.X);
    expectf(200.0, bounds.Y);
    expectf(450.0, bounds.Width);
    expectf(600.0, bounds.Height);

    GdipCreatePath(FillModeAlternate, &path);
    GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0);
    GdipAddPathLine2(path, &(line2_points[0]), 10);
    status = GdipGetPathWorldBounds(path, &bounds, matrix, NULL);
    expect(Ok, status);
    GdipDeletePath(path);

    expectf(510.4, bounds.X);
    expectf(250.2, bounds.Y);
    expectf(1275.0, bounds.Width);
    expectf(720.0, bounds.Height);

    GdipCreatePath(FillModeAlternate, &path);
    GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0);
    GdipAddPathLine2(path, &(line2_points[0]), 10);
    status = GdipGetPathWorldBounds(path, &bounds, NULL, pen);
    expect(Ok, status);
    GdipDeletePath(path);

    expectf(100.0, bounds.X);
    expectf(100.0, bounds.Y);
    expectf(650.0, bounds.Width);
    expectf(800.0, bounds.Height);

    GdipCreatePath(FillModeAlternate, &path);
    GdipAddPathLine2(path, &(line2_points[0]), 2);
    status = GdipGetPathWorldBounds(path, &bounds, NULL, pen);
    expect(Ok, status);
    GdipDeletePath(path);

    expectf(156.0, bounds.X);
    expectf(156.0, bounds.Y);
    expectf(138.0, bounds.Width);
    expectf(88.0, bounds.Height);

    line2_points[2].X = 2 * line2_points[1].X - line2_points[0].X;
    line2_points[2].Y = 2 * line2_points[1].Y - line2_points[0].Y;

    GdipCreatePath(FillModeAlternate, &path);
    GdipAddPathLine2(path, &(line2_points[0]), 3);
    status = GdipGetPathWorldBounds(path, &bounds, NULL, pen);
    expect(Ok, status);
    GdipDeletePath(path);

    expectf(100.0, bounds.X);
    expectf(100.0, bounds.Y);
    expectf(300.0, bounds.Width);
    expectf(200.0, bounds.Height);

    GdipCreatePath(FillModeAlternate, &path);
    GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 45.0, 20.0);
    status = GdipGetPathWorldBounds(path, &bounds, NULL, pen);
    expect(Ok, status);
    GdipDeletePath(path);

    expectf(386.7, bounds.X);
    expectf(553.4, bounds.Y);
    expectf(266.8, bounds.Width);
    expectf(289.6, bounds.Height);

    GdipCreatePath(FillModeAlternate, &path);
    status = GdipGetPathWorldBounds(path, &bounds, matrix, pen);
    expect(Ok, status);
    GdipDeletePath(path);

    expectf(0.0, bounds.X);
    expectf(0.0, bounds.Y);
    expectf(0.0, bounds.Width);
    expectf(0.0, bounds.Height);

    GdipCreatePath(FillModeAlternate, &path);
    GdipAddPathLine2(path, &(line2_points[0]), 2);
    status = GdipGetPathWorldBounds(path, &bounds, matrix, pen);
    expect(Ok, status);
    GdipDeletePath(path);

    todo_wine{
        expectf(427.9, bounds.X);
        expectf(167.7, bounds.Y);
        expectf(239.9, bounds.Width);
        expectf(164.9, bounds.Height);
    }

    GdipDeleteMatrix(matrix);
    GdipCreateMatrix2(0.9, -0.5, -0.5, -1.2, 10.4, 10.2, &matrix);
    GdipCreatePath(FillModeAlternate, &path);
    GdipAddPathArc(path, 100.0, 100.0, 500.0, 700.0, 0.0, 100.0);
    GdipAddPathLine2(path, &(line2_points[0]), 10);
    status = GdipGetPathWorldBounds(path, &bounds, matrix, NULL);
    expect(Ok, status);
    GdipDeletePath(path);
    GdipDeleteMatrix(matrix);

    expectf(-209.6, bounds.X);
    expectf(-1274.8, bounds.Y);
    expectf(705.0, bounds.Width);
    expectf(945.0, bounds.Height);

    GdipDeletePen(pen);
}
Beispiel #10
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);
}
Beispiel #11
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);
}