gdiplus: Allow recording metafiles with a NULL frame.

Signed-off-by: Vincent Povirk <vincent@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Vincent Povirk 2016-04-06 14:36:57 -05:00 committed by Alexandre Julliard
parent 1e67fcce9d
commit 4ed1b4f5e8
2 changed files with 43 additions and 42 deletions

View File

@ -195,7 +195,7 @@ GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF
HDC record_dc; HDC record_dc;
REAL dpix, dpiy; REAL dpix, dpiy;
REAL framerect_factor_x, framerect_factor_y; REAL framerect_factor_x, framerect_factor_y;
RECT rc; RECT rc, *lprc;
GpStatus stat; GpStatus stat;
TRACE("(%p %d %p %d %p %p)\n", hdc, type, frameRect, frameUnit, desc, metafile); 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) if (!hdc || type < EmfTypeEmfOnly || type > EmfTypeEmfPlusDual || !metafile)
return InvalidParameter; return InvalidParameter;
if (!frameRect)
{
FIXME("not implemented for NULL rect\n");
return NotImplemented;
}
dpix = (REAL)GetDeviceCaps(hdc, HORZRES) / GetDeviceCaps(hdc, HORZSIZE) * 25.4; dpix = (REAL)GetDeviceCaps(hdc, HORZRES) / GetDeviceCaps(hdc, HORZSIZE) * 25.4;
dpiy = (REAL)GetDeviceCaps(hdc, VERTRES) / GetDeviceCaps(hdc, VERTSIZE) * 25.4; dpiy = (REAL)GetDeviceCaps(hdc, VERTRES) / GetDeviceCaps(hdc, VERTSIZE) * 25.4;
switch (frameUnit) if (frameRect)
{ {
case MetafileFrameUnitPixel: switch (frameUnit)
framerect_factor_x = 2540.0 / dpix; {
framerect_factor_y = 2540.0 / dpiy; case MetafileFrameUnitPixel:
break; framerect_factor_x = 2540.0 / dpix;
case MetafileFrameUnitPoint: framerect_factor_y = 2540.0 / dpiy;
framerect_factor_x = framerect_factor_y = 2540.0 / 72.0; break;
break; case MetafileFrameUnitPoint:
case MetafileFrameUnitInch: framerect_factor_x = framerect_factor_y = 2540.0 / 72.0;
framerect_factor_x = framerect_factor_y = 2540.0; break;
break; case MetafileFrameUnitInch:
case MetafileFrameUnitDocument: framerect_factor_x = framerect_factor_y = 2540.0;
framerect_factor_x = framerect_factor_y = 2540.0 / 300.0; break;
break; case MetafileFrameUnitDocument:
case MetafileFrameUnitMillimeter: framerect_factor_x = framerect_factor_y = 2540.0 / 300.0;
framerect_factor_x = framerect_factor_y = 100.0; break;
break; case MetafileFrameUnitMillimeter:
case MetafileFrameUnitGdi: framerect_factor_x = framerect_factor_y = 100.0;
framerect_factor_x = framerect_factor_y = 1.0; break;
break; case MetafileFrameUnitGdi:
default: framerect_factor_x = framerect_factor_y = 1.0;
return InvalidParameter; 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;
lprc = &rc;
} }
else
lprc = NULL;
rc.left = framerect_factor_x * frameRect->X; record_dc = CreateEnhMetaFileW(hdc, NULL, lprc, desc);
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;
record_dc = CreateEnhMetaFileW(hdc, NULL, &rc, desc);
if (!record_dc) if (!record_dc)
return GenericError; return GenericError;

View File

@ -876,7 +876,7 @@ static void test_nullframerect(void) {
hdc = CreateCompatibleDC(0); hdc = CreateCompatibleDC(0);
stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, NULL, MetafileFrameUnitPixel, description, &metafile); stat = GdipRecordMetafile(hdc, EmfTypeEmfPlusOnly, NULL, MetafileFrameUnitPixel, description, &metafile);
todo_wine expect(Ok, stat); expect(Ok, stat);
DeleteDC(hdc); DeleteDC(hdc);
@ -917,10 +917,10 @@ static void test_nullframerect(void) {
stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit); stat = GdipGetImageBounds((GpImage*)metafile, &bounds, &unit);
expect(Ok, stat); expect(Ok, stat);
expect(UnitPixel, unit); expect(UnitPixel, unit);
expectf_(25.0, bounds.X, 0.05); todo_wine expectf_(25.0, bounds.X, 0.05);
expectf_(25.0, bounds.Y, 0.05); todo_wine expectf_(25.0, bounds.Y, 0.05);
expectf_(75.0, bounds.Width, 0.05); todo_wine expectf_(75.0, bounds.Width, 0.05);
expectf_(75.0, bounds.Height, 0.05); todo_wine expectf_(75.0, bounds.Height, 0.05);
stat = GdipDisposeImage((GpImage*)metafile); stat = GdipDisposeImage((GpImage*)metafile);
expect(Ok, stat); expect(Ok, stat);
@ -966,8 +966,8 @@ static void test_nullframerect(void) {
expect(UnitPixel, unit); expect(UnitPixel, unit);
expectf_(25.0, bounds.X, 0.05); expectf_(25.0, bounds.X, 0.05);
expectf_(25.0, bounds.Y, 0.05); expectf_(25.0, bounds.Y, 0.05);
expectf_(50.0, bounds.Width, 0.05); todo_wine expectf_(50.0, bounds.Width, 0.05);
expectf_(50.0, bounds.Height, 0.05); todo_wine expectf_(50.0, bounds.Height, 0.05);
stat = GdipDisposeImage((GpImage*)metafile); stat = GdipDisposeImage((GpImage*)metafile);
expect(Ok, stat); expect(Ok, stat);