Commit d23b83a0 authored by Michael Kaufmann's avatar Michael Kaufmann Committed by Alexandre Julliard

gdi32: SetWinMetaFileBits: Use the whole device surface if the METAFILEPICT parameter is NULL.

Also use the whole device surface if one of the extents is zero or negative and the mapping mode is MM_ANISOTROPIC or MM_ISOTROPIC. New tests.
parent dde6d8b1
...@@ -1339,10 +1339,10 @@ BOOL WINAPI PlayEnhMetaFileRecord( ...@@ -1339,10 +1339,10 @@ BOOL WINAPI PlayEnhMetaFileRecord(
if (!lpScaleViewportExtEx->xNum || !lpScaleViewportExtEx->xDenom || if (!lpScaleViewportExtEx->xNum || !lpScaleViewportExtEx->xDenom ||
!lpScaleViewportExtEx->yNum || !lpScaleViewportExtEx->yDenom) !lpScaleViewportExtEx->yNum || !lpScaleViewportExtEx->yDenom)
break; break;
info->vportExtX = (info->vportExtX * lpScaleViewportExtEx->xNum) / info->vportExtX = MulDiv(info->vportExtX, lpScaleViewportExtEx->xNum,
lpScaleViewportExtEx->xDenom; lpScaleViewportExtEx->xDenom);
info->vportExtY = (info->vportExtY * lpScaleViewportExtEx->yNum) / info->vportExtY = MulDiv(info->vportExtY, lpScaleViewportExtEx->yNum,
lpScaleViewportExtEx->yDenom; lpScaleViewportExtEx->yDenom);
if (info->vportExtX == 0) info->vportExtX = 1; if (info->vportExtX == 0) info->vportExtX = 1;
if (info->vportExtY == 0) info->vportExtY = 1; if (info->vportExtY == 0) info->vportExtY = 1;
if (info->mode == MM_ISOTROPIC) if (info->mode == MM_ISOTROPIC)
...@@ -1364,10 +1364,10 @@ BOOL WINAPI PlayEnhMetaFileRecord( ...@@ -1364,10 +1364,10 @@ BOOL WINAPI PlayEnhMetaFileRecord(
if (!lpScaleWindowExtEx->xNum || !lpScaleWindowExtEx->xDenom || if (!lpScaleWindowExtEx->xNum || !lpScaleWindowExtEx->xDenom ||
!lpScaleWindowExtEx->xNum || !lpScaleWindowExtEx->yDenom) !lpScaleWindowExtEx->xNum || !lpScaleWindowExtEx->yDenom)
break; break;
info->wndExtX = (info->wndExtX * lpScaleWindowExtEx->xNum) / info->wndExtX = MulDiv(info->wndExtX, lpScaleWindowExtEx->xNum,
lpScaleWindowExtEx->xDenom; lpScaleWindowExtEx->xDenom);
info->wndExtY = (info->wndExtY * lpScaleWindowExtEx->yNum) / info->wndExtY = MulDiv(info->wndExtY, lpScaleWindowExtEx->yNum,
lpScaleWindowExtEx->yDenom; lpScaleWindowExtEx->yDenom);
if (info->wndExtX == 0) info->wndExtX = 1; if (info->wndExtX == 0) info->wndExtX = 1;
if (info->wndExtY == 0) info->wndExtY = 1; if (info->wndExtY == 0) info->wndExtY = 1;
if (info->mode == MM_ISOTROPIC) if (info->mode == MM_ISOTROPIC)
...@@ -2627,6 +2627,7 @@ HENHMETAFILE WINAPI SetWinMetaFileBits(UINT cbBuffer, ...@@ -2627,6 +2627,7 @@ HENHMETAFILE WINAPI SetWinMetaFileBits(UINT cbBuffer,
RECT rc, *prcFrame = NULL; RECT rc, *prcFrame = NULL;
gdi_mf_comment *mfcomment; gdi_mf_comment *mfcomment;
UINT mfcomment_size; UINT mfcomment_size;
LONG mm, xExt, yExt;
TRACE("(%d, %p, %p, %p)\n", cbBuffer, lpbBuffer, hdcRef, lpmfp); TRACE("(%d, %p, %p, %p)\n", cbBuffer, lpbBuffer, hdcRef, lpmfp);
...@@ -2641,19 +2642,45 @@ HENHMETAFILE WINAPI SetWinMetaFileBits(UINT cbBuffer, ...@@ -2641,19 +2642,45 @@ HENHMETAFILE WINAPI SetWinMetaFileBits(UINT cbBuffer,
hdcRef = hdcdisp = CreateDCW(szDisplayW, NULL, NULL, NULL); hdcRef = hdcdisp = CreateDCW(szDisplayW, NULL, NULL, NULL);
if (lpmfp) if (lpmfp)
{
TRACE("mm = %ld %ldx%ld\n", lpmfp->mm, lpmfp->xExt, lpmfp->yExt); TRACE("mm = %ld %ldx%ld\n", lpmfp->mm, lpmfp->xExt, lpmfp->yExt);
if (lpmfp && (lpmfp->mm == MM_ISOTROPIC || lpmfp->mm == MM_ANISOTROPIC)) mm = lpmfp->mm;
xExt = lpmfp->xExt;
yExt = lpmfp->yExt;
}
else
{ {
rc.left = rc.top = 0; TRACE("lpmfp == NULL\n");
rc.right = lpmfp->xExt;
rc.bottom = lpmfp->yExt; /* Use the whole device surface */
prcFrame = &rc; mm = MM_ANISOTROPIC;
xExt = 0;
yExt = 0;
}
if (mm == MM_ISOTROPIC || mm == MM_ANISOTROPIC)
{
if (xExt < 0 || yExt < 0)
{
/* Use the whole device surface */
xExt = 0;
yExt = 0;
}
/* Use the x and y extents as the frame box */
if (xExt && yExt)
{
rc.left = rc.top = 0;
rc.right = xExt;
rc.bottom = yExt;
prcFrame = &rc;
}
} }
if(!(hdc = CreateEnhMetaFileW(hdcRef, NULL, prcFrame, NULL))) if(!(hdc = CreateEnhMetaFileW(hdcRef, NULL, prcFrame, NULL)))
{ {
ERR("CreateEnhMetaFile fails?\n"); ERR("CreateEnhMetaFile failed\n");
goto end; goto end;
} }
...@@ -2676,23 +2703,33 @@ HENHMETAFILE WINAPI SetWinMetaFileBits(UINT cbBuffer, ...@@ -2676,23 +2703,33 @@ HENHMETAFILE WINAPI SetWinMetaFileBits(UINT cbBuffer,
HeapFree(GetProcessHeap(), 0, mfcomment); HeapFree(GetProcessHeap(), 0, mfcomment);
} }
if(lpmfp && lpmfp->mm != MM_TEXT) if (mm != MM_TEXT)
SetMapMode(hdc, lpmfp->mm); SetMapMode(hdc, mm);
if (lpmfp && (lpmfp->mm == MM_ISOTROPIC || lpmfp->mm == MM_ANISOTROPIC)) if (mm == MM_ISOTROPIC || mm == MM_ANISOTROPIC)
{ {
INT horzres, vertres, horzsize, vertsize, xext, yext; INT horzsize, vertsize, horzres, vertres;
horzres = GetDeviceCaps(hdcRef, HORZRES);
vertres = GetDeviceCaps(hdcRef, VERTRES);
horzsize = GetDeviceCaps(hdcRef, HORZSIZE); horzsize = GetDeviceCaps(hdcRef, HORZSIZE);
vertsize = GetDeviceCaps(hdcRef, VERTSIZE); vertsize = GetDeviceCaps(hdcRef, VERTSIZE);
horzres = GetDeviceCaps(hdcRef, HORZRES);
vertres = GetDeviceCaps(hdcRef, VERTRES);
if (!xExt || !yExt)
{
/* Use the whole device surface */
xExt = horzres;
yExt = vertres;
}
else
{
xExt = MulDiv(xExt, horzres, 100 * horzsize);
yExt = MulDiv(yExt, vertres, 100 * vertsize);
}
/* set the initial viewport:window ratio as 1:1 */ /* set the initial viewport:window ratio as 1:1 */
xext = lpmfp->xExt*horzres/(100*horzsize); SetViewportExtEx(hdc, xExt, yExt, NULL);
yext = lpmfp->yExt*vertres/(100*vertsize); SetWindowExtEx(hdc, xExt, yExt, NULL);
SetViewportExtEx(hdc, xext, yext, NULL);
SetWindowExtEx(hdc, xext, yext, NULL);
} }
PlayMetaFile(hdc, hmf); PlayMetaFile(hdc, hmf);
......
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