Several fixes for playing enhanced metafiles in a given rectangle.

This commit is contained in:
Eric Kohl 2001-01-24 19:38:38 +00:00 committed by Alexandre Julliard
parent 08936ff97a
commit d40ef6bfe4
1 changed files with 62 additions and 49 deletions

View File

@ -638,17 +638,19 @@ BOOL WINAPI PlayEnhMetaFileRecord(
} }
case EMR_EXTTEXTOUTW: case EMR_EXTTEXTOUTW:
{ {
/* 0-3: ??? */ /* 0-3: rect ??? */
DWORD flags = mr->dParm[4]; DWORD flags = mr->dParm[4];
/* 5, 6: ??? */ /* 5, 6: ??? */
DWORD x = mr->dParm[7], y = mr->dParm[8]; DWORD x = mr->dParm[7], y = mr->dParm[8];
DWORD count = mr->dParm[9]; DWORD count = mr->dParm[9];
/* 10-16: ??? */ LPWSTR str = (LPWSTR)((char *)mr + mr->dParm[10]);
LPWSTR str = (LPWSTR)& mr->dParm[17]; /* 11: ??? */
/* trailing info: dx array? */ /* 12-15: rect ???*/
FIXME("Many ExtTextOut args not handled\n"); LPINT lpDx = (LPINT)((char *)mr + mr->dParm[16]);
ExtTextOutW(hdc, x, y, flags, /* lpRect */ NULL,
str, count, /* lpDx */ NULL); FIXME("Some ExtTextOut args not handled\n");
ExtTextOutW(hdc, x, y, flags, NULL,
str, count, lpDx);
break; break;
} }
@ -666,9 +668,12 @@ BOOL WINAPI PlayEnhMetaFileRecord(
{ {
PEMRSELECTPALETTE lpSelectPal = (PEMRSELECTPALETTE)mr; PEMRSELECTPALETTE lpSelectPal = (PEMRSELECTPALETTE)mr;
/* FIXME: Should this be forcing background mode? */ if( lpSelectPal->ihPal & 0x80000000 ) {
(handletable->objectHandle)[ lpSelectPal->ihPal ] = SelectPalette( hdc, GetStockObject(lpSelectPal->ihPal & 0x7fffffff), TRUE);
SelectPalette( hdc, (handletable->objectHandle)[lpSelectPal->ihPal], FALSE ); } else {
(handletable->objectHandle)[ lpSelectPal->ihPal ] =
SelectPalette( hdc, (handletable->objectHandle)[lpSelectPal->ihPal], TRUE);
}
break; break;
} }
@ -704,9 +709,7 @@ BOOL WINAPI PlayEnhMetaFileRecord(
case EMR_SETWORLDTRANSFORM: case EMR_SETWORLDTRANSFORM:
{ {
PEMRSETWORLDTRANSFORM lpXfrm = (PEMRSETWORLDTRANSFORM)mr; PEMRSETWORLDTRANSFORM lpXfrm = (PEMRSETWORLDTRANSFORM)mr;
SetWorldTransform( hdc, &lpXfrm->xform ); SetWorldTransform( hdc, &lpXfrm->xform );
break; break;
} }
@ -870,7 +873,7 @@ BOOL WINAPI PlayEnhMetaFileRecord(
{ {
PEMRMODIFYWORLDTRANSFORM lpModifyWorldTrans = (PEMRMODIFYWORLDTRANSFORM)mr; PEMRMODIFYWORLDTRANSFORM lpModifyWorldTrans = (PEMRMODIFYWORLDTRANSFORM)mr;
ModifyWorldTransform( hdc, &lpModifyWorldTrans->xform, ModifyWorldTransform( hdc, &lpModifyWorldTrans->xform,
lpModifyWorldTrans->iMode ); lpModifyWorldTrans->iMode );
break; break;
@ -1219,9 +1222,11 @@ BOOL WINAPI EnumEnhMetaFile(
INT savedMode = 0; INT savedMode = 0;
FLOAT xSrcPixSize, ySrcPixSize, xscale, yscale; FLOAT xSrcPixSize, ySrcPixSize, xscale, yscale;
XFORM savedXform, xform; XFORM savedXform, xform;
HPEN hPen; HPEN hPen = (HPEN)NULL;
HBRUSH hBrush; HBRUSH hBrush = (HBRUSH)NULL;
HFONT hFont; HFONT hFont = (HFONT)NULL;
XFORM outXform;
if(!lpRect) if(!lpRect)
{ {
@ -1257,33 +1262,37 @@ BOOL WINAPI EnumEnhMetaFile(
} }
ht->objectHandle[0] = hmf; ht->objectHandle[0] = hmf;
xSrcPixSize = (FLOAT) emh->szlMillimeters.cx / emh->szlDevice.cx; if (hdc)
ySrcPixSize = (FLOAT) emh->szlMillimeters.cy / emh->szlDevice.cy; {
xscale = (FLOAT)(lpRect->right - lpRect->left) * 100.0 / xSrcPixSize = (FLOAT) emh->szlMillimeters.cx / emh->szlDevice.cx;
(emh->rclFrame.right - emh->rclFrame.left) * xSrcPixSize; ySrcPixSize = (FLOAT) emh->szlMillimeters.cy / emh->szlDevice.cy;
yscale = (FLOAT)(lpRect->bottom - lpRect->top) * 100.0 / xscale = (FLOAT)(lpRect->right - lpRect->left) * 100.0 /
(emh->rclFrame.bottom - emh->rclFrame.top) * ySrcPixSize; (emh->rclFrame.right - emh->rclFrame.left) * xSrcPixSize;
yscale = (FLOAT)(lpRect->bottom - lpRect->top) * 100.0 /
(emh->rclFrame.bottom - emh->rclFrame.top) * ySrcPixSize;
xform.eM11 = xscale; xform.eM11 = xscale;
xform.eM12 = 0; xform.eM12 = 0;
xform.eM21 = 0; xform.eM21 = 0;
xform.eM22 = yscale; xform.eM22 = yscale;
if(emh->rclFrame.left || emh->rclFrame.top) xform.eDx = (FLOAT)lpRect->left - (xscale * emh->rclFrame.left * 0.5);
FIXME("Can't cope with nonzero rclFrame origin yet\n"); xform.eDy = (FLOAT)lpRect->top - (yscale * (FLOAT)emh->rclFrame.top * 0.5);
/* eDx = lpRect->left - (lpRect width) / (rclFrame width) * rclFrame.left ? */
xform.eDx = lpRect->left; savedMode = SetGraphicsMode(hdc, GM_ADVANCED);
xform.eDy = lpRect->top; GetWorldTransform(hdc, &savedXform);
savedMode = SetGraphicsMode(hdc, GM_ADVANCED);
GetWorldTransform(hdc, &savedXform); if (!ModifyWorldTransform(hdc, &xform, MWT_RIGHTMULTIPLY)) {
if (!ModifyWorldTransform(hdc, &xform, MWT_LEFTMULTIPLY)) { ERR("World transform failed!\n");
ERR("World transform failed!\n"); }
GetWorldTransform(hdc, &outXform);
/* save the current pen, brush and font */
hPen = GetCurrentObject(hdc, OBJ_PEN);
hBrush = GetCurrentObject(hdc, OBJ_BRUSH);
hFont = GetCurrentObject(hdc, OBJ_FONT);
} }
/* save the current pen, brush and font */
hPen = GetCurrentObject(hdc, OBJ_PEN);
hBrush = GetCurrentObject(hdc, OBJ_BRUSH);
hFont = GetCurrentObject(hdc, OBJ_FONT);
TRACE("nSize = %ld, nBytes = %ld, nHandles = %d, nRecords = %ld, nPalEntries = %ld\n", TRACE("nSize = %ld, nBytes = %ld, nHandles = %d, nRecords = %ld, nPalEntries = %ld\n",
emh->nSize, emh->nBytes, emh->nHandles, emh->nRecords, emh->nPalEntries); emh->nSize, emh->nBytes, emh->nHandles, emh->nRecords, emh->nPalEntries);
@ -1293,25 +1302,29 @@ BOOL WINAPI EnumEnhMetaFile(
{ {
emr = (ENHMETARECORD *)((char *)emh + offset); emr = (ENHMETARECORD *)((char *)emh + offset);
TRACE("Calling EnumFunc with record type %ld, size %ld\n", emr->iType, emr->nSize); TRACE("Calling EnumFunc with record type %ld, size %ld\n", emr->iType, emr->nSize);
ret = (*callback)(hdc, ht, emr, emh->nRecords, data); ret = (*callback)(hdc, ht, emr, emh->nHandles, data);
offset += emr->nSize; offset += emr->nSize;
} }
/* restore pen, brush and font */ if (hdc)
SelectObject(hdc, hBrush); {
SelectObject(hdc, hPen); /* restore pen, brush and font */
SelectObject(hdc, hFont); SelectObject(hdc, hBrush);
SelectObject(hdc, hPen);
SelectObject(hdc, hFont);
for(i = 1; i < emh->nRecords; i++) /* Don't delete element 0 (hmf) */ SetWorldTransform(hdc, &savedXform);
if (savedMode)
SetGraphicsMode(hdc, savedMode);
}
for(i = 1; i < emh->nHandles; i++) /* Don't delete element 0 (hmf) */
if( (ht->objectHandle)[i] ) if( (ht->objectHandle)[i] )
DeleteObject( (ht->objectHandle)[i] ); DeleteObject( (ht->objectHandle)[i] );
HeapFree( GetProcessHeap(), 0, ht ); HeapFree( GetProcessHeap(), 0, ht );
HeapFree(GetProcessHeap(), 0, emhTemp); HeapFree(GetProcessHeap(), 0, emhTemp);
SetWorldTransform(hdc, &savedXform);
if (savedMode) SetGraphicsMode(hdc, savedMode);
return ret; return ret;
} }