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 ...@@ -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 ...@@ -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;
rc.left = framerect_factor_x * frameRect->X; lprc = &rc;
rc.top = framerect_factor_y * frameRect->Y; }
rc.right = rc.left + framerect_factor_x * frameRect->Width; else
rc.bottom = rc.top + framerect_factor_y * frameRect->Height; lprc = NULL;
record_dc = CreateEnhMetaFileW(hdc, NULL, &rc, desc); record_dc = CreateEnhMetaFileW(hdc, NULL, lprc, desc);
if (!record_dc) if (!record_dc)
return GenericError; return GenericError;
......
...@@ -876,7 +876,7 @@ static void test_nullframerect(void) { ...@@ -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) { ...@@ -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) { ...@@ -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);
......
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