2 * Enhanced metafile functions
3 * Copyright 1998 Douglas Ridgway
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 * The enhanced format consists of the following elements:
25 * A table of handles to GDI objects
26 * An array of metafile records
30 * The standard format consists of a header and an array of metafile records.
35 #include "wine/port.h"
47 #include "gdi_private.h"
48 #include "wine/debug.h"
50 WINE_DEFAULT_DEBUG_CHANNEL(enhmetafile
);
56 BOOL on_disk
; /* true if metafile is on disk */
59 static const struct emr_name
{
72 X(EMR_SETWINDOWEXTEX
),
73 X(EMR_SETWINDOWORGEX
),
74 X(EMR_SETVIEWPORTEXTEX
),
75 X(EMR_SETVIEWPORTORGEX
),
79 X(EMR_SETMAPPERFLAGS
),
82 X(EMR_SETPOLYFILLMODE
),
84 X(EMR_SETSTRETCHBLTMODE
),
86 X(EMR_SETCOLORADJUSTMENT
),
92 X(EMR_EXCLUDECLIPRECT
),
93 X(EMR_INTERSECTCLIPRECT
),
94 X(EMR_SCALEVIEWPORTEXTEX
),
95 X(EMR_SCALEWINDOWEXTEX
),
98 X(EMR_SETWORLDTRANSFORM
),
99 X(EMR_MODIFYWORLDTRANSFORM
),
102 X(EMR_CREATEBRUSHINDIRECT
),
111 X(EMR_SELECTPALETTE
),
112 X(EMR_CREATEPALETTE
),
113 X(EMR_SETPALETTEENTRIES
),
114 X(EMR_RESIZEPALETTE
),
115 X(EMR_REALIZEPALETTE
),
120 X(EMR_SETARCDIRECTION
),
121 X(EMR_SETMITERLIMIT
),
126 X(EMR_STROKEANDFILLPATH
),
130 X(EMR_SELECTCLIPPATH
),
137 X(EMR_EXTSELECTCLIPRGN
),
142 X(EMR_SETDIBITSTODEVICE
),
143 X(EMR_STRETCHDIBITS
),
144 X(EMR_EXTCREATEFONTINDIRECTW
),
150 X(EMR_POLYBEZIERTO16
),
152 X(EMR_POLYPOLYLINE16
),
153 X(EMR_POLYPOLYGON16
),
155 X(EMR_CREATEMONOBRUSH
),
156 X(EMR_CREATEDIBPATTERNBRUSHPT
),
161 X(EMR_CREATECOLORSPACE
),
162 X(EMR_SETCOLORSPACE
),
163 X(EMR_DELETECOLORSPACE
),
165 X(EMR_GLSBOUNDEDRECORD
),
171 X(EMR_FORCEUFIMAPPING
),
173 X(EMR_COLORCORRECTPALETTE
),
174 X(EMR_SETICMPROFILEA
),
175 X(EMR_SETICMPROFILEW
),
178 X(EMR_TRANSPARENTBLT
),
182 X(EMR_SETTEXTJUSTIFICATION
),
183 X(EMR_COLORMATCHTOTARGETW
),
184 X(EMR_CREATECOLORSPACEW
)
188 /****************************************************************************
191 static const char *get_emr_name(DWORD type
)
194 for(i
= 0; i
< sizeof(emr_names
) / sizeof(emr_names
[0]); i
++)
195 if(type
== emr_names
[i
].type
) return emr_names
[i
].name
;
196 TRACE("Unknown record type %ld\n", type
);
200 /***********************************************************************
203 * Returns whether a DIB can be converted to a monochrome DDB.
205 * A DIB can be converted if its color table contains only black and
206 * white. Black must be the first color in the color table.
208 * Note : If the first color in the color table is white followed by
209 * black, we can't convert it to a monochrome DDB with
210 * SetDIBits, because black and white would be inverted.
212 static inline BOOL
is_dib_monochrome( const BITMAPINFO
* info
)
214 if (info
->bmiHeader
.biBitCount
!= 1) return FALSE
;
216 if (info
->bmiHeader
.biSize
== sizeof(BITMAPCOREHEADER
))
218 RGBTRIPLE
*rgb
= ((BITMAPCOREINFO
*) info
)->bmciColors
;
220 /* Check if the first color is black */
221 if ((rgb
->rgbtRed
== 0) && (rgb
->rgbtGreen
== 0) && (rgb
->rgbtBlue
== 0))
224 /* Check if the second color is white */
225 return ((rgb
->rgbtRed
== 0xff) && (rgb
->rgbtGreen
== 0xff)
226 && (rgb
->rgbtBlue
== 0xff));
230 else /* assume BITMAPINFOHEADER */
232 const RGBQUAD
*rgb
= info
->bmiColors
;
234 /* Check if the first color is black */
235 if ((rgb
->rgbRed
== 0) && (rgb
->rgbGreen
== 0) &&
236 (rgb
->rgbBlue
== 0) && (rgb
->rgbReserved
== 0))
240 /* Check if the second color is white */
241 return ((rgb
->rgbRed
== 0xff) && (rgb
->rgbGreen
== 0xff)
242 && (rgb
->rgbBlue
== 0xff) && (rgb
->rgbReserved
== 0));
248 /****************************************************************************
249 * EMF_Create_HENHMETAFILE
251 HENHMETAFILE
EMF_Create_HENHMETAFILE(ENHMETAHEADER
*emh
, BOOL on_disk
)
253 HENHMETAFILE hmf
= 0;
254 ENHMETAFILEOBJ
*metaObj
= GDI_AllocObject( sizeof(ENHMETAFILEOBJ
),
256 (HGDIOBJ
*)&hmf
, NULL
);
260 metaObj
->on_disk
= on_disk
;
261 GDI_ReleaseObj( hmf
);
266 /****************************************************************************
267 * EMF_Delete_HENHMETAFILE
269 static BOOL
EMF_Delete_HENHMETAFILE( HENHMETAFILE hmf
)
271 ENHMETAFILEOBJ
*metaObj
= (ENHMETAFILEOBJ
*)GDI_GetObjPtr( hmf
,
273 if(!metaObj
) return FALSE
;
276 UnmapViewOfFile( metaObj
->emh
);
278 HeapFree( GetProcessHeap(), 0, metaObj
->emh
);
279 return GDI_FreeObject( hmf
, metaObj
);
282 /******************************************************************
283 * EMF_GetEnhMetaHeader
285 * Returns ptr to ENHMETAHEADER associated with HENHMETAFILE
287 static ENHMETAHEADER
*EMF_GetEnhMetaHeader( HENHMETAFILE hmf
)
289 ENHMETAHEADER
*ret
= NULL
;
290 ENHMETAFILEOBJ
*metaObj
= (ENHMETAFILEOBJ
*)GDI_GetObjPtr( hmf
, ENHMETAFILE_MAGIC
);
291 TRACE("hmf %p -> enhmetaObj %p\n", hmf
, metaObj
);
295 GDI_ReleaseObj( hmf
);
300 /*****************************************************************************
304 static HENHMETAFILE
EMF_GetEnhMetaFile( HANDLE hFile
)
309 hMapping
= CreateFileMappingA( hFile
, NULL
, PAGE_READONLY
, 0, 0, NULL
);
310 emh
= MapViewOfFile( hMapping
, FILE_MAP_READ
, 0, 0, 0 );
311 CloseHandle( hMapping
);
315 if (emh
->iType
!= EMR_HEADER
|| emh
->dSignature
!= ENHMETA_SIGNATURE
) {
316 WARN("Invalid emf header type 0x%08lx sig 0x%08lx.\n",
317 emh
->iType
, emh
->dSignature
);
321 /* refuse to load unaligned EMF as Windows does */
324 WARN("Refusing to load unaligned EMF\n");
328 return EMF_Create_HENHMETAFILE( emh
, TRUE
);
331 UnmapViewOfFile( emh
);
336 /*****************************************************************************
337 * GetEnhMetaFileA (GDI32.@)
341 HENHMETAFILE WINAPI
GetEnhMetaFileA(
342 LPCSTR lpszMetaFile
/* [in] filename of enhanced metafile */
348 hFile
= CreateFileA(lpszMetaFile
, GENERIC_READ
, FILE_SHARE_READ
, 0,
349 OPEN_EXISTING
, 0, 0);
350 if (hFile
== INVALID_HANDLE_VALUE
) {
351 WARN("could not open %s\n", lpszMetaFile
);
354 hmf
= EMF_GetEnhMetaFile( hFile
);
355 CloseHandle( hFile
);
359 /*****************************************************************************
360 * GetEnhMetaFileW (GDI32.@)
362 HENHMETAFILE WINAPI
GetEnhMetaFileW(
363 LPCWSTR lpszMetaFile
) /* [in] filename of enhanced metafile */
368 hFile
= CreateFileW(lpszMetaFile
, GENERIC_READ
, FILE_SHARE_READ
, 0,
369 OPEN_EXISTING
, 0, 0);
370 if (hFile
== INVALID_HANDLE_VALUE
) {
371 WARN("could not open %s\n", debugstr_w(lpszMetaFile
));
374 hmf
= EMF_GetEnhMetaFile( hFile
);
375 CloseHandle( hFile
);
379 /*****************************************************************************
380 * GetEnhMetaFileHeader (GDI32.@)
382 * If buf is NULL, returns the size of buffer required.
383 * Otherwise, copy up to bufsize bytes of enhanced metafile header into
386 UINT WINAPI
GetEnhMetaFileHeader(
387 HENHMETAFILE hmf
, /* [in] enhanced metafile */
388 UINT bufsize
, /* [in] size of buffer */
389 LPENHMETAHEADER buf
/* [out] buffer */
395 emh
= EMF_GetEnhMetaHeader(hmf
);
396 if(!emh
) return FALSE
;
398 if (!buf
) return size
;
399 size
= min(size
, bufsize
);
400 memmove(buf
, emh
, size
);
405 /*****************************************************************************
406 * GetEnhMetaFileDescriptionA (GDI32.@)
408 UINT WINAPI
GetEnhMetaFileDescriptionA(
409 HENHMETAFILE hmf
, /* [in] enhanced metafile */
410 UINT size
, /* [in] size of buf */
411 LPSTR buf
/* [out] buffer to receive description */
414 LPENHMETAHEADER emh
= EMF_GetEnhMetaHeader(hmf
);
418 if(!emh
) return FALSE
;
419 if(emh
->nDescription
== 0 || emh
->offDescription
== 0) return 0;
420 descrW
= (WCHAR
*) ((char *) emh
+ emh
->offDescription
);
421 len
= WideCharToMultiByte( CP_ACP
, 0, descrW
, emh
->nDescription
, NULL
, 0, NULL
, NULL
);
423 if (!buf
|| !size
) return len
;
425 len
= min( size
, len
);
426 WideCharToMultiByte( CP_ACP
, 0, descrW
, emh
->nDescription
, buf
, len
, NULL
, NULL
);
430 /*****************************************************************************
431 * GetEnhMetaFileDescriptionW (GDI32.@)
433 * Copies the description string of an enhanced metafile into a buffer
436 * If _buf_ is NULL, returns size of _buf_ required. Otherwise, returns
437 * number of characters copied.
439 UINT WINAPI
GetEnhMetaFileDescriptionW(
440 HENHMETAFILE hmf
, /* [in] enhanced metafile */
441 UINT size
, /* [in] size of buf */
442 LPWSTR buf
/* [out] buffer to receive description */
445 LPENHMETAHEADER emh
= EMF_GetEnhMetaHeader(hmf
);
447 if(!emh
) return FALSE
;
448 if(emh
->nDescription
== 0 || emh
->offDescription
== 0) return 0;
449 if (!buf
|| !size
) return emh
->nDescription
;
451 memmove(buf
, (char *) emh
+ emh
->offDescription
, min(size
,emh
->nDescription
)*sizeof(WCHAR
));
452 return min(size
, emh
->nDescription
);
455 /****************************************************************************
456 * SetEnhMetaFileBits (GDI32.@)
458 * Creates an enhanced metafile by copying _bufsize_ bytes from _buf_.
460 HENHMETAFILE WINAPI
SetEnhMetaFileBits(UINT bufsize
, const BYTE
*buf
)
462 ENHMETAHEADER
*emh
= HeapAlloc( GetProcessHeap(), 0, bufsize
);
463 memmove(emh
, buf
, bufsize
);
464 return EMF_Create_HENHMETAFILE( emh
, FALSE
);
467 /*****************************************************************************
468 * GetEnhMetaFileBits (GDI32.@)
471 UINT WINAPI
GetEnhMetaFileBits(
477 LPENHMETAHEADER emh
= EMF_GetEnhMetaHeader( hmf
);
483 if( buf
== NULL
) return size
;
485 size
= min( size
, bufsize
);
486 memmove(buf
, emh
, size
);
490 typedef struct enum_emh_data
493 XFORM init_transform
;
494 XFORM world_transform
;
505 #define ENUM_GET_PRIVATE_DATA(ht) \
506 ((enum_emh_data*)(((unsigned char*)(ht))-sizeof (enum_emh_data)))
508 #define WIDTH(rect) ( (rect).right - (rect).left )
509 #define HEIGHT(rect) ( (rect).bottom - (rect).top )
511 #define IS_WIN9X() (GetVersion()&0x80000000)
513 static void EMF_Update_MF_Xform(HDC hdc
, enum_emh_data
*info
)
515 XFORM mapping_mode_trans
, final_trans
;
516 FLOAT scaleX
, scaleY
;
518 scaleX
= (FLOAT
)info
->vportExtX
/ (FLOAT
)info
->wndExtX
;
519 scaleY
= (FLOAT
)info
->vportExtY
/ (FLOAT
)info
->wndExtY
;
520 mapping_mode_trans
.eM11
= scaleX
;
521 mapping_mode_trans
.eM12
= 0.0;
522 mapping_mode_trans
.eM21
= 0.0;
523 mapping_mode_trans
.eM22
= scaleY
;
524 mapping_mode_trans
.eDx
= (FLOAT
)info
->vportOrgX
- scaleX
* (FLOAT
)info
->wndOrgX
;
525 mapping_mode_trans
.eDy
= (FLOAT
)info
->vportOrgY
- scaleY
* (FLOAT
)info
->wndOrgY
;
527 CombineTransform(&final_trans
, &info
->world_transform
, &mapping_mode_trans
);
528 CombineTransform(&final_trans
, &final_trans
, &info
->init_transform
);
530 if (!SetWorldTransform(hdc
, &final_trans
))
532 ERR("World transform failed!\n");
536 static void EMF_SetMapMode(HDC hdc
, enum_emh_data
*info
)
538 INT horzSize
= GetDeviceCaps( hdc
, HORZSIZE
);
539 INT vertSize
= GetDeviceCaps( hdc
, VERTSIZE
);
540 INT horzRes
= GetDeviceCaps( hdc
, HORZRES
);
541 INT vertRes
= GetDeviceCaps( hdc
, VERTRES
);
543 TRACE("%d\n",info
->mode
);
555 info
->wndExtX
= horzSize
* 10;
556 info
->wndExtY
= vertSize
* 10;
557 info
->vportExtX
= horzRes
;
558 info
->vportExtY
= -vertRes
;
561 info
->wndExtX
= horzSize
* 100;
562 info
->wndExtY
= vertSize
* 100;
563 info
->vportExtX
= horzRes
;
564 info
->vportExtY
= -vertRes
;
567 info
->wndExtX
= MulDiv(1000, horzSize
, 254);
568 info
->wndExtY
= MulDiv(1000, vertSize
, 254);
569 info
->vportExtX
= horzRes
;
570 info
->vportExtY
= -vertRes
;
573 info
->wndExtX
= MulDiv(10000, horzSize
, 254);
574 info
->wndExtY
= MulDiv(10000, vertSize
, 254);
575 info
->vportExtX
= horzRes
;
576 info
->vportExtY
= -vertRes
;
579 info
->wndExtX
= MulDiv(14400, horzSize
, 254);
580 info
->wndExtY
= MulDiv(14400, vertSize
, 254);
581 info
->vportExtX
= horzRes
;
582 info
->vportExtY
= -vertRes
;
591 /*****************************************************************************
592 * emr_produces_output
594 * Returns TRUE if the record type writes something to the dc. Used by
595 * PlayEnhMetaFileRecord to determine whether it needs to update the
596 * dc's xform when in win9x mode.
598 * FIXME: need to test which records should be here.
600 static BOOL
emr_produces_output(int type
)
606 case EMR_POLYBEZIERTO
:
608 case EMR_POLYPOLYLINE
:
609 case EMR_POLYPOLYGON
:
612 case EMR_EXCLUDECLIPRECT
:
613 case EMR_INTERSECTCLIPRECT
:
614 case EMR_SELECTOBJECT
:
622 case EMR_EXTFLOODFILL
:
634 case EMR_SETDIBITSTODEVICE
:
635 case EMR_STRETCHDIBITS
:
636 case EMR_EXTTEXTOUTA
:
637 case EMR_EXTTEXTOUTW
:
638 case EMR_POLYBEZIER16
:
641 case EMR_POLYBEZIERTO16
:
642 case EMR_POLYLINETO16
:
643 case EMR_POLYPOLYLINE16
:
644 case EMR_POLYPOLYGON16
:
646 case EMR_POLYTEXTOUTA
:
647 case EMR_POLYTEXTOUTW
:
648 case EMR_SMALLTEXTOUT
:
649 case EMR_TRANSPARENTBLT
:
657 /*****************************************************************************
658 * PlayEnhMetaFileRecord (GDI32.@)
660 * Render a single enhanced metafile record in the device context hdc.
663 * TRUE (non zero) on success, FALSE on error.
665 * Many unimplemented records.
666 * No error handling on record play failures (ie checking return codes)
669 * WinNT actually updates the current world transform in this function
670 * whereas Win9x does not.
672 BOOL WINAPI
PlayEnhMetaFileRecord(
673 HDC hdc
, /* [in] device context in which to render EMF record */
674 LPHANDLETABLE handletable
, /* [in] array of handles to be used in rendering record */
675 const ENHMETARECORD
*mr
, /* [in] EMF record to render */
676 UINT handles
/* [in] size of handle array */
681 enum_emh_data
*info
= ENUM_GET_PRIVATE_DATA(handletable
);
683 TRACE("hdc = %p, handletable = %p, record = %p, numHandles = %d\n",
684 hdc
, handletable
, mr
, handles
);
685 if (!mr
) return FALSE
;
689 /* In Win9x mode we update the xform if the record will produce output */
690 if ( IS_WIN9X() && emr_produces_output(type
) )
691 EMF_Update_MF_Xform(hdc
, info
);
693 TRACE("record %s\n", get_emr_name(type
));
702 PEMRGDICOMMENT lpGdiComment
= (PEMRGDICOMMENT
)mr
;
703 /* In an enhanced metafile, there can be both public and private GDI comments */
704 GdiComment( hdc
, lpGdiComment
->cbData
, lpGdiComment
->Data
);
709 PEMRSETMAPMODE pSetMapMode
= (PEMRSETMAPMODE
) mr
;
711 if(info
->mode
== pSetMapMode
->iMode
&& (info
->mode
== MM_ISOTROPIC
|| info
->mode
== MM_ANISOTROPIC
))
713 info
->mode
= pSetMapMode
->iMode
;
714 EMF_SetMapMode(hdc
, info
);
719 PEMRSETBKMODE pSetBkMode
= (PEMRSETBKMODE
) mr
;
720 SetBkMode(hdc
, pSetBkMode
->iMode
);
725 PEMRSETBKCOLOR pSetBkColor
= (PEMRSETBKCOLOR
) mr
;
726 SetBkColor(hdc
, pSetBkColor
->crColor
);
729 case EMR_SETPOLYFILLMODE
:
731 PEMRSETPOLYFILLMODE pSetPolyFillMode
= (PEMRSETPOLYFILLMODE
) mr
;
732 SetPolyFillMode(hdc
, pSetPolyFillMode
->iMode
);
737 PEMRSETROP2 pSetROP2
= (PEMRSETROP2
) mr
;
738 SetROP2(hdc
, pSetROP2
->iMode
);
741 case EMR_SETSTRETCHBLTMODE
:
743 PEMRSETSTRETCHBLTMODE pSetStretchBltMode
= (PEMRSETSTRETCHBLTMODE
) mr
;
744 SetStretchBltMode(hdc
, pSetStretchBltMode
->iMode
);
747 case EMR_SETTEXTALIGN
:
749 PEMRSETTEXTALIGN pSetTextAlign
= (PEMRSETTEXTALIGN
) mr
;
750 SetTextAlign(hdc
, pSetTextAlign
->iMode
);
753 case EMR_SETTEXTCOLOR
:
755 PEMRSETTEXTCOLOR pSetTextColor
= (PEMRSETTEXTCOLOR
) mr
;
756 SetTextColor(hdc
, pSetTextColor
->crColor
);
766 PEMRRESTOREDC pRestoreDC
= (PEMRRESTOREDC
) mr
;
767 TRACE("EMR_RESTORE: %ld\n", pRestoreDC
->iRelative
);
768 RestoreDC(hdc
, pRestoreDC
->iRelative
);
771 case EMR_INTERSECTCLIPRECT
:
773 PEMRINTERSECTCLIPRECT pClipRect
= (PEMRINTERSECTCLIPRECT
) mr
;
774 TRACE("EMR_INTERSECTCLIPRECT: rect %ld,%ld - %ld, %ld\n",
775 pClipRect
->rclClip
.left
, pClipRect
->rclClip
.top
,
776 pClipRect
->rclClip
.right
, pClipRect
->rclClip
.bottom
);
777 IntersectClipRect(hdc
, pClipRect
->rclClip
.left
, pClipRect
->rclClip
.top
,
778 pClipRect
->rclClip
.right
, pClipRect
->rclClip
.bottom
);
781 case EMR_SELECTOBJECT
:
783 PEMRSELECTOBJECT pSelectObject
= (PEMRSELECTOBJECT
) mr
;
784 if( pSelectObject
->ihObject
& 0x80000000 ) {
785 /* High order bit is set - it's a stock object
786 * Strip the high bit to get the index.
787 * See MSDN article Q142319
789 SelectObject( hdc
, GetStockObject( pSelectObject
->ihObject
&
792 /* High order bit wasn't set - not a stock object
795 (handletable
->objectHandle
)[pSelectObject
->ihObject
] );
799 case EMR_DELETEOBJECT
:
801 PEMRDELETEOBJECT pDeleteObject
= (PEMRDELETEOBJECT
) mr
;
802 DeleteObject( (handletable
->objectHandle
)[pDeleteObject
->ihObject
]);
803 (handletable
->objectHandle
)[pDeleteObject
->ihObject
] = 0;
806 case EMR_SETWINDOWORGEX
:
808 PEMRSETWINDOWORGEX pSetWindowOrgEx
= (PEMRSETWINDOWORGEX
) mr
;
810 info
->wndOrgX
= pSetWindowOrgEx
->ptlOrigin
.x
;
811 info
->wndOrgY
= pSetWindowOrgEx
->ptlOrigin
.y
;
813 TRACE("SetWindowOrgEx: %d,%d\n",info
->wndOrgX
,info
->wndOrgY
);
816 case EMR_SETWINDOWEXTEX
:
818 PEMRSETWINDOWEXTEX pSetWindowExtEx
= (PEMRSETWINDOWEXTEX
) mr
;
820 if(info
->mode
!= MM_ISOTROPIC
&& info
->mode
!= MM_ANISOTROPIC
)
822 info
->wndExtX
= pSetWindowExtEx
->szlExtent
.cx
;
823 info
->wndExtY
= pSetWindowExtEx
->szlExtent
.cy
;
825 TRACE("SetWindowExtEx: %d,%d\n",info
->wndExtX
,info
->wndExtY
);
828 case EMR_SETVIEWPORTORGEX
:
830 PEMRSETVIEWPORTORGEX pSetViewportOrgEx
= (PEMRSETVIEWPORTORGEX
) mr
;
831 enum_emh_data
*info
= ENUM_GET_PRIVATE_DATA(handletable
);
833 info
->vportOrgX
= pSetViewportOrgEx
->ptlOrigin
.x
;
834 info
->vportOrgY
= pSetViewportOrgEx
->ptlOrigin
.y
;
835 TRACE("SetViewportOrgEx: %d,%d\n",info
->vportOrgX
,info
->vportOrgY
);
838 case EMR_SETVIEWPORTEXTEX
:
840 PEMRSETVIEWPORTEXTEX pSetViewportExtEx
= (PEMRSETVIEWPORTEXTEX
) mr
;
841 enum_emh_data
*info
= ENUM_GET_PRIVATE_DATA(handletable
);
843 if(info
->mode
!= MM_ISOTROPIC
&& info
->mode
!= MM_ANISOTROPIC
)
845 info
->vportExtX
= pSetViewportExtEx
->szlExtent
.cx
;
846 info
->vportExtY
= pSetViewportExtEx
->szlExtent
.cy
;
847 TRACE("SetViewportExtEx: %d,%d\n",info
->vportExtX
,info
->vportExtY
);
852 PEMRCREATEPEN pCreatePen
= (PEMRCREATEPEN
) mr
;
853 (handletable
->objectHandle
)[pCreatePen
->ihPen
] =
854 CreatePenIndirect(&pCreatePen
->lopn
);
857 case EMR_EXTCREATEPEN
:
859 PEMREXTCREATEPEN pPen
= (PEMREXTCREATEPEN
) mr
;
861 lb
.lbStyle
= pPen
->elp
.elpBrushStyle
;
862 lb
.lbColor
= pPen
->elp
.elpColor
;
863 lb
.lbHatch
= pPen
->elp
.elpHatch
;
865 if(pPen
->offBmi
|| pPen
->offBits
)
866 FIXME("EMR_EXTCREATEPEN: Need to copy brush bitmap\n");
868 (handletable
->objectHandle
)[pPen
->ihPen
] =
869 ExtCreatePen(pPen
->elp
.elpPenStyle
, pPen
->elp
.elpWidth
, &lb
,
870 pPen
->elp
.elpNumEntries
, pPen
->elp
.elpStyleEntry
);
873 case EMR_CREATEBRUSHINDIRECT
:
875 PEMRCREATEBRUSHINDIRECT pBrush
= (PEMRCREATEBRUSHINDIRECT
) mr
;
877 brush
.lbStyle
= pBrush
->lb
.lbStyle
;
878 brush
.lbColor
= pBrush
->lb
.lbColor
;
879 brush
.lbHatch
= pBrush
->lb
.lbHatch
;
880 (handletable
->objectHandle
)[pBrush
->ihBrush
] = CreateBrushIndirect(&brush
);
883 case EMR_EXTCREATEFONTINDIRECTW
:
885 PEMREXTCREATEFONTINDIRECTW pFont
= (PEMREXTCREATEFONTINDIRECTW
) mr
;
886 (handletable
->objectHandle
)[pFont
->ihFont
] =
887 CreateFontIndirectW(&pFont
->elfw
.elfLogFont
);
892 PEMRMOVETOEX pMoveToEx
= (PEMRMOVETOEX
) mr
;
893 MoveToEx(hdc
, pMoveToEx
->ptl
.x
, pMoveToEx
->ptl
.y
, NULL
);
898 PEMRLINETO pLineTo
= (PEMRLINETO
) mr
;
899 LineTo(hdc
, pLineTo
->ptl
.x
, pLineTo
->ptl
.y
);
904 PEMRRECTANGLE pRect
= (PEMRRECTANGLE
) mr
;
905 Rectangle(hdc
, pRect
->rclBox
.left
, pRect
->rclBox
.top
,
906 pRect
->rclBox
.right
, pRect
->rclBox
.bottom
);
911 PEMRELLIPSE pEllipse
= (PEMRELLIPSE
) mr
;
912 Ellipse(hdc
, pEllipse
->rclBox
.left
, pEllipse
->rclBox
.top
,
913 pEllipse
->rclBox
.right
, pEllipse
->rclBox
.bottom
);
918 PEMRPOLYGON16 pPoly
= (PEMRPOLYGON16
) mr
;
919 /* Shouldn't use Polygon16 since pPoly->cpts is DWORD */
920 POINT
*pts
= HeapAlloc( GetProcessHeap(), 0,
921 pPoly
->cpts
* sizeof(POINT
) );
923 for(i
= 0; i
< pPoly
->cpts
; i
++)
925 pts
[i
].x
= pPoly
->apts
[i
].x
;
926 pts
[i
].y
= pPoly
->apts
[i
].y
;
928 Polygon(hdc
, pts
, pPoly
->cpts
);
929 HeapFree( GetProcessHeap(), 0, pts
);
934 PEMRPOLYLINE16 pPoly
= (PEMRPOLYLINE16
) mr
;
935 /* Shouldn't use Polyline16 since pPoly->cpts is DWORD */
936 POINT
*pts
= HeapAlloc( GetProcessHeap(), 0,
937 pPoly
->cpts
* sizeof(POINT
) );
939 for(i
= 0; i
< pPoly
->cpts
; i
++)
941 pts
[i
].x
= pPoly
->apts
[i
].x
;
942 pts
[i
].y
= pPoly
->apts
[i
].y
;
944 Polyline(hdc
, pts
, pPoly
->cpts
);
945 HeapFree( GetProcessHeap(), 0, pts
);
948 case EMR_POLYLINETO16
:
950 PEMRPOLYLINETO16 pPoly
= (PEMRPOLYLINETO16
) mr
;
951 /* Shouldn't use PolylineTo16 since pPoly->cpts is DWORD */
952 POINT
*pts
= HeapAlloc( GetProcessHeap(), 0,
953 pPoly
->cpts
* sizeof(POINT
) );
955 for(i
= 0; i
< pPoly
->cpts
; i
++)
957 pts
[i
].x
= pPoly
->apts
[i
].x
;
958 pts
[i
].y
= pPoly
->apts
[i
].y
;
960 PolylineTo(hdc
, pts
, pPoly
->cpts
);
961 HeapFree( GetProcessHeap(), 0, pts
);
964 case EMR_POLYBEZIER16
:
966 PEMRPOLYBEZIER16 pPoly
= (PEMRPOLYBEZIER16
) mr
;
967 /* Shouldn't use PolyBezier16 since pPoly->cpts is DWORD */
968 POINT
*pts
= HeapAlloc( GetProcessHeap(), 0,
969 pPoly
->cpts
* sizeof(POINT
) );
971 for(i
= 0; i
< pPoly
->cpts
; i
++)
973 pts
[i
].x
= pPoly
->apts
[i
].x
;
974 pts
[i
].y
= pPoly
->apts
[i
].y
;
976 PolyBezier(hdc
, pts
, pPoly
->cpts
);
977 HeapFree( GetProcessHeap(), 0, pts
);
980 case EMR_POLYBEZIERTO16
:
982 PEMRPOLYBEZIERTO16 pPoly
= (PEMRPOLYBEZIERTO16
) mr
;
983 /* Shouldn't use PolyBezierTo16 since pPoly->cpts is DWORD */
984 POINT
*pts
= HeapAlloc( GetProcessHeap(), 0,
985 pPoly
->cpts
* sizeof(POINT
) );
987 for(i
= 0; i
< pPoly
->cpts
; i
++)
989 pts
[i
].x
= pPoly
->apts
[i
].x
;
990 pts
[i
].y
= pPoly
->apts
[i
].y
;
992 PolyBezierTo(hdc
, pts
, pPoly
->cpts
);
993 HeapFree( GetProcessHeap(), 0, pts
);
996 case EMR_POLYPOLYGON16
:
998 PEMRPOLYPOLYGON16 pPolyPoly
= (PEMRPOLYPOLYGON16
) mr
;
999 /* NB POINTS array doesn't start at pPolyPoly->apts it's actually
1000 pPolyPoly->aPolyCounts + pPolyPoly->nPolys */
1002 POINT16
*pts16
= (POINT16
*)(pPolyPoly
->aPolyCounts
+ pPolyPoly
->nPolys
);
1003 POINT
*pts
= HeapAlloc( GetProcessHeap(), 0, pPolyPoly
->cpts
* sizeof(POINT
) );
1005 for(i
= 0; i
< pPolyPoly
->cpts
; i
++)
1007 pts
[i
].x
= pts16
[i
].x
;
1008 pts
[i
].y
= pts16
[i
].y
;
1010 PolyPolygon(hdc
, pts
, (INT
*)pPolyPoly
->aPolyCounts
, pPolyPoly
->nPolys
);
1011 HeapFree( GetProcessHeap(), 0, pts
);
1014 case EMR_POLYPOLYLINE16
:
1016 PEMRPOLYPOLYLINE16 pPolyPoly
= (PEMRPOLYPOLYLINE16
) mr
;
1017 /* NB POINTS array doesn't start at pPolyPoly->apts it's actually
1018 pPolyPoly->aPolyCounts + pPolyPoly->nPolys */
1020 POINT16
*pts16
= (POINT16
*)(pPolyPoly
->aPolyCounts
+ pPolyPoly
->nPolys
);
1021 POINT
*pts
= HeapAlloc( GetProcessHeap(), 0, pPolyPoly
->cpts
* sizeof(POINT
) );
1023 for(i
= 0; i
< pPolyPoly
->cpts
; i
++)
1025 pts
[i
].x
= pts16
[i
].x
;
1026 pts
[i
].y
= pts16
[i
].y
;
1028 PolyPolyline(hdc
, pts
, pPolyPoly
->aPolyCounts
, pPolyPoly
->nPolys
);
1029 HeapFree( GetProcessHeap(), 0, pts
);
1033 case EMR_STRETCHDIBITS
:
1035 EMRSTRETCHDIBITS
*pStretchDIBits
= (EMRSTRETCHDIBITS
*)mr
;
1038 pStretchDIBits
->xDest
,
1039 pStretchDIBits
->yDest
,
1040 pStretchDIBits
->cxDest
,
1041 pStretchDIBits
->cyDest
,
1042 pStretchDIBits
->xSrc
,
1043 pStretchDIBits
->ySrc
,
1044 pStretchDIBits
->cxSrc
,
1045 pStretchDIBits
->cySrc
,
1046 (BYTE
*)mr
+ pStretchDIBits
->offBitsSrc
,
1047 (const BITMAPINFO
*)((BYTE
*)mr
+ pStretchDIBits
->offBmiSrc
),
1048 pStretchDIBits
->iUsageSrc
,
1049 pStretchDIBits
->dwRop
);
1053 case EMR_EXTTEXTOUTA
:
1055 PEMREXTTEXTOUTA pExtTextOutA
= (PEMREXTTEXTOUTA
)mr
;
1059 rc
.left
= pExtTextOutA
->emrtext
.rcl
.left
;
1060 rc
.top
= pExtTextOutA
->emrtext
.rcl
.top
;
1061 rc
.right
= pExtTextOutA
->emrtext
.rcl
.right
;
1062 rc
.bottom
= pExtTextOutA
->emrtext
.rcl
.bottom
;
1063 TRACE("EMR_EXTTEXTOUTA: x,y = %ld, %ld. rect = %ld, %ld - %ld, %ld. flags %08lx\n",
1064 pExtTextOutA
->emrtext
.ptlReference
.x
, pExtTextOutA
->emrtext
.ptlReference
.y
,
1065 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, pExtTextOutA
->emrtext
.fOptions
);
1067 /* Linux version of pstoedit produces EMFs with offDx set to 0.
1068 * These files can be enumerated and played under Win98 just
1069 * fine, but at least Win2k chokes on them.
1071 if (pExtTextOutA
->emrtext
.offDx
)
1072 dx
= (INT
*)((BYTE
*)mr
+ pExtTextOutA
->emrtext
.offDx
);
1074 ExtTextOutA(hdc
, pExtTextOutA
->emrtext
.ptlReference
.x
, pExtTextOutA
->emrtext
.ptlReference
.y
,
1075 pExtTextOutA
->emrtext
.fOptions
, &rc
,
1076 (LPSTR
)((BYTE
*)mr
+ pExtTextOutA
->emrtext
.offString
), pExtTextOutA
->emrtext
.nChars
,
1081 case EMR_EXTTEXTOUTW
:
1083 PEMREXTTEXTOUTW pExtTextOutW
= (PEMREXTTEXTOUTW
)mr
;
1087 rc
.left
= pExtTextOutW
->emrtext
.rcl
.left
;
1088 rc
.top
= pExtTextOutW
->emrtext
.rcl
.top
;
1089 rc
.right
= pExtTextOutW
->emrtext
.rcl
.right
;
1090 rc
.bottom
= pExtTextOutW
->emrtext
.rcl
.bottom
;
1091 TRACE("EMR_EXTTEXTOUTW: x,y = %ld, %ld. rect = %ld, %ld - %ld, %ld. flags %08lx\n",
1092 pExtTextOutW
->emrtext
.ptlReference
.x
, pExtTextOutW
->emrtext
.ptlReference
.y
,
1093 rc
.left
, rc
.top
, rc
.right
, rc
.bottom
, pExtTextOutW
->emrtext
.fOptions
);
1095 /* Linux version of pstoedit produces EMFs with offDx set to 0.
1096 * These files can be enumerated and played under Win98 just
1097 * fine, but at least Win2k chokes on them.
1099 if (pExtTextOutW
->emrtext
.offDx
)
1100 dx
= (INT
*)((BYTE
*)mr
+ pExtTextOutW
->emrtext
.offDx
);
1102 ExtTextOutW(hdc
, pExtTextOutW
->emrtext
.ptlReference
.x
, pExtTextOutW
->emrtext
.ptlReference
.y
,
1103 pExtTextOutW
->emrtext
.fOptions
, &rc
,
1104 (LPWSTR
)((BYTE
*)mr
+ pExtTextOutW
->emrtext
.offString
), pExtTextOutW
->emrtext
.nChars
,
1109 case EMR_CREATEPALETTE
:
1111 PEMRCREATEPALETTE lpCreatePal
= (PEMRCREATEPALETTE
)mr
;
1113 (handletable
->objectHandle
)[ lpCreatePal
->ihPal
] =
1114 CreatePalette( &lpCreatePal
->lgpl
);
1119 case EMR_SELECTPALETTE
:
1121 PEMRSELECTPALETTE lpSelectPal
= (PEMRSELECTPALETTE
)mr
;
1123 if( lpSelectPal
->ihPal
& 0x80000000 ) {
1124 SelectPalette( hdc
, GetStockObject(lpSelectPal
->ihPal
& 0x7fffffff), TRUE
);
1126 (handletable
->objectHandle
)[ lpSelectPal
->ihPal
] =
1127 SelectPalette( hdc
, (handletable
->objectHandle
)[lpSelectPal
->ihPal
], TRUE
);
1132 case EMR_REALIZEPALETTE
:
1134 RealizePalette( hdc
);
1138 case EMR_EXTSELECTCLIPRGN
:
1141 PEMREXTSELECTCLIPRGN lpRgn
= (PEMREXTSELECTCLIPRGN
)mr
;
1142 HRGN hRgn
= ExtCreateRegion(NULL
, lpRgn
->cbRgnData
, (RGNDATA
*)lpRgn
->RgnData
);
1144 ExtSelectClipRgn(hdc
, hRgn
, (INT
)(lpRgn
->iMode
));
1145 /* ExtSelectClipRgn created a copy of the region */
1148 FIXME("ExtSelectClipRgn\n");
1152 case EMR_SETMETARGN
:
1158 case EMR_SETWORLDTRANSFORM
:
1160 PEMRSETWORLDTRANSFORM lpXfrm
= (PEMRSETWORLDTRANSFORM
)mr
;
1161 info
->world_transform
= lpXfrm
->xform
;
1165 case EMR_POLYBEZIER
:
1167 PEMRPOLYBEZIER lpPolyBez
= (PEMRPOLYBEZIER
)mr
;
1168 PolyBezier(hdc
, (const POINT
*)lpPolyBez
->aptl
, (UINT
)lpPolyBez
->cptl
);
1174 PEMRPOLYGON lpPoly
= (PEMRPOLYGON
)mr
;
1175 Polygon( hdc
, (const POINT
*)lpPoly
->aptl
, (UINT
)lpPoly
->cptl
);
1181 PEMRPOLYLINE lpPolyLine
= (PEMRPOLYLINE
)mr
;
1182 Polyline(hdc
, (const POINT
*)lpPolyLine
->aptl
, (UINT
)lpPolyLine
->cptl
);
1186 case EMR_POLYBEZIERTO
:
1188 PEMRPOLYBEZIERTO lpPolyBezierTo
= (PEMRPOLYBEZIERTO
)mr
;
1189 PolyBezierTo( hdc
, (const POINT
*)lpPolyBezierTo
->aptl
,
1190 (UINT
)lpPolyBezierTo
->cptl
);
1194 case EMR_POLYLINETO
:
1196 PEMRPOLYLINETO lpPolyLineTo
= (PEMRPOLYLINETO
)mr
;
1197 PolylineTo( hdc
, (const POINT
*)lpPolyLineTo
->aptl
,
1198 (UINT
)lpPolyLineTo
->cptl
);
1202 case EMR_POLYPOLYLINE
:
1204 PEMRPOLYPOLYLINE pPolyPolyline
= (PEMRPOLYPOLYLINE
) mr
;
1205 /* NB Points at pPolyPolyline->aPolyCounts + pPolyPolyline->nPolys */
1207 PolyPolyline(hdc
, (LPPOINT
)(pPolyPolyline
->aPolyCounts
+
1208 pPolyPolyline
->nPolys
),
1209 pPolyPolyline
->aPolyCounts
,
1210 pPolyPolyline
->nPolys
);
1215 case EMR_POLYPOLYGON
:
1217 PEMRPOLYPOLYGON pPolyPolygon
= (PEMRPOLYPOLYGON
) mr
;
1219 /* NB Points at pPolyPolygon->aPolyCounts + pPolyPolygon->nPolys */
1221 PolyPolygon(hdc
, (LPPOINT
)(pPolyPolygon
->aPolyCounts
+
1222 pPolyPolygon
->nPolys
),
1223 (INT
*)pPolyPolygon
->aPolyCounts
, pPolyPolygon
->nPolys
);
1227 case EMR_SETBRUSHORGEX
:
1229 PEMRSETBRUSHORGEX lpSetBrushOrgEx
= (PEMRSETBRUSHORGEX
)mr
;
1232 (INT
)lpSetBrushOrgEx
->ptlOrigin
.x
,
1233 (INT
)lpSetBrushOrgEx
->ptlOrigin
.y
,
1241 PEMRSETPIXELV lpSetPixelV
= (PEMRSETPIXELV
)mr
;
1244 (INT
)lpSetPixelV
->ptlPixel
.x
,
1245 (INT
)lpSetPixelV
->ptlPixel
.y
,
1246 lpSetPixelV
->crColor
);
1251 case EMR_SETMAPPERFLAGS
:
1253 PEMRSETMAPPERFLAGS lpSetMapperFlags
= (PEMRSETMAPPERFLAGS
)mr
;
1255 SetMapperFlags( hdc
, lpSetMapperFlags
->dwFlags
);
1260 case EMR_SETCOLORADJUSTMENT
:
1262 PEMRSETCOLORADJUSTMENT lpSetColorAdjust
= (PEMRSETCOLORADJUSTMENT
)mr
;
1264 SetColorAdjustment( hdc
, &lpSetColorAdjust
->ColorAdjustment
);
1269 case EMR_OFFSETCLIPRGN
:
1271 PEMROFFSETCLIPRGN lpOffsetClipRgn
= (PEMROFFSETCLIPRGN
)mr
;
1274 (INT
)lpOffsetClipRgn
->ptlOffset
.x
,
1275 (INT
)lpOffsetClipRgn
->ptlOffset
.y
);
1276 FIXME("OffsetClipRgn\n");
1281 case EMR_EXCLUDECLIPRECT
:
1283 PEMREXCLUDECLIPRECT lpExcludeClipRect
= (PEMREXCLUDECLIPRECT
)mr
;
1285 ExcludeClipRect( hdc
,
1286 lpExcludeClipRect
->rclClip
.left
,
1287 lpExcludeClipRect
->rclClip
.top
,
1288 lpExcludeClipRect
->rclClip
.right
,
1289 lpExcludeClipRect
->rclClip
.bottom
);
1290 FIXME("ExcludeClipRect\n");
1295 case EMR_SCALEVIEWPORTEXTEX
:
1297 PEMRSCALEVIEWPORTEXTEX lpScaleViewportExtEx
= (PEMRSCALEVIEWPORTEXTEX
)mr
;
1299 if ((info
->mode
!= MM_ISOTROPIC
) && (info
->mode
!= MM_ANISOTROPIC
))
1301 if (!lpScaleViewportExtEx
->xNum
|| !lpScaleViewportExtEx
->xDenom
||
1302 !lpScaleViewportExtEx
->yNum
|| !lpScaleViewportExtEx
->yDenom
)
1304 info
->vportExtX
= (info
->vportExtX
* lpScaleViewportExtEx
->xNum
) /
1305 lpScaleViewportExtEx
->xDenom
;
1306 info
->vportExtY
= (info
->vportExtY
* lpScaleViewportExtEx
->yNum
) /
1307 lpScaleViewportExtEx
->yDenom
;
1308 if (info
->vportExtX
== 0) info
->vportExtX
= 1;
1309 if (info
->vportExtY
== 0) info
->vportExtY
= 1;
1310 if (info
->mode
== MM_ISOTROPIC
)
1311 FIXME("EMRSCALEVIEWPORTEXTEX MM_ISOTROPIC mapping\n");
1312 /* MAPPING_FixIsotropic( dc ); */
1314 TRACE("EMRSCALEVIEWPORTEXTEX %ld/%ld %ld/%ld\n",
1315 lpScaleViewportExtEx
->xNum
,lpScaleViewportExtEx
->xDenom
,
1316 lpScaleViewportExtEx
->yNum
,lpScaleViewportExtEx
->yDenom
);
1321 case EMR_SCALEWINDOWEXTEX
:
1323 PEMRSCALEWINDOWEXTEX lpScaleWindowExtEx
= (PEMRSCALEWINDOWEXTEX
)mr
;
1325 if ((info
->mode
!= MM_ISOTROPIC
) && (info
->mode
!= MM_ANISOTROPIC
))
1327 if (!lpScaleWindowExtEx
->xNum
|| !lpScaleWindowExtEx
->xDenom
||
1328 !lpScaleWindowExtEx
->xNum
|| !lpScaleWindowExtEx
->yDenom
)
1330 info
->wndExtX
= (info
->wndExtX
* lpScaleWindowExtEx
->xNum
) /
1331 lpScaleWindowExtEx
->xDenom
;
1332 info
->wndExtY
= (info
->wndExtY
* lpScaleWindowExtEx
->yNum
) /
1333 lpScaleWindowExtEx
->yDenom
;
1334 if (info
->wndExtX
== 0) info
->wndExtX
= 1;
1335 if (info
->wndExtY
== 0) info
->wndExtY
= 1;
1336 if (info
->mode
== MM_ISOTROPIC
)
1337 FIXME("EMRSCALEWINDOWEXTEX MM_ISOTROPIC mapping\n");
1338 /* MAPPING_FixIsotropic( dc ); */
1340 TRACE("EMRSCALEWINDOWEXTEX %ld/%ld %ld/%ld\n",
1341 lpScaleWindowExtEx
->xNum
,lpScaleWindowExtEx
->xDenom
,
1342 lpScaleWindowExtEx
->yNum
,lpScaleWindowExtEx
->yDenom
);
1347 case EMR_MODIFYWORLDTRANSFORM
:
1349 PEMRMODIFYWORLDTRANSFORM lpModifyWorldTrans
= (PEMRMODIFYWORLDTRANSFORM
)mr
;
1351 switch(lpModifyWorldTrans
->iMode
) {
1353 info
->world_transform
.eM11
= info
->world_transform
.eM22
= 1;
1354 info
->world_transform
.eM12
= info
->world_transform
.eM21
= 0;
1355 info
->world_transform
.eDx
= info
->world_transform
.eDy
= 0;
1357 case MWT_LEFTMULTIPLY
:
1358 CombineTransform(&info
->world_transform
, &lpModifyWorldTrans
->xform
,
1359 &info
->world_transform
);
1361 case MWT_RIGHTMULTIPLY
:
1362 CombineTransform(&info
->world_transform
, &info
->world_transform
,
1363 &lpModifyWorldTrans
->xform
);
1366 FIXME("Unknown imode %ld\n", lpModifyWorldTrans
->iMode
);
1374 PEMRANGLEARC lpAngleArc
= (PEMRANGLEARC
)mr
;
1377 (INT
)lpAngleArc
->ptlCenter
.x
, (INT
)lpAngleArc
->ptlCenter
.y
,
1378 lpAngleArc
->nRadius
, lpAngleArc
->eStartAngle
,
1379 lpAngleArc
->eSweepAngle
);
1386 PEMRROUNDRECT lpRoundRect
= (PEMRROUNDRECT
)mr
;
1389 lpRoundRect
->rclBox
.left
,
1390 lpRoundRect
->rclBox
.top
,
1391 lpRoundRect
->rclBox
.right
,
1392 lpRoundRect
->rclBox
.bottom
,
1393 lpRoundRect
->szlCorner
.cx
,
1394 lpRoundRect
->szlCorner
.cy
);
1401 PEMRARC lpArc
= (PEMRARC
)mr
;
1404 (INT
)lpArc
->rclBox
.left
,
1405 (INT
)lpArc
->rclBox
.top
,
1406 (INT
)lpArc
->rclBox
.right
,
1407 (INT
)lpArc
->rclBox
.bottom
,
1408 (INT
)lpArc
->ptlStart
.x
,
1409 (INT
)lpArc
->ptlStart
.y
,
1410 (INT
)lpArc
->ptlEnd
.x
,
1411 (INT
)lpArc
->ptlEnd
.y
);
1418 PEMRCHORD lpChord
= (PEMRCHORD
)mr
;
1421 (INT
)lpChord
->rclBox
.left
,
1422 (INT
)lpChord
->rclBox
.top
,
1423 (INT
)lpChord
->rclBox
.right
,
1424 (INT
)lpChord
->rclBox
.bottom
,
1425 (INT
)lpChord
->ptlStart
.x
,
1426 (INT
)lpChord
->ptlStart
.y
,
1427 (INT
)lpChord
->ptlEnd
.x
,
1428 (INT
)lpChord
->ptlEnd
.y
);
1435 PEMRPIE lpPie
= (PEMRPIE
)mr
;
1438 (INT
)lpPie
->rclBox
.left
,
1439 (INT
)lpPie
->rclBox
.top
,
1440 (INT
)lpPie
->rclBox
.right
,
1441 (INT
)lpPie
->rclBox
.bottom
,
1442 (INT
)lpPie
->ptlStart
.x
,
1443 (INT
)lpPie
->ptlStart
.y
,
1444 (INT
)lpPie
->ptlEnd
.x
,
1445 (INT
)lpPie
->ptlEnd
.y
);
1452 PEMRARC lpArcTo
= (PEMRARC
)mr
;
1455 (INT
)lpArcTo
->rclBox
.left
,
1456 (INT
)lpArcTo
->rclBox
.top
,
1457 (INT
)lpArcTo
->rclBox
.right
,
1458 (INT
)lpArcTo
->rclBox
.bottom
,
1459 (INT
)lpArcTo
->ptlStart
.x
,
1460 (INT
)lpArcTo
->ptlStart
.y
,
1461 (INT
)lpArcTo
->ptlEnd
.x
,
1462 (INT
)lpArcTo
->ptlEnd
.y
);
1467 case EMR_EXTFLOODFILL
:
1469 PEMREXTFLOODFILL lpExtFloodFill
= (PEMREXTFLOODFILL
)mr
;
1472 (INT
)lpExtFloodFill
->ptlStart
.x
,
1473 (INT
)lpExtFloodFill
->ptlStart
.y
,
1474 lpExtFloodFill
->crColor
,
1475 (UINT
)lpExtFloodFill
->iMode
);
1482 PEMRPOLYDRAW lpPolyDraw
= (PEMRPOLYDRAW
)mr
;
1484 (const POINT
*)lpPolyDraw
->aptl
,
1485 lpPolyDraw
->abTypes
,
1486 (INT
)lpPolyDraw
->cptl
);
1491 case EMR_SETARCDIRECTION
:
1493 PEMRSETARCDIRECTION lpSetArcDirection
= (PEMRSETARCDIRECTION
)mr
;
1494 SetArcDirection( hdc
, (INT
)lpSetArcDirection
->iArcDirection
);
1498 case EMR_SETMITERLIMIT
:
1500 PEMRSETMITERLIMIT lpSetMiterLimit
= (PEMRSETMITERLIMIT
)mr
;
1501 SetMiterLimit( hdc
, lpSetMiterLimit
->eMiterLimit
, NULL
);
1517 case EMR_CLOSEFIGURE
:
1525 /*PEMRFILLPATH lpFillPath = (PEMRFILLPATH)mr;*/
1530 case EMR_STROKEANDFILLPATH
:
1532 /*PEMRSTROKEANDFILLPATH lpStrokeAndFillPath = (PEMRSTROKEANDFILLPATH)mr;*/
1533 StrokeAndFillPath( hdc
);
1537 case EMR_STROKEPATH
:
1539 /*PEMRSTROKEPATH lpStrokePath = (PEMRSTROKEPATH)mr;*/
1544 case EMR_FLATTENPATH
:
1556 case EMR_SELECTCLIPPATH
:
1558 PEMRSELECTCLIPPATH lpSelectClipPath
= (PEMRSELECTCLIPPATH
)mr
;
1559 SelectClipPath( hdc
, (INT
)lpSelectClipPath
->iMode
);
1569 case EMR_CREATECOLORSPACE
:
1571 PEMRCREATECOLORSPACE lpCreateColorSpace
= (PEMRCREATECOLORSPACE
)mr
;
1572 (handletable
->objectHandle
)[lpCreateColorSpace
->ihCS
] =
1573 CreateColorSpaceA( &lpCreateColorSpace
->lcs
);
1577 case EMR_SETCOLORSPACE
:
1579 PEMRSETCOLORSPACE lpSetColorSpace
= (PEMRSETCOLORSPACE
)mr
;
1581 (handletable
->objectHandle
)[lpSetColorSpace
->ihCS
] );
1585 case EMR_DELETECOLORSPACE
:
1587 PEMRDELETECOLORSPACE lpDeleteColorSpace
= (PEMRDELETECOLORSPACE
)mr
;
1588 DeleteColorSpace( (handletable
->objectHandle
)[lpDeleteColorSpace
->ihCS
] );
1592 case EMR_SETICMMODE
:
1594 PEMRSETICMMODE lpSetICMMode
= (PEMRSETICMMODE
)mr
;
1595 SetICMMode( hdc
, (INT
)lpSetICMMode
->iMode
);
1599 case EMR_PIXELFORMAT
:
1602 PEMRPIXELFORMAT lpPixelFormat
= (PEMRPIXELFORMAT
)mr
;
1604 iPixelFormat
= ChoosePixelFormat( hdc
, &lpPixelFormat
->pfd
);
1605 SetPixelFormat( hdc
, iPixelFormat
, &lpPixelFormat
->pfd
);
1610 case EMR_SETPALETTEENTRIES
:
1612 PEMRSETPALETTEENTRIES lpSetPaletteEntries
= (PEMRSETPALETTEENTRIES
)mr
;
1614 SetPaletteEntries( (handletable
->objectHandle
)[lpSetPaletteEntries
->ihPal
],
1615 (UINT
)lpSetPaletteEntries
->iStart
,
1616 (UINT
)lpSetPaletteEntries
->cEntries
,
1617 lpSetPaletteEntries
->aPalEntries
);
1622 case EMR_RESIZEPALETTE
:
1624 PEMRRESIZEPALETTE lpResizePalette
= (PEMRRESIZEPALETTE
)mr
;
1626 ResizePalette( (handletable
->objectHandle
)[lpResizePalette
->ihPal
],
1627 (UINT
)lpResizePalette
->cEntries
);
1632 case EMR_CREATEDIBPATTERNBRUSHPT
:
1634 PEMRCREATEDIBPATTERNBRUSHPT lpCreate
= (PEMRCREATEDIBPATTERNBRUSHPT
)mr
;
1635 LPVOID lpPackedStruct
;
1637 /* check that offsets and data are contained within the record */
1638 if ( !( (lpCreate
->cbBmi
>=0) && (lpCreate
->cbBits
>=0) &&
1639 (lpCreate
->offBmi
>=0) && (lpCreate
->offBits
>=0) &&
1640 ((lpCreate
->offBmi
+lpCreate
->cbBmi
) <= mr
->nSize
) &&
1641 ((lpCreate
->offBits
+lpCreate
->cbBits
) <= mr
->nSize
) ) )
1643 ERR("Invalid EMR_CREATEDIBPATTERNBRUSHPT record\n");
1647 /* This is a BITMAPINFO struct followed directly by bitmap bits */
1648 lpPackedStruct
= HeapAlloc( GetProcessHeap(), 0,
1649 lpCreate
->cbBmi
+ lpCreate
->cbBits
);
1652 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1656 /* Now pack this structure */
1657 memcpy( lpPackedStruct
,
1658 ((BYTE
*)lpCreate
) + lpCreate
->offBmi
,
1660 memcpy( ((BYTE
*)lpPackedStruct
) + lpCreate
->cbBmi
,
1661 ((BYTE
*)lpCreate
) + lpCreate
->offBits
,
1664 (handletable
->objectHandle
)[lpCreate
->ihBrush
] =
1665 CreateDIBPatternBrushPt( lpPackedStruct
,
1666 (UINT
)lpCreate
->iUsage
);
1668 HeapFree(GetProcessHeap(), 0, lpPackedStruct
);
1672 case EMR_CREATEMONOBRUSH
:
1674 PEMRCREATEMONOBRUSH pCreateMonoBrush
= (PEMRCREATEMONOBRUSH
)mr
;
1675 BITMAPINFO
*pbi
= (BITMAPINFO
*)((BYTE
*)mr
+ pCreateMonoBrush
->offBmi
);
1678 /* Need to check if the bitmap is monochrome, and if the
1679 two colors are really black and white */
1680 if (pCreateMonoBrush
->iUsage
== DIB_PAL_MONO
)
1684 /* Undocumented iUsage indicates a mono bitmap with no palette table,
1685 * aligned to 32 rather than 16 bits.
1688 bm
.bmWidth
= pbi
->bmiHeader
.biWidth
;
1689 bm
.bmHeight
= abs(pbi
->bmiHeader
.biHeight
);
1690 bm
.bmWidthBytes
= 4 * ((pbi
->bmiHeader
.biWidth
+ 31) / 32);
1691 bm
.bmPlanes
= pbi
->bmiHeader
.biPlanes
;
1692 bm
.bmBitsPixel
= pbi
->bmiHeader
.biBitCount
;
1693 bm
.bmBits
= (BYTE
*)mr
+ pCreateMonoBrush
->offBits
;
1694 hBmp
= CreateBitmapIndirect(&bm
);
1696 else if (is_dib_monochrome(pbi
))
1698 /* Top-down DIBs have a negative height */
1699 LONG height
= pbi
->bmiHeader
.biHeight
;
1701 hBmp
= CreateBitmap(pbi
->bmiHeader
.biWidth
, abs(height
), 1, 1, NULL
);
1702 SetDIBits(hdc
, hBmp
, 0, pbi
->bmiHeader
.biHeight
,
1703 (BYTE
*)mr
+ pCreateMonoBrush
->offBits
, pbi
, pCreateMonoBrush
->iUsage
);
1707 hBmp
= CreateDIBitmap(hdc
, (BITMAPINFOHEADER
*)pbi
, CBM_INIT
,
1708 (BYTE
*)mr
+ pCreateMonoBrush
->offBits
, pbi
, pCreateMonoBrush
->iUsage
);
1711 (handletable
->objectHandle
)[pCreateMonoBrush
->ihBrush
] = CreatePatternBrush(hBmp
);
1713 /* CreatePatternBrush created a copy of the bitmap */
1720 PEMRBITBLT pBitBlt
= (PEMRBITBLT
)mr
;
1722 if(pBitBlt
->offBmiSrc
== 0) { /* Record is a PatBlt */
1723 PatBlt(hdc
, pBitBlt
->xDest
, pBitBlt
->yDest
, pBitBlt
->cxDest
, pBitBlt
->cyDest
,
1725 } else { /* BitBlt */
1726 HDC hdcSrc
= CreateCompatibleDC(hdc
);
1727 HBRUSH hBrush
, hBrushOld
;
1728 HBITMAP hBmp
= 0, hBmpOld
= 0;
1729 BITMAPINFO
*pbi
= (BITMAPINFO
*)((BYTE
*)mr
+ pBitBlt
->offBmiSrc
);
1731 SetWorldTransform(hdcSrc
, &pBitBlt
->xformSrc
);
1733 hBrush
= CreateSolidBrush(pBitBlt
->crBkColorSrc
);
1734 hBrushOld
= SelectObject(hdcSrc
, hBrush
);
1735 PatBlt(hdcSrc
, pBitBlt
->rclBounds
.left
, pBitBlt
->rclBounds
.top
,
1736 pBitBlt
->rclBounds
.right
- pBitBlt
->rclBounds
.left
,
1737 pBitBlt
->rclBounds
.bottom
- pBitBlt
->rclBounds
.top
, PATCOPY
);
1738 SelectObject(hdcSrc
, hBrushOld
);
1739 DeleteObject(hBrush
);
1741 hBmp
= CreateDIBitmap(hdc
, (BITMAPINFOHEADER
*)pbi
, CBM_INIT
,
1742 (BYTE
*)mr
+ pBitBlt
->offBitsSrc
, pbi
, pBitBlt
->iUsageSrc
);
1743 hBmpOld
= SelectObject(hdcSrc
, hBmp
);
1745 BitBlt(hdc
, pBitBlt
->xDest
, pBitBlt
->yDest
, pBitBlt
->cxDest
, pBitBlt
->cyDest
,
1746 hdcSrc
, pBitBlt
->xSrc
, pBitBlt
->ySrc
, pBitBlt
->dwRop
);
1748 SelectObject(hdcSrc
, hBmpOld
);
1755 case EMR_STRETCHBLT
:
1757 PEMRSTRETCHBLT pStretchBlt
= (PEMRSTRETCHBLT
)mr
;
1759 TRACE("EMR_STRETCHBLT: %ld, %ld %ldx%ld -> %ld, %ld %ldx%ld. rop %08lx offBitsSrc %ld\n",
1760 pStretchBlt
->xSrc
, pStretchBlt
->ySrc
, pStretchBlt
->cxSrc
, pStretchBlt
->cySrc
,
1761 pStretchBlt
->xDest
, pStretchBlt
->yDest
, pStretchBlt
->cxDest
, pStretchBlt
->cyDest
,
1762 pStretchBlt
->dwRop
, pStretchBlt
->offBitsSrc
);
1764 if(pStretchBlt
->offBmiSrc
== 0) { /* Record is a PatBlt */
1765 PatBlt(hdc
, pStretchBlt
->xDest
, pStretchBlt
->yDest
, pStretchBlt
->cxDest
, pStretchBlt
->cyDest
,
1766 pStretchBlt
->dwRop
);
1767 } else { /* StretchBlt */
1768 HDC hdcSrc
= CreateCompatibleDC(hdc
);
1769 HBRUSH hBrush
, hBrushOld
;
1770 HBITMAP hBmp
= 0, hBmpOld
= 0;
1771 BITMAPINFO
*pbi
= (BITMAPINFO
*)((BYTE
*)mr
+ pStretchBlt
->offBmiSrc
);
1773 SetWorldTransform(hdcSrc
, &pStretchBlt
->xformSrc
);
1775 hBrush
= CreateSolidBrush(pStretchBlt
->crBkColorSrc
);
1776 hBrushOld
= SelectObject(hdcSrc
, hBrush
);
1777 PatBlt(hdcSrc
, pStretchBlt
->rclBounds
.left
, pStretchBlt
->rclBounds
.top
,
1778 pStretchBlt
->rclBounds
.right
- pStretchBlt
->rclBounds
.left
,
1779 pStretchBlt
->rclBounds
.bottom
- pStretchBlt
->rclBounds
.top
, PATCOPY
);
1780 SelectObject(hdcSrc
, hBrushOld
);
1781 DeleteObject(hBrush
);
1783 hBmp
= CreateDIBitmap(hdc
, (BITMAPINFOHEADER
*)pbi
, CBM_INIT
,
1784 (BYTE
*)mr
+ pStretchBlt
->offBitsSrc
, pbi
, pStretchBlt
->iUsageSrc
);
1785 hBmpOld
= SelectObject(hdcSrc
, hBmp
);
1787 StretchBlt(hdc
, pStretchBlt
->xDest
, pStretchBlt
->yDest
, pStretchBlt
->cxDest
, pStretchBlt
->cyDest
,
1788 hdcSrc
, pStretchBlt
->xSrc
, pStretchBlt
->ySrc
, pStretchBlt
->cxSrc
, pStretchBlt
->cySrc
,
1789 pStretchBlt
->dwRop
);
1791 SelectObject(hdcSrc
, hBmpOld
);
1800 PEMRMASKBLT pMaskBlt
= (PEMRMASKBLT
)mr
;
1801 HDC hdcSrc
= CreateCompatibleDC(hdc
);
1802 HBRUSH hBrush
, hBrushOld
;
1803 HBITMAP hBmp
, hBmpOld
, hBmpMask
;
1806 SetWorldTransform(hdcSrc
, &pMaskBlt
->xformSrc
);
1808 hBrush
= CreateSolidBrush(pMaskBlt
->crBkColorSrc
);
1809 hBrushOld
= SelectObject(hdcSrc
, hBrush
);
1810 PatBlt(hdcSrc
, pMaskBlt
->rclBounds
.left
, pMaskBlt
->rclBounds
.top
,
1811 pMaskBlt
->rclBounds
.right
- pMaskBlt
->rclBounds
.left
,
1812 pMaskBlt
->rclBounds
.bottom
- pMaskBlt
->rclBounds
.top
, PATCOPY
);
1813 SelectObject(hdcSrc
, hBrushOld
);
1814 DeleteObject(hBrush
);
1816 pbi
= (BITMAPINFO
*)((BYTE
*)mr
+ pMaskBlt
->offBmiMask
);
1817 hBmpMask
= CreateBitmap(pbi
->bmiHeader
.biWidth
, pbi
->bmiHeader
.biHeight
,
1819 SetDIBits(hdc
, hBmpMask
, 0, pbi
->bmiHeader
.biHeight
,
1820 (BYTE
*)mr
+ pMaskBlt
->offBitsMask
, pbi
, pMaskBlt
->iUsageMask
);
1822 pbi
= (BITMAPINFO
*)((BYTE
*)mr
+ pMaskBlt
->offBmiSrc
);
1823 hBmp
= CreateDIBitmap(hdc
, (BITMAPINFOHEADER
*)pbi
, CBM_INIT
,
1824 (BYTE
*)mr
+ pMaskBlt
->offBitsSrc
, pbi
, pMaskBlt
->iUsageSrc
);
1825 hBmpOld
= SelectObject(hdcSrc
, hBmp
);
1838 SelectObject(hdcSrc
, hBmpOld
);
1840 DeleteObject(hBmpMask
);
1847 PEMRPLGBLT pPlgBlt
= (PEMRPLGBLT
)mr
;
1848 HDC hdcSrc
= CreateCompatibleDC(hdc
);
1849 HBRUSH hBrush
, hBrushOld
;
1850 HBITMAP hBmp
, hBmpOld
, hBmpMask
;
1854 SetWorldTransform(hdcSrc
, &pPlgBlt
->xformSrc
);
1856 pts
[0].x
= pPlgBlt
->aptlDest
[0].x
; pts
[0].y
= pPlgBlt
->aptlDest
[0].y
;
1857 pts
[1].x
= pPlgBlt
->aptlDest
[1].x
; pts
[1].y
= pPlgBlt
->aptlDest
[1].y
;
1858 pts
[2].x
= pPlgBlt
->aptlDest
[2].x
; pts
[2].y
= pPlgBlt
->aptlDest
[2].y
;
1860 hBrush
= CreateSolidBrush(pPlgBlt
->crBkColorSrc
);
1861 hBrushOld
= SelectObject(hdcSrc
, hBrush
);
1862 PatBlt(hdcSrc
, pPlgBlt
->rclBounds
.left
, pPlgBlt
->rclBounds
.top
,
1863 pPlgBlt
->rclBounds
.right
- pPlgBlt
->rclBounds
.left
,
1864 pPlgBlt
->rclBounds
.bottom
- pPlgBlt
->rclBounds
.top
, PATCOPY
);
1865 SelectObject(hdcSrc
, hBrushOld
);
1866 DeleteObject(hBrush
);
1868 pbi
= (BITMAPINFO
*)((BYTE
*)mr
+ pPlgBlt
->offBmiMask
);
1869 hBmpMask
= CreateBitmap(pbi
->bmiHeader
.biWidth
, pbi
->bmiHeader
.biHeight
,
1871 SetDIBits(hdc
, hBmpMask
, 0, pbi
->bmiHeader
.biHeight
,
1872 (BYTE
*)mr
+ pPlgBlt
->offBitsMask
, pbi
, pPlgBlt
->iUsageMask
);
1874 pbi
= (BITMAPINFO
*)((BYTE
*)mr
+ pPlgBlt
->offBmiSrc
);
1875 hBmp
= CreateDIBitmap(hdc
, (BITMAPINFOHEADER
*)pbi
, CBM_INIT
,
1876 (BYTE
*)mr
+ pPlgBlt
->offBitsSrc
, pbi
, pPlgBlt
->iUsageSrc
);
1877 hBmpOld
= SelectObject(hdcSrc
, hBmp
);
1888 SelectObject(hdcSrc
, hBmpOld
);
1890 DeleteObject(hBmpMask
);
1895 case EMR_SETDIBITSTODEVICE
:
1897 PEMRSETDIBITSTODEVICE pSetDIBitsToDevice
= (PEMRSETDIBITSTODEVICE
)mr
;
1899 SetDIBitsToDevice(hdc
,
1900 pSetDIBitsToDevice
->xDest
,
1901 pSetDIBitsToDevice
->yDest
,
1902 pSetDIBitsToDevice
->cxSrc
,
1903 pSetDIBitsToDevice
->cySrc
,
1904 pSetDIBitsToDevice
->xSrc
,
1905 pSetDIBitsToDevice
->ySrc
,
1906 pSetDIBitsToDevice
->iStartScan
,
1907 pSetDIBitsToDevice
->cScans
,
1908 (BYTE
*)mr
+ pSetDIBitsToDevice
->offBitsSrc
,
1909 (BITMAPINFO
*)((BYTE
*)mr
+ pSetDIBitsToDevice
->offBmiSrc
),
1910 pSetDIBitsToDevice
->iUsageSrc
);
1914 case EMR_POLYTEXTOUTA
:
1916 PEMRPOLYTEXTOUTA pPolyTextOutA
= (PEMRPOLYTEXTOUTA
)mr
;
1917 POLYTEXTA
*polytextA
= HeapAlloc(GetProcessHeap(), 0, pPolyTextOutA
->cStrings
* sizeof(POLYTEXTA
));
1919 XFORM xform
, xformOld
;
1922 gModeOld
= SetGraphicsMode(hdc
, pPolyTextOutA
->iGraphicsMode
);
1923 GetWorldTransform(hdc
, &xformOld
);
1925 xform
.eM11
= pPolyTextOutA
->exScale
;
1928 xform
.eM22
= pPolyTextOutA
->eyScale
;
1931 SetWorldTransform(hdc
, &xform
);
1933 /* Set up POLYTEXTA structures */
1934 for(i
= 0; i
< pPolyTextOutA
->cStrings
; i
++)
1936 polytextA
[i
].x
= pPolyTextOutA
->aemrtext
[i
].ptlReference
.x
;
1937 polytextA
[i
].y
= pPolyTextOutA
->aemrtext
[i
].ptlReference
.y
;
1938 polytextA
[i
].n
= pPolyTextOutA
->aemrtext
[i
].nChars
;
1939 polytextA
[i
].lpstr
= (LPSTR
)((BYTE
*)mr
+ pPolyTextOutA
->aemrtext
[i
].offString
);
1940 polytextA
[i
].uiFlags
= pPolyTextOutA
->aemrtext
[i
].fOptions
;
1941 polytextA
[i
].rcl
.left
= pPolyTextOutA
->aemrtext
[i
].rcl
.left
;
1942 polytextA
[i
].rcl
.right
= pPolyTextOutA
->aemrtext
[i
].rcl
.right
;
1943 polytextA
[i
].rcl
.top
= pPolyTextOutA
->aemrtext
[i
].rcl
.top
;
1944 polytextA
[i
].rcl
.bottom
= pPolyTextOutA
->aemrtext
[i
].rcl
.bottom
;
1945 polytextA
[i
].pdx
= (int *)((BYTE
*)mr
+ pPolyTextOutA
->aemrtext
[i
].offDx
);
1947 PolyTextOutA(hdc
, polytextA
, pPolyTextOutA
->cStrings
);
1948 HeapFree(GetProcessHeap(), 0, polytextA
);
1950 SetWorldTransform(hdc
, &xformOld
);
1951 SetGraphicsMode(hdc
, gModeOld
);
1955 case EMR_POLYTEXTOUTW
:
1957 PEMRPOLYTEXTOUTW pPolyTextOutW
= (PEMRPOLYTEXTOUTW
)mr
;
1958 POLYTEXTW
*polytextW
= HeapAlloc(GetProcessHeap(), 0, pPolyTextOutW
->cStrings
* sizeof(POLYTEXTW
));
1960 XFORM xform
, xformOld
;
1963 gModeOld
= SetGraphicsMode(hdc
, pPolyTextOutW
->iGraphicsMode
);
1964 GetWorldTransform(hdc
, &xformOld
);
1966 xform
.eM11
= pPolyTextOutW
->exScale
;
1969 xform
.eM22
= pPolyTextOutW
->eyScale
;
1972 SetWorldTransform(hdc
, &xform
);
1974 /* Set up POLYTEXTW structures */
1975 for(i
= 0; i
< pPolyTextOutW
->cStrings
; i
++)
1977 polytextW
[i
].x
= pPolyTextOutW
->aemrtext
[i
].ptlReference
.x
;
1978 polytextW
[i
].y
= pPolyTextOutW
->aemrtext
[i
].ptlReference
.y
;
1979 polytextW
[i
].n
= pPolyTextOutW
->aemrtext
[i
].nChars
;
1980 polytextW
[i
].lpstr
= (LPWSTR
)((BYTE
*)mr
+ pPolyTextOutW
->aemrtext
[i
].offString
);
1981 polytextW
[i
].uiFlags
= pPolyTextOutW
->aemrtext
[i
].fOptions
;
1982 polytextW
[i
].rcl
.left
= pPolyTextOutW
->aemrtext
[i
].rcl
.left
;
1983 polytextW
[i
].rcl
.right
= pPolyTextOutW
->aemrtext
[i
].rcl
.right
;
1984 polytextW
[i
].rcl
.top
= pPolyTextOutW
->aemrtext
[i
].rcl
.top
;
1985 polytextW
[i
].rcl
.bottom
= pPolyTextOutW
->aemrtext
[i
].rcl
.bottom
;
1986 polytextW
[i
].pdx
= (int *)((BYTE
*)mr
+ pPolyTextOutW
->aemrtext
[i
].offDx
);
1988 PolyTextOutW(hdc
, polytextW
, pPolyTextOutW
->cStrings
);
1989 HeapFree(GetProcessHeap(), 0, polytextW
);
1991 SetWorldTransform(hdc
, &xformOld
);
1992 SetGraphicsMode(hdc
, gModeOld
);
1998 PEMRFILLRGN pFillRgn
= (PEMRFILLRGN
)mr
;
1999 HRGN hRgn
= ExtCreateRegion(NULL
, pFillRgn
->cbRgnData
, (RGNDATA
*)pFillRgn
->RgnData
);
2002 (handletable
->objectHandle
)[pFillRgn
->ihBrush
]);
2009 PEMRFRAMERGN pFrameRgn
= (PEMRFRAMERGN
)mr
;
2010 HRGN hRgn
= ExtCreateRegion(NULL
, pFrameRgn
->cbRgnData
, (RGNDATA
*)pFrameRgn
->RgnData
);
2013 (handletable
->objectHandle
)[pFrameRgn
->ihBrush
],
2014 pFrameRgn
->szlStroke
.cx
,
2015 pFrameRgn
->szlStroke
.cy
);
2022 PEMRINVERTRGN pInvertRgn
= (PEMRINVERTRGN
)mr
;
2023 HRGN hRgn
= ExtCreateRegion(NULL
, pInvertRgn
->cbRgnData
, (RGNDATA
*)pInvertRgn
->RgnData
);
2024 InvertRgn(hdc
, hRgn
);
2031 PEMRPAINTRGN pPaintRgn
= (PEMRPAINTRGN
)mr
;
2032 HRGN hRgn
= ExtCreateRegion(NULL
, pPaintRgn
->cbRgnData
, (RGNDATA
*)pPaintRgn
->RgnData
);
2033 PaintRgn(hdc
, hRgn
);
2038 case EMR_SETTEXTJUSTIFICATION
:
2040 PEMRSETTEXTJUSTIFICATION pSetTextJust
= (PEMRSETTEXTJUSTIFICATION
)mr
;
2041 SetTextJustification(hdc
, pSetTextJust
->nBreakExtra
, pSetTextJust
->nBreakCount
);
2047 PEMRSETLAYOUT pSetLayout
= (PEMRSETLAYOUT
)mr
;
2048 SetLayout(hdc
, pSetLayout
->iMode
);
2052 case EMR_POLYDRAW16
:
2054 case EMR_GLSBOUNDEDRECORD
:
2055 case EMR_DRAWESCAPE
:
2058 case EMR_SMALLTEXTOUT
:
2059 case EMR_FORCEUFIMAPPING
:
2060 case EMR_NAMEDESCAPE
:
2061 case EMR_COLORCORRECTPALETTE
:
2062 case EMR_SETICMPROFILEA
:
2063 case EMR_SETICMPROFILEW
:
2064 case EMR_ALPHABLEND
:
2065 case EMR_TRANSPARENTBLT
:
2066 case EMR_GRADIENTFILL
:
2067 case EMR_SETLINKEDUFI
:
2068 case EMR_COLORMATCHTOTARGETW
:
2069 case EMR_CREATECOLORSPACEW
:
2072 /* From docs: If PlayEnhMetaFileRecord doesn't recognize a
2073 record then ignore and return TRUE. */
2074 FIXME("type %d is unimplemented\n", type
);
2077 tmprc
.left
= tmprc
.top
= 0;
2078 tmprc
.right
= tmprc
.bottom
= 1000;
2079 LPtoDP(hdc
, (POINT
*)&tmprc
, 2);
2080 TRACE("L:0,0 - 1000,1000 -> D:%ld,%ld - %ld,%ld\n", tmprc
.left
,
2081 tmprc
.top
, tmprc
.right
, tmprc
.bottom
);
2085 /* WinNT - update the transform (win9x updates when the next graphics output
2086 record is played). */
2087 EMF_Update_MF_Xform(hdc
, info
);
2094 /*****************************************************************************
2096 * EnumEnhMetaFile (GDI32.@)
2098 * Walk an enhanced metafile, calling a user-specified function _EnhMetaFunc_
2100 * record. Returns when either every record has been used or
2101 * when _EnhMetaFunc_ returns FALSE.
2105 * TRUE if every record is used, FALSE if any invocation of _EnhMetaFunc_
2112 * This function behaves differently in Win9x and WinNT.
2114 * In WinNT, the DC's world transform is updated as the EMF changes
2115 * the Window/Viewport Extent and Origin or it's world transform.
2116 * The actual Window/Viewport Extent and Origin are left untouched.
2118 * In Win9x, the DC is left untouched, and PlayEnhMetaFileRecord
2119 * updates the scaling itself but only just before a record that
2120 * writes anything to the DC.
2122 * I'm not sure where the data (enum_emh_data) is stored in either
2123 * version. For this implementation, it is stored before the handle
2124 * table, but it could be stored in the DC, in the EMF handle or in
2128 BOOL WINAPI
EnumEnhMetaFile(
2129 HDC hdc
, /* [in] device context to pass to _EnhMetaFunc_ */
2130 HENHMETAFILE hmf
, /* [in] EMF to walk */
2131 ENHMFENUMPROC callback
, /* [in] callback function */
2132 LPVOID data
, /* [in] optional data for callback function */
2133 const RECT
*lpRect
/* [in] bounding rectangle for rendered metafile */
2145 HBRUSH hBrush
= NULL
;
2147 enum_emh_data
*info
;
2148 SIZE vp_size
, win_size
;
2149 POINT vp_org
, win_org
;
2150 INT mapMode
= MM_TEXT
;
2151 COLORREF old_text_color
= 0, old_bk_color
= 0;
2155 SetLastError(ERROR_INVALID_PARAMETER
);
2159 emh
= EMF_GetEnhMetaHeader(hmf
);
2161 SetLastError(ERROR_INVALID_HANDLE
);
2165 info
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
2166 sizeof (enum_emh_data
) + sizeof(HANDLETABLE
) * emh
->nHandles
);
2169 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
2176 info
->vportOrgX
= 0;
2177 info
->vportOrgY
= 0;
2178 info
->vportExtX
= 1;
2179 info
->vportExtY
= 1;
2180 info
->world_transform
.eM11
= info
->world_transform
.eM22
= 1;
2181 info
->world_transform
.eM12
= info
->world_transform
.eM21
= 0;
2182 info
->world_transform
.eDx
= info
->world_transform
.eDy
= 0;
2184 ht
= (HANDLETABLE
*) &info
[1];
2185 ht
->objectHandle
[0] = hmf
;
2189 savedMode
= SetGraphicsMode(hdc
, GM_ADVANCED
);
2190 GetWorldTransform(hdc
, &savedXform
);
2191 GetViewportExtEx(hdc
, &vp_size
);
2192 GetWindowExtEx(hdc
, &win_size
);
2193 GetViewportOrgEx(hdc
, &vp_org
);
2194 GetWindowOrgEx(hdc
, &win_org
);
2195 mapMode
= GetMapMode(hdc
);
2197 /* save the current pen, brush and font */
2198 hPen
= GetCurrentObject(hdc
, OBJ_PEN
);
2199 hBrush
= GetCurrentObject(hdc
, OBJ_BRUSH
);
2200 hFont
= GetCurrentObject(hdc
, OBJ_FONT
);
2202 old_text_color
= SetTextColor(hdc
, RGB(0,0,0));
2203 old_bk_color
= SetBkColor(hdc
, RGB(0xff, 0xff, 0xff));
2206 info
->mode
= MM_TEXT
;
2210 /* Win95 leaves the vp/win ext/org info alone */
2211 info
->init_transform
.eM11
= 1.0;
2212 info
->init_transform
.eM12
= 0.0;
2213 info
->init_transform
.eM21
= 0.0;
2214 info
->init_transform
.eM22
= 1.0;
2215 info
->init_transform
.eDx
= 0.0;
2216 info
->init_transform
.eDy
= 0.0;
2220 /* WinNT combines the vp/win ext/org info into a transform */
2221 FLOAT xscale
, yscale
;
2222 xscale
= (FLOAT
)vp_size
.cx
/ (FLOAT
)win_size
.cx
;
2223 yscale
= (FLOAT
)vp_size
.cy
/ (FLOAT
)win_size
.cy
;
2224 info
->init_transform
.eM11
= xscale
;
2225 info
->init_transform
.eM12
= 0.0;
2226 info
->init_transform
.eM21
= 0.0;
2227 info
->init_transform
.eM22
= yscale
;
2228 info
->init_transform
.eDx
= (FLOAT
)vp_org
.x
- xscale
* (FLOAT
)win_org
.x
;
2229 info
->init_transform
.eDy
= (FLOAT
)vp_org
.y
- yscale
* (FLOAT
)win_org
.y
;
2231 CombineTransform(&info
->init_transform
, &savedXform
, &info
->init_transform
);
2234 if ( lpRect
&& WIDTH(emh
->rclFrame
) && HEIGHT(emh
->rclFrame
) )
2236 FLOAT xSrcPixSize
, ySrcPixSize
, xscale
, yscale
;
2239 TRACE("rect: %ld,%ld - %ld,%ld. rclFrame: %ld,%ld - %ld,%ld\n",
2240 lpRect
->left
, lpRect
->top
, lpRect
->right
, lpRect
->bottom
,
2241 emh
->rclFrame
.left
, emh
->rclFrame
.top
, emh
->rclFrame
.right
,
2242 emh
->rclFrame
.bottom
);
2244 xSrcPixSize
= (FLOAT
) emh
->szlMillimeters
.cx
/ emh
->szlDevice
.cx
;
2245 ySrcPixSize
= (FLOAT
) emh
->szlMillimeters
.cy
/ emh
->szlDevice
.cy
;
2246 xscale
= (FLOAT
) WIDTH(*lpRect
) * 100.0 /
2247 WIDTH(emh
->rclFrame
) * xSrcPixSize
;
2248 yscale
= (FLOAT
) HEIGHT(*lpRect
) * 100.0 /
2249 HEIGHT(emh
->rclFrame
) * ySrcPixSize
;
2250 TRACE("xscale = %f, yscale = %f\n", xscale
, yscale
);
2252 xform
.eM11
= xscale
;
2255 xform
.eM22
= yscale
;
2256 xform
.eDx
= (FLOAT
) lpRect
->left
- (FLOAT
) WIDTH(*lpRect
) / WIDTH(emh
->rclFrame
) * emh
->rclFrame
.left
;
2257 xform
.eDy
= (FLOAT
) lpRect
->top
- (FLOAT
) HEIGHT(*lpRect
) / HEIGHT(emh
->rclFrame
) * emh
->rclFrame
.top
;
2259 CombineTransform(&info
->init_transform
, &xform
, &info
->init_transform
);
2262 /* WinNT resets the current vp/win org/ext */
2263 if ( !IS_WIN9X() && hdc
)
2265 SetMapMode(hdc
, MM_TEXT
);
2266 SetWindowOrgEx(hdc
, 0, 0, NULL
);
2267 SetViewportOrgEx(hdc
, 0, 0, NULL
);
2268 EMF_Update_MF_Xform(hdc
, info
);
2273 while(ret
&& offset
< emh
->nBytes
)
2275 emr
= (ENHMETARECORD
*)((char *)emh
+ offset
);
2276 TRACE("Calling EnumFunc with record %s, size %ld\n", get_emr_name(emr
->iType
), emr
->nSize
);
2277 ret
= (*callback
)(hdc
, ht
, emr
, emh
->nHandles
, (LPARAM
)data
);
2278 offset
+= emr
->nSize
;
2283 SetBkColor(hdc
, old_bk_color
);
2284 SetTextColor(hdc
, old_text_color
);
2286 /* restore pen, brush and font */
2287 SelectObject(hdc
, hBrush
);
2288 SelectObject(hdc
, hPen
);
2289 SelectObject(hdc
, hFont
);
2291 SetWorldTransform(hdc
, &savedXform
);
2293 SetGraphicsMode(hdc
, savedMode
);
2294 SetMapMode(hdc
, mapMode
);
2295 SetWindowOrgEx(hdc
, win_org
.x
, win_org
.y
, NULL
);
2296 SetWindowExtEx(hdc
, win_size
.cx
, win_size
.cy
, NULL
);
2297 SetViewportOrgEx(hdc
, vp_org
.x
, vp_org
.y
, NULL
);
2298 SetViewportExtEx(hdc
, vp_size
.cx
, vp_size
.cy
, NULL
);
2301 for(i
= 1; i
< emh
->nHandles
; i
++) /* Don't delete element 0 (hmf) */
2302 if( (ht
->objectHandle
)[i
] )
2303 DeleteObject( (ht
->objectHandle
)[i
] );
2305 HeapFree( GetProcessHeap(), 0, info
);
2309 static INT CALLBACK
EMF_PlayEnhMetaFileCallback(HDC hdc
, HANDLETABLE
*ht
,
2310 const ENHMETARECORD
*emr
,
2311 INT handles
, LPARAM data
)
2313 return PlayEnhMetaFileRecord(hdc
, ht
, emr
, handles
);
2316 /**************************************************************************
2317 * PlayEnhMetaFile (GDI32.@)
2319 * Renders an enhanced metafile into a specified rectangle *lpRect
2320 * in device context hdc.
2323 BOOL WINAPI
PlayEnhMetaFile(
2324 HDC hdc
, /* [in] DC to render into */
2325 HENHMETAFILE hmf
, /* [in] metafile to render */
2326 const RECT
*lpRect
/* [in] rectangle to place metafile inside */
2329 return EnumEnhMetaFile(hdc
, hmf
, EMF_PlayEnhMetaFileCallback
, NULL
,
2333 /*****************************************************************************
2334 * DeleteEnhMetaFile (GDI32.@)
2336 * Deletes an enhanced metafile and frees the associated storage.
2338 BOOL WINAPI
DeleteEnhMetaFile(HENHMETAFILE hmf
)
2340 return EMF_Delete_HENHMETAFILE( hmf
);
2343 /*****************************************************************************
2344 * CopyEnhMetaFileA (GDI32.@)
2346 * Duplicate an enhanced metafile.
2350 HENHMETAFILE WINAPI
CopyEnhMetaFileA(
2351 HENHMETAFILE hmfSrc
,
2354 ENHMETAHEADER
*emrSrc
= EMF_GetEnhMetaHeader( hmfSrc
), *emrDst
;
2355 HENHMETAFILE hmfDst
;
2357 if(!emrSrc
) return FALSE
;
2359 emrDst
= HeapAlloc( GetProcessHeap(), 0, emrSrc
->nBytes
);
2360 memcpy( emrDst
, emrSrc
, emrSrc
->nBytes
);
2361 hmfDst
= EMF_Create_HENHMETAFILE( emrDst
, FALSE
);
2365 hFile
= CreateFileA( file
, GENERIC_WRITE
| GENERIC_READ
, 0,
2366 NULL
, CREATE_ALWAYS
, 0, 0);
2367 WriteFile( hFile
, emrSrc
, emrSrc
->nBytes
, &w
, NULL
);
2368 CloseHandle( hFile
);
2369 /* Reopen file for reading only, so that apps can share
2370 read access to the file while hmf is still valid */
2371 hFile
= CreateFileA( file
, GENERIC_READ
, FILE_SHARE_READ
,
2372 NULL
, OPEN_EXISTING
, 0, 0);
2373 if(hFile
== INVALID_HANDLE_VALUE
) {
2374 ERR("Can't reopen emf for reading\n");
2377 hmfDst
= EMF_GetEnhMetaFile( hFile
);
2378 CloseHandle( hFile
);
2383 /*****************************************************************************
2384 * CopyEnhMetaFileW (GDI32.@)
2386 * See CopyEnhMetaFileA.
2390 HENHMETAFILE WINAPI
CopyEnhMetaFileW(
2391 HENHMETAFILE hmfSrc
,
2394 ENHMETAHEADER
*emrSrc
= EMF_GetEnhMetaHeader( hmfSrc
), *emrDst
;
2395 HENHMETAFILE hmfDst
;
2397 if(!emrSrc
) return FALSE
;
2399 emrDst
= HeapAlloc( GetProcessHeap(), 0, emrSrc
->nBytes
);
2400 memcpy( emrDst
, emrSrc
, emrSrc
->nBytes
);
2401 hmfDst
= EMF_Create_HENHMETAFILE( emrDst
, FALSE
);
2405 hFile
= CreateFileW( file
, GENERIC_WRITE
| GENERIC_READ
, 0,
2406 NULL
, CREATE_ALWAYS
, 0, 0);
2407 WriteFile( hFile
, emrSrc
, emrSrc
->nBytes
, &w
, NULL
);
2408 CloseHandle( hFile
);
2409 /* Reopen file for reading only, so that apps can share
2410 read access to the file while hmf is still valid */
2411 hFile
= CreateFileW( file
, GENERIC_READ
, FILE_SHARE_READ
,
2412 NULL
, OPEN_EXISTING
, 0, 0);
2413 if(hFile
== INVALID_HANDLE_VALUE
) {
2414 ERR("Can't reopen emf for reading\n");
2417 hmfDst
= EMF_GetEnhMetaFile( hFile
);
2418 CloseHandle( hFile
);
2424 /* Struct to be used to be passed in the LPVOID parameter for cbEnhPaletteCopy */
2425 typedef struct tagEMF_PaletteCopy
2428 LPPALETTEENTRY lpPe
;
2431 /***************************************************************
2432 * Find the EMR_EOF record and then use it to find the
2433 * palette entries for this enhanced metafile.
2434 * The lpData is actually a pointer to an EMF_PaletteCopy struct
2435 * which contains the max number of elements to copy and where
2438 * NOTE: To be used by GetEnhMetaFilePaletteEntries only!
2440 static INT CALLBACK
cbEnhPaletteCopy( HDC a
,
2442 const ENHMETARECORD
*lpEMR
,
2447 if ( lpEMR
->iType
== EMR_EOF
)
2449 PEMREOF lpEof
= (PEMREOF
)lpEMR
;
2450 EMF_PaletteCopy
* info
= (EMF_PaletteCopy
*)lpData
;
2451 DWORD dwNumPalToCopy
= min( lpEof
->nPalEntries
, info
->cEntries
);
2453 TRACE( "copying 0x%08lx palettes\n", dwNumPalToCopy
);
2455 memcpy( (LPVOID
)info
->lpPe
,
2456 (LPVOID
)(((LPSTR
)lpEof
) + lpEof
->offPalEntries
),
2457 sizeof( *(info
->lpPe
) ) * dwNumPalToCopy
);
2459 /* Update the passed data as a return code */
2460 info
->lpPe
= NULL
; /* Palettes were copied! */
2461 info
->cEntries
= (UINT
)dwNumPalToCopy
;
2463 return FALSE
; /* That's all we need */
2469 /*****************************************************************************
2470 * GetEnhMetaFilePaletteEntries (GDI32.@)
2472 * Copy the palette and report size
2474 * BUGS: Error codes (SetLastError) are not set on failures
2476 UINT WINAPI
GetEnhMetaFilePaletteEntries( HENHMETAFILE hEmf
,
2478 LPPALETTEENTRY lpPe
)
2480 ENHMETAHEADER
* enhHeader
= EMF_GetEnhMetaHeader( hEmf
);
2481 EMF_PaletteCopy infoForCallBack
;
2483 TRACE( "(%p,%d,%p)\n", hEmf
, cEntries
, lpPe
);
2485 /* First check if there are any palettes associated with
2487 if ( enhHeader
->nPalEntries
== 0 ) return 0;
2489 /* Is the user requesting the number of palettes? */
2490 if ( lpPe
== NULL
) return (UINT
)enhHeader
->nPalEntries
;
2492 /* Copy cEntries worth of PALETTEENTRY structs into the buffer */
2493 infoForCallBack
.cEntries
= cEntries
;
2494 infoForCallBack
.lpPe
= lpPe
;
2496 if ( !EnumEnhMetaFile( 0, hEmf
, cbEnhPaletteCopy
,
2497 &infoForCallBack
, 0 ) )
2500 /* Verify that the callback executed correctly */
2501 if ( infoForCallBack
.lpPe
!= NULL
)
2503 /* Callback proc had error! */
2504 ERR( "cbEnhPaletteCopy didn't execute correctly\n" );
2508 return infoForCallBack
.cEntries
;
2511 typedef struct gdi_mf_comment
2518 DWORD cbWinMetaFile
;
2521 /******************************************************************
2522 * SetWinMetaFileBits (GDI32.@)
2524 * Translate from old style to new style.
2527 HENHMETAFILE WINAPI
SetWinMetaFileBits(UINT cbBuffer
,
2528 CONST BYTE
*lpbBuffer
,
2530 CONST METAFILEPICT
*lpmfp
2533 static const WCHAR szDisplayW
[] = { 'D','I','S','P','L','A','Y','\0' };
2534 HMETAFILE hmf
= NULL
;
2535 HENHMETAFILE ret
= NULL
;
2536 HDC hdc
= NULL
, hdcdisp
= NULL
;
2537 RECT rc
, *prcFrame
= NULL
;
2538 gdi_mf_comment
*mfcomment
;
2539 UINT mfcomment_size
;
2541 TRACE("(%d, %p, %p, %p)\n", cbBuffer
, lpbBuffer
, hdcRef
, lpmfp
);
2543 hmf
= SetMetaFileBitsEx(cbBuffer
, lpbBuffer
);
2546 WARN("SetMetaFileBitsEx failed\n");
2551 hdcRef
= hdcdisp
= CreateDCW(szDisplayW
, NULL
, NULL
, NULL
);
2554 TRACE("mm = %ld %ldx%ld\n", lpmfp
->mm
, lpmfp
->xExt
, lpmfp
->yExt
);
2556 if (lpmfp
&& (lpmfp
->mm
== MM_ISOTROPIC
|| lpmfp
->mm
== MM_ANISOTROPIC
))
2558 rc
.left
= rc
.top
= 0;
2559 rc
.right
= lpmfp
->xExt
;
2560 rc
.bottom
= lpmfp
->yExt
;
2564 if(!(hdc
= CreateEnhMetaFileW(hdcRef
, NULL
, prcFrame
, NULL
)))
2566 ERR("CreateEnhMetaFile fails?\n");
2571 * Write the original METAFILE into the enhanced metafile.
2572 * It is encapsulated in a GDICOMMENT_WINDOWS_METAFILE record.
2574 mfcomment_size
= sizeof (gdi_mf_comment
) + cbBuffer
;
2575 mfcomment
= HeapAlloc(GetProcessHeap(), 0, mfcomment_size
);
2578 mfcomment
->ident
= GDICOMMENT_IDENTIFIER
;
2579 mfcomment
->iComment
= GDICOMMENT_WINDOWS_METAFILE
;
2580 mfcomment
->nVersion
= 0x00000300;
2581 mfcomment
->nChecksum
= 0; /* FIXME */
2582 mfcomment
->fFlags
= 0;
2583 mfcomment
->cbWinMetaFile
= cbBuffer
;
2584 memcpy(&mfcomment
[1], lpbBuffer
, cbBuffer
);
2585 GdiComment(hdc
, mfcomment_size
, (BYTE
*) mfcomment
);
2586 HeapFree(GetProcessHeap(), 0, mfcomment
);
2589 if(lpmfp
&& lpmfp
->mm
!= MM_TEXT
)
2590 SetMapMode(hdc
, lpmfp
->mm
);
2592 if (lpmfp
&& (lpmfp
->mm
== MM_ISOTROPIC
|| lpmfp
->mm
== MM_ANISOTROPIC
))
2594 INT horzres
, vertres
, horzsize
, vertsize
, xext
, yext
;
2596 horzres
= GetDeviceCaps(hdcRef
, HORZRES
);
2597 vertres
= GetDeviceCaps(hdcRef
, VERTRES
);
2598 horzsize
= GetDeviceCaps(hdcRef
, HORZSIZE
);
2599 vertsize
= GetDeviceCaps(hdcRef
, VERTSIZE
);
2601 /* set the initial viewport:window ratio as 1:1 */
2602 xext
= lpmfp
->xExt
*horzres
/(100*horzsize
);
2603 yext
= lpmfp
->yExt
*vertres
/(100*vertsize
);
2604 SetViewportExtEx(hdc
, xext
, yext
, NULL
);
2605 SetWindowExtEx(hdc
, xext
, yext
, NULL
);
2608 PlayMetaFile(hdc
, hmf
);
2610 ret
= CloseEnhMetaFile(hdc
);
2612 if (hdcdisp
) DeleteDC(hdcdisp
);
2613 DeleteMetaFile(hmf
);