Commit 4ed1b4f5 authored by Vincent Povirk's avatar Vincent Povirk Committed by Alexandre Julliard

gdiplus: Allow recording metafiles with a NULL frame.

parent 1e67fcce
......@@ -195,7 +195,7 @@ GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF
HDC record_dc;
REAL dpix, dpiy;
REAL framerect_factor_x, framerect_factor_y;
RECT rc;
RECT rc, *lprc;
GpStatus stat;
TRACE("(%p %d %p %d %p %p)\n", hdc, type, frameRect, frameUnit, desc, metafile);
......@@ -203,46 +203,47 @@ GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF
if (!hdc || type < EmfTypeEmfOnly || type > EmfTypeEmfPlusDual || !metafile)
return InvalidParameter;
if (!frameRect)
{
FIXME("not implemented for NULL rect\n");
return NotImplemented;
}
dpix = (REAL)GetDeviceCaps(hdc, HORZRES) / GetDeviceCaps(hdc, HORZSIZE) * 25.4;
dpiy = (REAL)GetDeviceCaps(hdc, VERTRES) / GetDeviceCaps(hdc, VERTSIZE) * 25.4;
switch (frameUnit)
if (frameRect)
{
case MetafileFrameUnitPixel:
framerect_factor_x = 2540.0 / dpix;
framerect_factor_y = 2540.0 / dpiy;
break;
case MetafileFrameUnitPoint:
framerect_factor_x = framerect_factor_y = 2540.0 / 72.0;
break;
case MetafileFrameUnitInch:
framerect_factor_x = framerect_factor_y = 2540.0;
break;
case MetafileFrameUnitDocument:
framerect_factor_x = framerect_factor_y = 2540.0 / 300.0;
break;
case MetafileFrameUnitMillimeter:
framerect_factor_x = framerect_factor_y = 100.0;
break;
case MetafileFrameUnitGdi:
framerect_factor_x = framerect_factor_y = 1.0;
break;
default:
return InvalidParameter;
}
switch (frameUnit)
{
case MetafileFrameUnitPixel:
framerect_factor_x = 2540.0 / dpix;
framerect_factor_y = 2540.0 / dpiy;
break;
case MetafileFrameUnitPoint:
framerect_factor_x = framerect_factor_y = 2540.0 / 72.0;
break;
case MetafileFrameUnitInch:
framerect_factor_x = framerect_factor_y = 2540.0;
break;
case MetafileFrameUnitDocument:
framerect_factor_x = framerect_factor_y = 2540.0 / 300.0;
break;
case MetafileFrameUnitMillimeter:
framerect_factor_x = framerect_factor_y = 100.0;
break;
case MetafileFrameUnitGdi:
framerect_factor_x = framerect_factor_y = 1.0;
break;
default:
return InvalidParameter;
}
rc.left = framerect_factor_x * frameRect->X;
rc.top = framerect_factor_y * frameRect->Y;
rc.right = rc.left + framerect_factor_x * frameRect->Width;
rc.bottom = rc.top + framerect_factor_y * frameRect->Height;
rc.left = framerect_factor_x * frameRect->X;
rc.top = framerect_factor_y * frameRect->Y;
rc.right = rc.left + framerect_factor_x * frameRect->Width;
rc.bottom = rc.top + framerect_factor_y * frameRect->Height;
lprc = &rc;
}
else
lprc = NULL;
record_dc = CreateEnhMetaFileW(hdc, NULL, &rc, desc);
record_dc = CreateEnhMetaFileW(hdc, NULL, lprc, desc);
if (!record_dc)
return GenericError;
......
......@@ -876,7 +876,7 @@ static void test_nullframerect(void) {
hdc = CreateCompatibleDC(0);
stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, NULL, MetafileFrameUnitPixel, description, &metafile);
todo_wine expect(Ok, stat);
expect(Ok, stat);
DeleteDC(hdc);
......@@ -917,10 +917,10 @@ static void test_nullframerect(void) {
stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
expect(Ok, stat);
expect(UnitPixel, unit);
expectf_(25.0, bounds.X, 0.05);
expectf_(25.0, bounds.Y, 0.05);
expectf_(75.0, bounds.Width, 0.05);
expectf_(75.0, bounds.Height, 0.05);
todo_wine expectf_(25.0, bounds.X, 0.05);
todo_wine expectf_(25.0, bounds.Y, 0.05);
todo_wine expectf_(75.0, bounds.Width, 0.05);
todo_wine expectf_(75.0, bounds.Height, 0.05);
stat = GdipDisposeImage((GpImage*)metafile);
expect(Ok, stat);
......@@ -966,8 +966,8 @@ static void test_nullframerect(void) {
expect(UnitPixel, unit);
expectf_(25.0, bounds.X, 0.05);
expectf_(25.0, bounds.Y, 0.05);
expectf_(50.0, bounds.Width, 0.05);
expectf_(50.0, bounds.Height, 0.05);
todo_wine expectf_(50.0, bounds.Width, 0.05);
todo_wine expectf_(50.0, bounds.Height, 0.05);
stat = GdipDisposeImage((GpImage*)metafile);
expect(Ok, stat);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment