gdiplus: Add tests and fix GdipDrawImagePointsRect.
This commit is contained in:
parent
fe8e08a5d6
commit
c057694883
|
@ -2161,6 +2161,9 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
|
||||||
count, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback,
|
count, srcx, srcy, srcwidth, srcheight, srcUnit, imageAttributes, callback,
|
||||||
callbackData);
|
callbackData);
|
||||||
|
|
||||||
|
if (count > 3)
|
||||||
|
return NotImplemented;
|
||||||
|
|
||||||
if(!graphics || !image || !points || count != 3)
|
if(!graphics || !image || !points || count != 3)
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
|
||||||
|
@ -2170,6 +2173,8 @@ GpStatus WINGDIPAPI GdipDrawImagePointsRect(GpGraphics *graphics, GpImage *image
|
||||||
memcpy(ptf, points, 3 * sizeof(GpPointF));
|
memcpy(ptf, points, 3 * sizeof(GpPointF));
|
||||||
ptf[3].X = ptf[2].X + ptf[1].X - ptf[0].X;
|
ptf[3].X = ptf[2].X + ptf[1].X - ptf[0].X;
|
||||||
ptf[3].Y = ptf[2].Y + ptf[1].Y - ptf[0].Y;
|
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);
|
transform_and_round_points(graphics, pti, ptf, 4);
|
||||||
|
|
||||||
if (image->picture)
|
if (image->picture)
|
||||||
|
|
|
@ -1130,6 +1130,60 @@ static void test_GdipDrawLineI(void)
|
||||||
ReleaseDC(hwnd, hdc);
|
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)
|
static void test_GdipDrawLinesI(void)
|
||||||
{
|
{
|
||||||
GpStatus status;
|
GpStatus status;
|
||||||
|
@ -1603,6 +1657,7 @@ static void test_Get_Release_DC(void)
|
||||||
expect(ObjectBusy, status);
|
expect(ObjectBusy, status);
|
||||||
status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, 5);
|
status = GdipTransformPoints(graphics, CoordinateSpacePage, CoordinateSpaceWorld, ptf, 5);
|
||||||
expect(ObjectBusy, status);
|
expect(ObjectBusy, status);
|
||||||
|
|
||||||
/* try to delete before release */
|
/* try to delete before release */
|
||||||
status = GdipDeleteGraphics(graphics);
|
status = GdipDeleteGraphics(graphics);
|
||||||
expect(ObjectBusy, status);
|
expect(ObjectBusy, status);
|
||||||
|
@ -2998,6 +3053,7 @@ START_TEST(graphics)
|
||||||
test_GdipDrawCurve3I();
|
test_GdipDrawCurve3I();
|
||||||
test_GdipDrawLineI();
|
test_GdipDrawLineI();
|
||||||
test_GdipDrawLinesI();
|
test_GdipDrawLinesI();
|
||||||
|
test_GdipDrawImagePointsRect();
|
||||||
test_GdipFillClosedCurve();
|
test_GdipFillClosedCurve();
|
||||||
test_GdipFillClosedCurveI();
|
test_GdipFillClosedCurveI();
|
||||||
test_GdipDrawString();
|
test_GdipDrawString();
|
||||||
|
|
Loading…
Reference in New Issue