Resend: SetWinMetaFileBits: Scale the picture to the whole device
surface if lpmfp == NULL
Michael Kaufmann
hallo at michael-kaufmann.ch
Sat Feb 18 15:46:47 CST 2006
Changelog:
SetWinMetaFileBits:
- Isotropic/Anisotropic mapping mode: Scale the picture to the whole
device surface if lpmfp == NULL (current implementation doesn't set the
window and viewport extents in this case, leading to upside-down images
or other strange effects). Also use the whole device surface if the x
extent or the y extent is zero or negative (MSDN says something about
aspect ratios, but that is not implemented in Windows)
- Other mapping modes: Ignore the specified extents (let the GDI
calculate them)
-------------- next part --------------
Index: dlls/gdi/enhmetafile.c
===================================================================
RCS file: /home/wine/wine/dlls/gdi/enhmetafile.c,v
retrieving revision 1.18
diff -u -r1.18 enhmetafile.c
--- dlls/gdi/enhmetafile.c 31 Jan 2006 12:08:13 -0000 1.18
+++ dlls/gdi/enhmetafile.c 1 Feb 2006 21:55:58 -0000
@@ -2626,6 +2626,7 @@
RECT rc, *prcFrame = NULL;
gdi_mf_comment *mfcomment;
UINT mfcomment_size;
+ LONG mm, xExt, yExt;
TRACE("(%d, %p, %p, %p)\n", cbBuffer, lpbBuffer, hdcRef, lpmfp);
@@ -2640,19 +2641,46 @@
hdcRef = hdcdisp = CreateDCW(szDisplayW, NULL, NULL, NULL);
if (lpmfp)
+ {
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;
- rc.right = lpmfp->xExt;
- rc.bottom = lpmfp->yExt;
- prcFrame = &rc;
+ TRACE("lpmfp == NULL\n");
+
+ /* Scale the metafile to the whole device surface */
+ 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 = 100 * GetDeviceCaps(hdcRef, HORZSIZE);
+ yExt = 100 * GetDeviceCaps(hdcRef, VERTSIZE);
+ }
+
+ /* The dimensions for MM_ISOTROPIC will be adjusted later,
+ don't use them here */
+ if (mm != MM_ISOTROPIC)
+ {
+ rc.left = rc.top = 0;
+ rc.right = xExt;
+ rc.bottom = yExt;
+ prcFrame = &rc;
+ }
+ }
+
if(!(hdc = CreateEnhMetaFileW(hdcRef, NULL, prcFrame, NULL)))
{
- ERR("CreateEnhMetaFile fails?\n");
+ ERR("CreateEnhMetaFile failed\n");
goto end;
}
@@ -2675,23 +2703,24 @@
HeapFree(GetProcessHeap(), 0, mfcomment);
}
- if(lpmfp && lpmfp->mm != MM_TEXT)
- SetMapMode(hdc, lpmfp->mm);
+ if (mm != MM_TEXT)
+ 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);
vertsize = GetDeviceCaps(hdcRef, VERTSIZE);
+ horzres = GetDeviceCaps(hdcRef, HORZRES);
+ vertres = GetDeviceCaps(hdcRef, VERTRES);
+
+ xExt = xExt*horzres/(100*horzsize);
+ yExt = yExt*vertres/(100*vertsize);
/* set the initial viewport:window ratio as 1:1 */
- xext = lpmfp->xExt*horzres/(100*horzsize);
- yext = lpmfp->yExt*vertres/(100*vertsize);
- SetViewportExtEx(hdc, xext, yext, NULL);
- SetWindowExtEx(hdc, xext, yext, NULL);
+ SetViewportExtEx(hdc, xExt, yExt, NULL);
+ SetWindowExtEx(hdc, xExt, yExt, NULL);
}
PlayMetaFile(hdc, hmf);
More information about the wine-patches
mailing list