gdi32: Make generated EMFs fully match Windows ones.
This commit is contained in:
parent
7aff723ccc
commit
02a15500fb
|
@ -2257,6 +2257,7 @@ BOOL WINAPI EnumEnhMetaFile(
|
||||||
HPEN hPen = NULL;
|
HPEN hPen = NULL;
|
||||||
HBRUSH hBrush = NULL;
|
HBRUSH hBrush = NULL;
|
||||||
HFONT hFont = NULL;
|
HFONT hFont = NULL;
|
||||||
|
HRGN hRgn = NULL;
|
||||||
enum_emh_data *info;
|
enum_emh_data *info;
|
||||||
SIZE vp_size, win_size;
|
SIZE vp_size, win_size;
|
||||||
POINT vp_org, win_org;
|
POINT vp_org, win_org;
|
||||||
|
@ -2311,11 +2312,18 @@ BOOL WINAPI EnumEnhMetaFile(
|
||||||
GetWindowOrgEx(hdc, &win_org);
|
GetWindowOrgEx(hdc, &win_org);
|
||||||
mapMode = GetMapMode(hdc);
|
mapMode = GetMapMode(hdc);
|
||||||
|
|
||||||
/* save the current pen, brush and font */
|
/* save DC */
|
||||||
hPen = GetCurrentObject(hdc, OBJ_PEN);
|
hPen = GetCurrentObject(hdc, OBJ_PEN);
|
||||||
hBrush = GetCurrentObject(hdc, OBJ_BRUSH);
|
hBrush = GetCurrentObject(hdc, OBJ_BRUSH);
|
||||||
hFont = GetCurrentObject(hdc, OBJ_FONT);
|
hFont = GetCurrentObject(hdc, OBJ_FONT);
|
||||||
|
|
||||||
|
hRgn = CreateRectRgn(0, 0, 0, 0);
|
||||||
|
if (!GetClipRgn(hdc, hRgn))
|
||||||
|
{
|
||||||
|
DeleteObject(hRgn);
|
||||||
|
hRgn = 0;
|
||||||
|
}
|
||||||
|
|
||||||
old_text_color = SetTextColor(hdc, RGB(0,0,0));
|
old_text_color = SetTextColor(hdc, RGB(0,0,0));
|
||||||
old_bk_color = SetBkColor(hdc, RGB(0xff, 0xff, 0xff));
|
old_bk_color = SetBkColor(hdc, RGB(0xff, 0xff, 0xff));
|
||||||
old_align = SetTextAlign(hdc, 0);
|
old_align = SetTextAlign(hdc, 0);
|
||||||
|
@ -2410,10 +2418,12 @@ BOOL WINAPI EnumEnhMetaFile(
|
||||||
SetBkColor(hdc, old_bk_color);
|
SetBkColor(hdc, old_bk_color);
|
||||||
SetTextColor(hdc, old_text_color);
|
SetTextColor(hdc, old_text_color);
|
||||||
|
|
||||||
/* restore pen, brush and font */
|
/* restore DC */
|
||||||
SelectObject(hdc, hBrush);
|
SelectObject(hdc, hBrush);
|
||||||
SelectObject(hdc, hPen);
|
SelectObject(hdc, hPen);
|
||||||
SelectObject(hdc, hFont);
|
SelectObject(hdc, hFont);
|
||||||
|
ExtSelectClipRgn(hdc, hRgn, RGN_COPY);
|
||||||
|
DeleteObject(hRgn);
|
||||||
|
|
||||||
SetWorldTransform(hdc, &savedXform);
|
SetWorldTransform(hdc, &savedXform);
|
||||||
if (savedMode)
|
if (savedMode)
|
||||||
|
@ -2673,9 +2683,8 @@ HENHMETAFILE WINAPI SetWinMetaFileBits(UINT cbBuffer,
|
||||||
HENHMETAFILE ret = NULL;
|
HENHMETAFILE ret = NULL;
|
||||||
HDC hdc = NULL, hdcdisp = NULL;
|
HDC hdc = NULL, hdcdisp = NULL;
|
||||||
RECT rc, *prcFrame = NULL;
|
RECT rc, *prcFrame = NULL;
|
||||||
gdi_mf_comment *mfcomment;
|
|
||||||
UINT mfcomment_size;
|
|
||||||
LONG mm, xExt, yExt;
|
LONG mm, xExt, yExt;
|
||||||
|
INT horzsize, vertsize, horzres, vertres;
|
||||||
|
|
||||||
TRACE("(%d, %p, %p, %p)\n", cbBuffer, lpbBuffer, hdcRef, lpmfp);
|
TRACE("(%d, %p, %p, %p)\n", cbBuffer, lpbBuffer, hdcRef, lpmfp);
|
||||||
|
|
||||||
|
@ -2736,9 +2745,14 @@ HENHMETAFILE WINAPI SetWinMetaFileBits(UINT cbBuffer,
|
||||||
* Write the original METAFILE into the enhanced metafile.
|
* Write the original METAFILE into the enhanced metafile.
|
||||||
* It is encapsulated in a GDICOMMENT_WINDOWS_METAFILE record.
|
* It is encapsulated in a GDICOMMENT_WINDOWS_METAFILE record.
|
||||||
*/
|
*/
|
||||||
|
if (mm != MM_TEXT)
|
||||||
|
{
|
||||||
|
gdi_mf_comment *mfcomment;
|
||||||
|
UINT mfcomment_size;
|
||||||
|
|
||||||
mfcomment_size = sizeof (gdi_mf_comment) + cbBuffer;
|
mfcomment_size = sizeof (gdi_mf_comment) + cbBuffer;
|
||||||
mfcomment = HeapAlloc(GetProcessHeap(), 0, mfcomment_size);
|
mfcomment = HeapAlloc(GetProcessHeap(), 0, mfcomment_size);
|
||||||
if(mfcomment)
|
if (mfcomment)
|
||||||
{
|
{
|
||||||
mfcomment->ident = GDICOMMENT_IDENTIFIER;
|
mfcomment->ident = GDICOMMENT_IDENTIFIER;
|
||||||
mfcomment->iComment = GDICOMMENT_WINDOWS_METAFILE;
|
mfcomment->iComment = GDICOMMENT_WINDOWS_METAFILE;
|
||||||
|
@ -2750,13 +2764,9 @@ HENHMETAFILE WINAPI SetWinMetaFileBits(UINT cbBuffer,
|
||||||
GdiComment(hdc, mfcomment_size, (BYTE*) mfcomment);
|
GdiComment(hdc, mfcomment_size, (BYTE*) mfcomment);
|
||||||
HeapFree(GetProcessHeap(), 0, mfcomment);
|
HeapFree(GetProcessHeap(), 0, mfcomment);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mm != MM_TEXT)
|
|
||||||
SetMapMode(hdc, mm);
|
SetMapMode(hdc, mm);
|
||||||
|
}
|
||||||
|
|
||||||
if (mm == MM_ISOTROPIC || mm == MM_ANISOTROPIC)
|
|
||||||
{
|
|
||||||
INT horzsize, vertsize, horzres, vertres;
|
|
||||||
|
|
||||||
horzsize = GetDeviceCaps(hdcRef, HORZSIZE);
|
horzsize = GetDeviceCaps(hdcRef, HORZSIZE);
|
||||||
vertsize = GetDeviceCaps(hdcRef, VERTSIZE);
|
vertsize = GetDeviceCaps(hdcRef, VERTSIZE);
|
||||||
|
@ -2778,7 +2788,6 @@ HENHMETAFILE WINAPI SetWinMetaFileBits(UINT cbBuffer,
|
||||||
/* set the initial viewport:window ratio as 1:1 */
|
/* set the initial viewport:window ratio as 1:1 */
|
||||||
SetViewportExtEx(hdc, xExt, yExt, NULL);
|
SetViewportExtEx(hdc, xExt, yExt, NULL);
|
||||||
SetWindowExtEx(hdc, xExt, yExt, NULL);
|
SetWindowExtEx(hdc, xExt, yExt, NULL);
|
||||||
}
|
|
||||||
|
|
||||||
PlayMetaFile(hdc, hmf);
|
PlayMetaFile(hdc, hmf);
|
||||||
|
|
||||||
|
|
|
@ -396,6 +396,8 @@ BOOL MF_PlayMetaFile( HDC hdc, METAHEADER *mh)
|
||||||
HPEN hPen;
|
HPEN hPen;
|
||||||
HBRUSH hBrush;
|
HBRUSH hBrush;
|
||||||
HFONT hFont;
|
HFONT hFont;
|
||||||
|
HPALETTE hPal;
|
||||||
|
HRGN hRgn;
|
||||||
BOOL loaded = FALSE;
|
BOOL loaded = FALSE;
|
||||||
|
|
||||||
if (!mh) return FALSE;
|
if (!mh) return FALSE;
|
||||||
|
@ -405,10 +407,18 @@ BOOL MF_PlayMetaFile( HDC hdc, METAHEADER *mh)
|
||||||
loaded = TRUE;
|
loaded = TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* save the current pen, brush and font */
|
/* save DC */
|
||||||
hPen = GetCurrentObject(hdc, OBJ_PEN);
|
hPen = GetCurrentObject(hdc, OBJ_PEN);
|
||||||
hBrush = GetCurrentObject(hdc, OBJ_BRUSH);
|
hBrush = GetCurrentObject(hdc, OBJ_BRUSH);
|
||||||
hFont = GetCurrentObject(hdc, OBJ_FONT);
|
hFont = GetCurrentObject(hdc, OBJ_FONT);
|
||||||
|
hPal = GetCurrentObject(hdc, OBJ_PAL);
|
||||||
|
|
||||||
|
hRgn = CreateRectRgn(0, 0, 0, 0);
|
||||||
|
if (!GetClipRgn(hdc, hRgn))
|
||||||
|
{
|
||||||
|
DeleteObject(hRgn);
|
||||||
|
hRgn = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* create the handle table */
|
/* create the handle table */
|
||||||
ht = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
|
ht = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
|
||||||
|
@ -436,9 +446,12 @@ BOOL MF_PlayMetaFile( HDC hdc, METAHEADER *mh)
|
||||||
PlayMetaFileRecord( hdc, ht, mr, mh->mtNoObjects );
|
PlayMetaFileRecord( hdc, ht, mr, mh->mtNoObjects );
|
||||||
}
|
}
|
||||||
|
|
||||||
SelectObject(hdc, hBrush);
|
/* restore DC */
|
||||||
SelectObject(hdc, hPen);
|
SelectObject(hdc, hPen);
|
||||||
SelectObject(hdc, hFont);
|
SelectObject(hdc, hBrush);
|
||||||
|
SelectPalette(hdc, hPal, FALSE);
|
||||||
|
ExtSelectClipRgn(hdc, hRgn, RGN_COPY);
|
||||||
|
DeleteObject(hRgn);
|
||||||
|
|
||||||
/* free objects in handle table */
|
/* free objects in handle table */
|
||||||
for(i = 0; i < mh->mtNoObjects; i++)
|
for(i = 0; i < mh->mtNoObjects; i++)
|
||||||
|
|
|
@ -1480,7 +1480,7 @@ static void test_emf_ExtTextOut_on_path(void)
|
||||||
* are there, but their contents don't match for different reasons.
|
* are there, but their contents don't match for different reasons.
|
||||||
*/
|
*/
|
||||||
if (compare_emf_bits(hMetafile, EMF_TEXTOUT_ON_PATH_BITS, sizeof(EMF_TEXTOUT_ON_PATH_BITS),
|
if (compare_emf_bits(hMetafile, EMF_TEXTOUT_ON_PATH_BITS, sizeof(EMF_TEXTOUT_ON_PATH_BITS),
|
||||||
"emf_TextOut_on_path", FALSE, TRUE) != 0)
|
"emf_TextOut_on_path", FALSE, FALSE) != 0)
|
||||||
{
|
{
|
||||||
dump_emf_bits(hMetafile, "emf_TextOut_on_path");
|
dump_emf_bits(hMetafile, "emf_TextOut_on_path");
|
||||||
dump_emf_records(hMetafile, "emf_TextOut_on_path");
|
dump_emf_records(hMetafile, "emf_TextOut_on_path");
|
||||||
|
@ -1676,7 +1676,7 @@ static void test_emf_clipping(void)
|
||||||
ok(hemf != 0, "CloseEnhMetaFile error %d\n", GetLastError());
|
ok(hemf != 0, "CloseEnhMetaFile error %d\n", GetLastError());
|
||||||
|
|
||||||
if (compare_emf_bits(hemf, EMF_CLIPPING, sizeof(EMF_CLIPPING),
|
if (compare_emf_bits(hemf, EMF_CLIPPING, sizeof(EMF_CLIPPING),
|
||||||
"emf_clipping", FALSE, TRUE) != 0)
|
"emf_clipping", FALSE, FALSE) != 0)
|
||||||
{
|
{
|
||||||
dump_emf_bits(hemf, "emf_clipping");
|
dump_emf_bits(hemf, "emf_clipping");
|
||||||
dump_emf_records(hemf, "emf_clipping");
|
dump_emf_records(hemf, "emf_clipping");
|
||||||
|
@ -1785,7 +1785,7 @@ static void test_mf_conversions(void)
|
||||||
hemf = create_converted_emf(&mfp);
|
hemf = create_converted_emf(&mfp);
|
||||||
|
|
||||||
if (compare_emf_bits(hemf, EMF_LINETO_MM_ANISOTROPIC_BITS, sizeof(EMF_LINETO_MM_ANISOTROPIC_BITS),
|
if (compare_emf_bits(hemf, EMF_LINETO_MM_ANISOTROPIC_BITS, sizeof(EMF_LINETO_MM_ANISOTROPIC_BITS),
|
||||||
"emf_LineTo MM_ANISOTROPIC", TRUE, TRUE) != 0)
|
"emf_LineTo MM_ANISOTROPIC", TRUE, FALSE) != 0)
|
||||||
{
|
{
|
||||||
dump_emf_bits(hemf, "emf_LineTo MM_ANISOTROPIC");
|
dump_emf_bits(hemf, "emf_LineTo MM_ANISOTROPIC");
|
||||||
dump_emf_records(hemf, "emf_LineTo MM_ANISOTROPIC");
|
dump_emf_records(hemf, "emf_LineTo MM_ANISOTROPIC");
|
||||||
|
@ -1810,7 +1810,7 @@ static void test_mf_conversions(void)
|
||||||
hemf = create_converted_emf(&mfp);
|
hemf = create_converted_emf(&mfp);
|
||||||
|
|
||||||
if (compare_emf_bits(hemf, EMF_LINETO_MM_TEXT_BITS, sizeof(EMF_LINETO_MM_TEXT_BITS),
|
if (compare_emf_bits(hemf, EMF_LINETO_MM_TEXT_BITS, sizeof(EMF_LINETO_MM_TEXT_BITS),
|
||||||
"emf_LineTo MM_TEXT", TRUE, TRUE) != 0)
|
"emf_LineTo MM_TEXT", TRUE, FALSE) != 0)
|
||||||
{
|
{
|
||||||
dump_emf_bits(hemf, "emf_LineTo MM_TEXT");
|
dump_emf_bits(hemf, "emf_LineTo MM_TEXT");
|
||||||
dump_emf_records(hemf, "emf_LineTo MM_TEXT");
|
dump_emf_records(hemf, "emf_LineTo MM_TEXT");
|
||||||
|
@ -1830,7 +1830,7 @@ static void test_mf_conversions(void)
|
||||||
hemf = create_converted_emf(NULL);
|
hemf = create_converted_emf(NULL);
|
||||||
|
|
||||||
if (compare_emf_bits(hemf, EMF_LINETO_BITS, sizeof(EMF_LINETO_BITS),
|
if (compare_emf_bits(hemf, EMF_LINETO_BITS, sizeof(EMF_LINETO_BITS),
|
||||||
"emf_LineTo NULL", TRUE, TRUE) != 0)
|
"emf_LineTo NULL", TRUE, FALSE) != 0)
|
||||||
{
|
{
|
||||||
dump_emf_bits(hemf, "emf_LineTo NULL");
|
dump_emf_bits(hemf, "emf_LineTo NULL");
|
||||||
dump_emf_records(hemf, "emf_LineTo NULL");
|
dump_emf_records(hemf, "emf_LineTo NULL");
|
||||||
|
|
Loading…
Reference in New Issue