Module: wine Branch: master Commit: c0576948833522e71aa9cc2c77ce5d515b473d2f URL: http://source.winehq.org/git/wine.git/?a=commit;h=c0576948833522e71aa9cc2c77...
Author: Maarten Lankhorst m.b.lankhorst@gmail.com Date: Thu Feb 17 10:51:33 2011 +0100
gdiplus: Add tests and fix GdipDrawImagePointsRect.
---
dlls/gdiplus/graphics.c | 5 +++ dlls/gdiplus/tests/graphics.c | 56 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 61 insertions(+), 0 deletions(-)
diff --git a/dlls/gdiplus/graphics.c b/dlls/gdiplus/graphics.c index 65700da..5f226e9 100644 --- a/dlls/gdiplus/graphics.c +++ b/dlls/gdiplus/graphics.c @@ -2161,6 +2161,9 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image count, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback, callbackData);
+ if (count > 3) + return NotImplemented; + if(!graphics || !image || !points || count != 3) return InvalidParameter;
@@ -2170,6 +2173,8 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image memcpy(ptf, points, 3 * sizeof(GpPointF)); ptf[3].X = ptf[2].X + ptf[1].X - ptf[0].X; ptf[3].Y = ptf[2].Y + ptf[1].Y - ptf[0].Y; + if (!srcwidth || !srcheight || ptf[3].X == ptf[0].X || ptf[3].Y == ptf[0].Y) + return Ok; transform_and_round_points(graphics, pti, ptf, 4);
if (image->picture) diff --git a/dlls/gdiplus/tests/graphics.c b/dlls/gdiplus/tests/graphics.c index 9a746b1..275c237 100644 --- a/dlls/gdiplus/tests/graphics.c +++ b/dlls/gdiplus/tests/graphics.c @@ -1130,6 +1130,60 @@ static void test_GdipDrawLineI(void) ReleaseDC(hwnd, hdc); }
+static void test_GdipDrawImagePointsRect(void) +{ + GpStatus status; + GpGraphics *graphics = NULL; + GpPointF ptf[4]; + GpBitmap *bm = NULL; + BYTE rbmi[sizeof(BITMAPINFOHEADER)]; + BYTE buff[400]; + BITMAPINFO *bmi = (BITMAPINFO*)rbmi; + HDC hdc = GetDC( hwnd ); + if (!hdc) + return; + + memset(rbmi, 0, sizeof(rbmi)); + bmi->bmiHeader.biSize = sizeof(BITMAPINFOHEADER); + bmi->bmiHeader.biWidth = 10; + bmi->bmiHeader.biHeight = 10; + bmi->bmiHeader.biPlanes = 1; + bmi->bmiHeader.biBitCount = 32; + bmi->bmiHeader.biCompression = BI_RGB; + status = GdipCreateBitmapFromGdiDib(bmi, buff, &bm); + expect(Ok, status); + ok(NULL != bm, "Expected bitmap to be initialized\n"); + status = GdipCreateFromHDC(hdc, &graphics); + expect(Ok, status); + ptf[0].X = 0; + ptf[0].Y = 0; + ptf[1].X = 10; + ptf[1].Y = 0; + ptf[2].X = 0; + ptf[2].Y = 10; + ptf[3].X = 10; + ptf[3].Y = 10; + status = GdipDrawImagePointsRect(graphics, (GpImage*)bm, ptf, 4, 0, 0, 10, 10, UnitPixel, NULL, NULL, NULL); + expect(NotImplemented, status); + status = GdipDrawImagePointsRect(graphics, (GpImage*)bm, ptf, 2, 0, 0, 10, 10, UnitPixel, NULL, NULL, NULL); + expect(InvalidParameter, status); + status = GdipDrawImagePointsRect(graphics, (GpImage*)bm, ptf, 3, 0, 0, 10, 10, UnitPixel, NULL, NULL, NULL); + expect(Ok, status); + status = GdipDrawImagePointsRect(graphics, NULL, ptf, 3, 0, 0, 10, 10, UnitPixel, NULL, NULL, NULL); + expect(InvalidParameter, status); + status = GdipDrawImagePointsRect(graphics, (GpImage*)bm, NULL, 3, 0, 0, 10, 10, UnitPixel, NULL, NULL, NULL); + expect(InvalidParameter, status); + status = GdipDrawImagePointsRect(graphics, (GpImage*)bm, ptf, 3, 0, 0, 0, 0, UnitPixel, NULL, NULL, NULL); + expect(Ok, status); + memset(ptf, 0, sizeof(ptf)); + status = GdipDrawImagePointsRect(graphics, (GpImage*)bm, ptf, 3, 0, 0, 10, 10, UnitPixel, NULL, NULL, NULL); + expect(Ok, status); + + GdipDisposeImage((GpImage*)bm); + GdipDeleteGraphics(graphics); + ReleaseDC(hwnd, hdc); +} + static void test_GdipDrawLinesI(void) { GpStatus status; @@ -1603,6 +1657,7 @@ static void test_Get_Release_DC(void) expect(ObjectBusy, status); status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, 5); expect(ObjectBusy, status); + /* try to delete before release */ status = GdipDeleteGraphics(graphics); expect(ObjectBusy, status); @@ -2998,6 +3053,7 @@ START_TEST(graphics) test_GdipDrawCurve3I(); test_GdipDrawLineI(); test_GdipDrawLinesI(); + test_GdipDrawImagePointsRect(); test_GdipFillClosedCurve(); test_GdipFillClosedCurveI(); test_GdipDrawString();