gdiplus: Use reference device to determine created metafile resolution.
Signed-off-by: Vincent Povirk <vincent@codeweavers.com> Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
parent
233f1c1b88
commit
1735a7240e
|
@ -193,6 +193,7 @@ GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF
|
|||
MetafileFrameUnit frameUnit, GDIPCONST WCHAR *desc, GpMetafile **metafile)
|
||||
{
|
||||
HDC record_dc;
|
||||
REAL dpix, dpiy;
|
||||
REAL framerect_factor_x, framerect_factor_y;
|
||||
RECT rc;
|
||||
GpStatus stat;
|
||||
|
@ -208,11 +209,14 @@ GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF
|
|||
return NotImplemented;
|
||||
}
|
||||
|
||||
dpix = (REAL)GetDeviceCaps(hdc, HORZRES) / GetDeviceCaps(hdc, HORZSIZE) * 25.4;
|
||||
dpiy = (REAL)GetDeviceCaps(hdc, VERTRES) / GetDeviceCaps(hdc, VERTSIZE) * 25.4;
|
||||
|
||||
switch (frameUnit)
|
||||
{
|
||||
case MetafileFrameUnitPixel:
|
||||
framerect_factor_x = 2540.0 / GetDeviceCaps(hdc, LOGPIXELSX);
|
||||
framerect_factor_y = 2540.0 / GetDeviceCaps(hdc, LOGPIXELSY);
|
||||
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;
|
||||
|
@ -254,8 +258,8 @@ GpStatus WINGDIPAPI GdipRecordMetafile(HDC hdc, EmfType type, GDIPCONST GpRectF
|
|||
(*metafile)->image.picture = NULL;
|
||||
(*metafile)->image.flags = ImageFlagsNone;
|
||||
(*metafile)->image.palette = NULL;
|
||||
(*metafile)->image.xres = 72.0;
|
||||
(*metafile)->image.yres = 72.0;
|
||||
(*metafile)->image.xres = dpix;
|
||||
(*metafile)->image.yres = dpiy;
|
||||
(*metafile)->bounds = *frameRect;
|
||||
(*metafile)->unit = frameUnit;
|
||||
(*metafile)->metafile_type = type;
|
||||
|
|
|
@ -373,10 +373,10 @@ static void test_empty(void)
|
|||
expect(U(header).EmfHeader.nBytes, header.Size);
|
||||
ok(header.Version == 0xdbc01001 || header.Version == 0xdbc01002, "Unexpected version %x\n", header.Version);
|
||||
expect(1, header.EmfPlusFlags); /* reference device was display, not printer */
|
||||
todo_wine expectf(xres, header.DpiX);
|
||||
todo_wine expectf(xres, U(header).EmfHeader.szlDevice.cx / (REAL)U(header).EmfHeader.szlMillimeters.cx * 25.4);
|
||||
todo_wine expectf(yres, header.DpiY);
|
||||
todo_wine expectf(yres, U(header).EmfHeader.szlDevice.cy / (REAL)U(header).EmfHeader.szlMillimeters.cy * 25.4);
|
||||
expectf(xres, header.DpiX);
|
||||
expectf(xres, U(header).EmfHeader.szlDevice.cx / (REAL)U(header).EmfHeader.szlMillimeters.cx * 25.4);
|
||||
expectf(yres, header.DpiY);
|
||||
expectf(yres, U(header).EmfHeader.szlDevice.cy / (REAL)U(header).EmfHeader.szlMillimeters.cy * 25.4);
|
||||
expect(0, header.X);
|
||||
expect(0, header.Y);
|
||||
expect(100, header.Width);
|
||||
|
@ -391,8 +391,8 @@ static void test_empty(void)
|
|||
expect(-1, U(header).EmfHeader.rclBounds.bottom);
|
||||
expect(0, U(header).EmfHeader.rclFrame.left);
|
||||
expect(0, U(header).EmfHeader.rclFrame.top);
|
||||
todo_wine expectf_(100.0, U(header).EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
|
||||
todo_wine expectf_(100.0, U(header).EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
|
||||
expectf_(100.0, U(header).EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
|
||||
expectf_(100.0, U(header).EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
|
||||
|
||||
stat = GdipCreateMetafileFromEmf(hemf, TRUE, &metafile);
|
||||
expect(Ok, stat);
|
||||
|
@ -720,10 +720,10 @@ static void test_emfonly(void)
|
|||
expect(U(header).EmfHeader.nBytes, header.Size);
|
||||
expect(0x10000, header.Version);
|
||||
expect(0, header.EmfPlusFlags);
|
||||
todo_wine expectf(xres, header.DpiX);
|
||||
todo_wine expectf(xres, U(header).EmfHeader.szlDevice.cx / (REAL)U(header).EmfHeader.szlMillimeters.cx * 25.4);
|
||||
todo_wine expectf(yres, header.DpiY);
|
||||
todo_wine expectf(yres, U(header).EmfHeader.szlDevice.cy / (REAL)U(header).EmfHeader.szlMillimeters.cy * 25.4);
|
||||
expectf(xres, header.DpiX);
|
||||
expectf(xres, U(header).EmfHeader.szlDevice.cx / (REAL)U(header).EmfHeader.szlMillimeters.cx * 25.4);
|
||||
expectf(yres, header.DpiY);
|
||||
expectf(yres, U(header).EmfHeader.szlDevice.cy / (REAL)U(header).EmfHeader.szlMillimeters.cy * 25.4);
|
||||
expect(0, header.X);
|
||||
expect(0, header.Y);
|
||||
expect(100, header.Width);
|
||||
|
@ -738,8 +738,8 @@ static void test_emfonly(void)
|
|||
expect(74, U(header).EmfHeader.rclBounds.bottom);
|
||||
expect(0, U(header).EmfHeader.rclFrame.left);
|
||||
expect(0, U(header).EmfHeader.rclFrame.top);
|
||||
todo_wine expectf_(100.0, U(header).EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
|
||||
todo_wine expectf_(100.0, U(header).EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
|
||||
expectf_(100.0, U(header).EmfHeader.rclFrame.right * xres / 2540.0, 2.0);
|
||||
expectf_(100.0, U(header).EmfHeader.rclFrame.bottom * yres / 2540.0, 2.0);
|
||||
|
||||
stat = GdipCreateMetafileFromEmf(hemf, TRUE, &metafile);
|
||||
expect(Ok, stat);
|
||||
|
|
Loading…
Reference in New Issue