static void test_isinfinite(void) { GpStatus status; GpRegion *region; GpGraphics *graphics = NULL; GpMatrix *m; HDC hdc = GetDC(0); BOOL res; status = GdipCreateFromHDC(hdc, &graphics); expect(Ok, status); GdipCreateRegion(®ion); GdipCreateMatrix2(3.0, 0.0, 0.0, 1.0, 20.0, 30.0, &m); /* NULL arguments */ status = GdipIsInfiniteRegion(NULL, NULL, NULL); expect(InvalidParameter, status); status = GdipIsInfiniteRegion(region, NULL, NULL); expect(InvalidParameter, status); status = GdipIsInfiniteRegion(NULL, graphics, NULL); expect(InvalidParameter, status); status = GdipIsInfiniteRegion(NULL, NULL, &res); expect(InvalidParameter, status); status = GdipIsInfiniteRegion(region, NULL, &res); expect(InvalidParameter, status); res = FALSE; status = GdipIsInfiniteRegion(region, graphics, &res); expect(Ok, status); expect(TRUE, res); /* after world transform */ status = GdipSetWorldTransform(graphics, m); expect(Ok, status); res = FALSE; status = GdipIsInfiniteRegion(region, graphics, &res); expect(Ok, status); expect(TRUE, res); GdipDeleteMatrix(m); GdipDeleteRegion(region); GdipDeleteGraphics(graphics); ReleaseDC(0, hdc); }
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); }
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); }
static void test_transform(void) { GpStatus status; GpTexture *texture; GpGraphics *graphics = NULL; GpBitmap *bitmap; HDC hdc = GetDC(0); GpMatrix *m, *m1; BOOL res; status = GdipCreateMatrix2(2.0, 0.0, 0.0, 0.0, 0.0, 0.0, &m); expect(Ok, status); status = GdipCreateFromHDC(hdc, &graphics); expect(Ok, status); status = GdipCreateBitmapFromGraphics(1, 1, graphics, &bitmap); expect(Ok, status); status = GdipCreateTexture((GpImage*)bitmap, WrapModeTile, &texture); expect(Ok, status); /* NULL */ status = GdipGetTextureTransform(NULL, NULL); expect(InvalidParameter, status); status = GdipGetTextureTransform(texture, NULL); expect(InvalidParameter, status); /* get default value - identity matrix */ status = GdipGetTextureTransform(texture, m); expect(Ok, status); status = GdipIsMatrixIdentity(m, &res); expect(Ok, status); expect(TRUE, res); /* set and get then */ status = GdipCreateMatrix2(2.0, 0.0, 0.0, 2.0, 0.0, 0.0, &m1); expect(Ok, status); status = GdipSetTextureTransform(texture, m1); expect(Ok, status); status = GdipGetTextureTransform(texture, m); expect(Ok, status); status = GdipIsMatrixEqual(m, m1, &res); expect(Ok, status); expect(TRUE, res); /* reset */ status = GdipResetTextureTransform(texture); expect(Ok, status); status = GdipGetTextureTransform(texture, m); expect(Ok, status); status = GdipIsMatrixIdentity(m, &res); expect(Ok, status); expect(TRUE, res); status = GdipDeleteBrush((GpBrush*)texture); expect(Ok, status); status = GdipDeleteMatrix(m1); expect(Ok, status); status = GdipDeleteMatrix(m); expect(Ok, status); status = GdipDisposeImage((GpImage*)bitmap); expect(Ok, status); status = GdipDeleteGraphics(graphics); expect(Ok, status); ReleaseDC(0, hdc); }