2 * Enhanced metafile functions
3 * Copyright 1998 Douglas Ridgway
7 * The enhanced format consists of the following elements:
10 * A table of handles to GDI objects
11 * An array of metafile records
15 * The standard format consists of a header and an array of metafile records.
25 #include "enhmetafile.h"
26 #include "debugtools.h"
30 DEFAULT_DEBUG_CHANNEL(enhmetafile
);
32 /****************************************************************************
33 * EMF_Create_HENHMETAFILE
35 HENHMETAFILE
EMF_Create_HENHMETAFILE(ENHMETAHEADER
*emh
, HFILE hFile
, HANDLE
39 ENHMETAFILEOBJ
*metaObj
= GDI_AllocObject( sizeof(ENHMETAFILEOBJ
),
40 ENHMETAFILE_MAGIC
, &hmf
);
44 metaObj
->hFile
= hFile
;
45 metaObj
->hMapping
= hMapping
;
46 GDI_ReleaseObj( hmf
);
51 /****************************************************************************
52 * EMF_Delete_HENHMETAFILE
54 static BOOL
EMF_Delete_HENHMETAFILE( HENHMETAFILE hmf
)
56 ENHMETAFILEOBJ
*metaObj
= (ENHMETAFILEOBJ
*)GDI_GetObjPtr( hmf
,
58 if(!metaObj
) return FALSE
;
59 if(metaObj
->hMapping
) {
60 UnmapViewOfFile( metaObj
->emh
);
61 CloseHandle( metaObj
->hMapping
);
62 CloseHandle( metaObj
->hFile
);
64 HeapFree( GetProcessHeap(), 0, metaObj
->emh
);
65 return GDI_FreeObject( hmf
, metaObj
);
68 /******************************************************************
69 * EMF_GetEnhMetaHeader
71 * Returns ptr to ENHMETAHEADER associated with HENHMETAFILE
72 * Should be followed by call to EMF_ReleaseEnhMetaHeader
74 static ENHMETAHEADER
*EMF_GetEnhMetaHeader( HENHMETAFILE hmf
)
76 ENHMETAFILEOBJ
*metaObj
= (ENHMETAFILEOBJ
*)GDI_GetObjPtr( hmf
,
78 TRACE("hmf %04x -> enhmetaObj %p\n", hmf
, metaObj
);
79 return metaObj
? metaObj
->emh
: NULL
;
82 /******************************************************************
83 * EMF_ReleaseEnhMetaHeader
85 * Releases ENHMETAHEADER associated with HENHMETAFILE
87 static void EMF_ReleaseEnhMetaHeader( HENHMETAFILE hmf
)
89 GDI_ReleaseObj( hmf
);
92 /*****************************************************************************
96 static HENHMETAFILE
EMF_GetEnhMetaFile( HANDLE hFile
)
101 hMapping
= CreateFileMappingA( hFile
, NULL
, PAGE_READONLY
, 0, 0, NULL
);
102 emh
= MapViewOfFile( hMapping
, FILE_MAP_READ
, 0, 0, 0 );
104 if (emh
->iType
!= EMR_HEADER
|| emh
->dSignature
!= ENHMETA_SIGNATURE
) {
105 WARN("Invalid emf header type 0x%08lx sig 0x%08lx.\n",
106 emh
->iType
, emh
->dSignature
);
107 UnmapViewOfFile( emh
);
108 CloseHandle( hMapping
);
111 return EMF_Create_HENHMETAFILE( emh
, hFile
, hMapping
);
115 /*****************************************************************************
116 * GetEnhMetaFileA (GDI32.@)
120 HENHMETAFILE WINAPI
GetEnhMetaFileA(
121 LPCSTR lpszMetaFile
/* [in] filename of enhanced metafile */
127 hFile
= CreateFileA(lpszMetaFile
, GENERIC_READ
, FILE_SHARE_READ
, 0,
128 OPEN_EXISTING
, 0, 0);
129 if (hFile
== INVALID_HANDLE_VALUE
) {
130 WARN("could not open %s\n", lpszMetaFile
);
133 hmf
= EMF_GetEnhMetaFile( hFile
);
135 CloseHandle( hFile
);
139 /*****************************************************************************
140 * GetEnhMetaFileW (GDI32.@)
142 HENHMETAFILE WINAPI
GetEnhMetaFileW(
143 LPCWSTR lpszMetaFile
) /* [in] filename of enhanced metafile */
148 hFile
= CreateFileW(lpszMetaFile
, GENERIC_READ
, FILE_SHARE_READ
, 0,
149 OPEN_EXISTING
, 0, 0);
150 if (hFile
== INVALID_HANDLE_VALUE
) {
151 WARN("could not open %s\n", debugstr_w(lpszMetaFile
));
154 hmf
= EMF_GetEnhMetaFile( hFile
);
156 CloseHandle( hFile
);
160 /*****************************************************************************
161 * GetEnhMetaFileHeader (GDI32.@)
163 * If buf is NULL, returns the size of buffer required.
164 * Otherwise, copy up to bufsize bytes of enhanced metafile header into
167 UINT WINAPI
GetEnhMetaFileHeader(
168 HENHMETAFILE hmf
, /* [in] enhanced metafile */
169 UINT bufsize
, /* [in] size of buffer */
170 LPENHMETAHEADER buf
/* [out] buffer */
176 emh
= EMF_GetEnhMetaHeader(hmf
);
177 if(!emh
) return FALSE
;
180 EMF_ReleaseEnhMetaHeader(hmf
);
183 size
= min(size
, bufsize
);
184 memmove(buf
, emh
, size
);
185 EMF_ReleaseEnhMetaHeader(hmf
);
190 /*****************************************************************************
191 * GetEnhMetaFileDescriptionA (GDI32.@)
193 UINT WINAPI
GetEnhMetaFileDescriptionA(
194 HENHMETAFILE hmf
, /* [in] enhanced metafile */
195 UINT size
, /* [in] size of buf */
196 LPSTR buf
/* [out] buffer to receive description */
199 LPENHMETAHEADER emh
= EMF_GetEnhMetaHeader(hmf
);
203 if(!emh
) return FALSE
;
204 if(emh
->nDescription
== 0 || emh
->offDescription
== 0) {
205 EMF_ReleaseEnhMetaHeader(hmf
);
208 descrW
= (WCHAR
*) ((char *) emh
+ emh
->offDescription
);
209 len
= WideCharToMultiByte( CP_ACP
, 0, descrW
, emh
->nDescription
, NULL
, 0, NULL
, NULL
);
211 if (!buf
|| !size
) {
212 EMF_ReleaseEnhMetaHeader(hmf
);
216 len
= min( size
, len
);
217 WideCharToMultiByte( CP_ACP
, 0, descrW
, emh
->nDescription
, buf
, len
, NULL
, NULL
);
218 EMF_ReleaseEnhMetaHeader(hmf
);
222 /*****************************************************************************
223 * GetEnhMetaFileDescriptionW (GDI32.@)
225 * Copies the description string of an enhanced metafile into a buffer
228 * If _buf_ is NULL, returns size of _buf_ required. Otherwise, returns
229 * number of characters copied.
231 UINT WINAPI
GetEnhMetaFileDescriptionW(
232 HENHMETAFILE hmf
, /* [in] enhanced metafile */
233 UINT size
, /* [in] size of buf */
234 LPWSTR buf
/* [out] buffer to receive description */
237 LPENHMETAHEADER emh
= EMF_GetEnhMetaHeader(hmf
);
239 if(!emh
) return FALSE
;
240 if(emh
->nDescription
== 0 || emh
->offDescription
== 0) {
241 EMF_ReleaseEnhMetaHeader(hmf
);
244 if (!buf
|| !size
) {
245 EMF_ReleaseEnhMetaHeader(hmf
);
246 return emh
->nDescription
;
249 memmove(buf
, (char *) emh
+ emh
->offDescription
,
250 min(size
,emh
->nDescription
)*sizeof(WCHAR
));
251 EMF_ReleaseEnhMetaHeader(hmf
);
252 return min(size
, emh
->nDescription
);
255 /****************************************************************************
256 * SetEnhMetaFileBits (GDI32.@)
258 * Creates an enhanced metafile by copying _bufsize_ bytes from _buf_.
260 HENHMETAFILE WINAPI
SetEnhMetaFileBits(UINT bufsize
, const BYTE
*buf
)
262 ENHMETAHEADER
*emh
= HeapAlloc( GetProcessHeap(), 0, bufsize
);
263 memmove(emh
, buf
, bufsize
);
264 return EMF_Create_HENHMETAFILE( emh
, 0, 0 );
267 /*****************************************************************************
268 * GetEnhMetaFileBits (GDI32.@)
271 UINT WINAPI
GetEnhMetaFileBits(
277 LPENHMETAHEADER emh
= EMF_GetEnhMetaHeader( hmf
);
284 EMF_ReleaseEnhMetaHeader( hmf
);
288 size
= min( size
, bufsize
);
289 memmove(buf
, emh
, size
);
291 EMF_ReleaseEnhMetaHeader( hmf
);
295 /*****************************************************************************
296 * PlayEnhMetaFileRecord (GDI32.@)
298 * Render a single enhanced metafile record in the device context hdc.
301 * TRUE (non zero) on success, FALSE on error.
303 * Many unimplemented records.
304 * No error handling on record play failures (ie checking return codes)
306 BOOL WINAPI
PlayEnhMetaFileRecord(
307 HDC hdc
, /* [in] device context in which to render EMF record */
308 LPHANDLETABLE handletable
, /* [in] array of handles to be used in rendering record */
309 const ENHMETARECORD
*mr
, /* [in] EMF record to render */
310 UINT handles
/* [in] size of handle array */
315 "hdc = %08x, handletable = %p, record = %p, numHandles = %d\n",
316 hdc
, handletable
, mr
, handles
);
317 if (!mr
) return FALSE
;
321 TRACE(" type=%d\n", type
);
330 PEMRGDICOMMENT lpGdiComment
= (PEMRGDICOMMENT
)mr
;
331 /* In an enhanced metafile, there can be both public and private GDI comments */
332 GdiComment( hdc
, lpGdiComment
->cbData
, lpGdiComment
->Data
);
337 PEMRSETMAPMODE pSetMapMode
= (PEMRSETMAPMODE
) mr
;
338 SetMapMode(hdc
, pSetMapMode
->iMode
);
343 PEMRSETBKMODE pSetBkMode
= (PEMRSETBKMODE
) mr
;
344 SetBkMode(hdc
, pSetBkMode
->iMode
);
349 PEMRSETBKCOLOR pSetBkColor
= (PEMRSETBKCOLOR
) mr
;
350 SetBkColor(hdc
, pSetBkColor
->crColor
);
353 case EMR_SETPOLYFILLMODE
:
355 PEMRSETPOLYFILLMODE pSetPolyFillMode
= (PEMRSETPOLYFILLMODE
) mr
;
356 SetPolyFillMode(hdc
, pSetPolyFillMode
->iMode
);
361 PEMRSETROP2 pSetROP2
= (PEMRSETROP2
) mr
;
362 SetROP2(hdc
, pSetROP2
->iMode
);
365 case EMR_SETSTRETCHBLTMODE
:
367 PEMRSETSTRETCHBLTMODE pSetStretchBltMode
= (PEMRSETSTRETCHBLTMODE
) mr
;
368 SetStretchBltMode(hdc
, pSetStretchBltMode
->iMode
);
371 case EMR_SETTEXTALIGN
:
373 PEMRSETTEXTALIGN pSetTextAlign
= (PEMRSETTEXTALIGN
) mr
;
374 SetTextAlign(hdc
, pSetTextAlign
->iMode
);
377 case EMR_SETTEXTCOLOR
:
379 PEMRSETTEXTCOLOR pSetTextColor
= (PEMRSETTEXTCOLOR
) mr
;
380 SetTextColor(hdc
, pSetTextColor
->crColor
);
390 PEMRRESTOREDC pRestoreDC
= (PEMRRESTOREDC
) mr
;
391 RestoreDC(hdc
, pRestoreDC
->iRelative
);
394 case EMR_INTERSECTCLIPRECT
:
396 PEMRINTERSECTCLIPRECT pClipRect
= (PEMRINTERSECTCLIPRECT
) mr
;
397 IntersectClipRect(hdc
, pClipRect
->rclClip
.left
, pClipRect
->rclClip
.top
,
398 pClipRect
->rclClip
.right
, pClipRect
->rclClip
.bottom
);
401 case EMR_SELECTOBJECT
:
403 PEMRSELECTOBJECT pSelectObject
= (PEMRSELECTOBJECT
) mr
;
404 if( pSelectObject
->ihObject
& 0x80000000 ) {
405 /* High order bit is set - it's a stock object
406 * Strip the high bit to get the index.
407 * See MSDN article Q142319
409 SelectObject( hdc
, GetStockObject( pSelectObject
->ihObject
&
412 /* High order bit wasn't set - not a stock object
415 (handletable
->objectHandle
)[pSelectObject
->ihObject
] );
419 case EMR_DELETEOBJECT
:
421 PEMRDELETEOBJECT pDeleteObject
= (PEMRDELETEOBJECT
) mr
;
422 DeleteObject( (handletable
->objectHandle
)[pDeleteObject
->ihObject
]);
423 (handletable
->objectHandle
)[pDeleteObject
->ihObject
] = 0;
426 case EMR_SETWINDOWORGEX
:
429 * FIXME: The call to SetWindowOrgEx prevents EMFs from being scrolled
430 * by an application. This is very BAD!!!
433 PEMRSETWINDOWORGEX pSetWindowOrgEx
= (PEMRSETWINDOWORGEX
) mr
;
434 SetWindowOrgEx(hdc
, pSetWindowOrgEx
->ptlOrigin
.x
,
435 pSetWindowOrgEx
->ptlOrigin
.y
, NULL
);
439 case EMR_SETWINDOWEXTEX
:
441 PEMRSETWINDOWEXTEX pSetWindowExtEx
= (PEMRSETWINDOWEXTEX
) mr
;
442 SetWindowExtEx(hdc
, pSetWindowExtEx
->szlExtent
.cx
,
443 pSetWindowExtEx
->szlExtent
.cy
, NULL
);
446 case EMR_SETVIEWPORTORGEX
:
448 PEMRSETVIEWPORTORGEX pSetViewportOrgEx
= (PEMRSETVIEWPORTORGEX
) mr
;
449 SetViewportOrgEx(hdc
, pSetViewportOrgEx
->ptlOrigin
.x
,
450 pSetViewportOrgEx
->ptlOrigin
.y
, NULL
);
453 case EMR_SETVIEWPORTEXTEX
:
455 PEMRSETVIEWPORTEXTEX pSetViewportExtEx
= (PEMRSETVIEWPORTEXTEX
) mr
;
456 SetViewportExtEx(hdc
, pSetViewportExtEx
->szlExtent
.cx
,
457 pSetViewportExtEx
->szlExtent
.cy
, NULL
);
462 PEMRCREATEPEN pCreatePen
= (PEMRCREATEPEN
) mr
;
463 (handletable
->objectHandle
)[pCreatePen
->ihPen
] =
464 CreatePenIndirect(&pCreatePen
->lopn
);
467 case EMR_EXTCREATEPEN
:
469 PEMREXTCREATEPEN pPen
= (PEMREXTCREATEPEN
) mr
;
471 lb
.lbStyle
= pPen
->elp
.elpBrushStyle
;
472 lb
.lbColor
= pPen
->elp
.elpColor
;
473 lb
.lbHatch
= pPen
->elp
.elpHatch
;
475 if(pPen
->offBmi
|| pPen
->offBits
)
476 FIXME("EMR_EXTCREATEPEN: Need to copy brush bitmap\n");
478 (handletable
->objectHandle
)[pPen
->ihPen
] =
479 ExtCreatePen(pPen
->elp
.elpPenStyle
, pPen
->elp
.elpWidth
, &lb
,
480 pPen
->elp
.elpNumEntries
, pPen
->elp
.elpStyleEntry
);
483 case EMR_CREATEBRUSHINDIRECT
:
485 PEMRCREATEBRUSHINDIRECT pBrush
= (PEMRCREATEBRUSHINDIRECT
) mr
;
486 (handletable
->objectHandle
)[pBrush
->ihBrush
] =
487 CreateBrushIndirect(&pBrush
->lb
);
490 case EMR_EXTCREATEFONTINDIRECTW
:
492 PEMREXTCREATEFONTINDIRECTW pFont
= (PEMREXTCREATEFONTINDIRECTW
) mr
;
493 (handletable
->objectHandle
)[pFont
->ihFont
] =
494 CreateFontIndirectW(&pFont
->elfw
.elfLogFont
);
499 PEMRMOVETOEX pMoveToEx
= (PEMRMOVETOEX
) mr
;
500 MoveToEx(hdc
, pMoveToEx
->ptl
.x
, pMoveToEx
->ptl
.y
, NULL
);
505 PEMRLINETO pLineTo
= (PEMRLINETO
) mr
;
506 LineTo(hdc
, pLineTo
->ptl
.x
, pLineTo
->ptl
.y
);
511 PEMRRECTANGLE pRect
= (PEMRRECTANGLE
) mr
;
512 Rectangle(hdc
, pRect
->rclBox
.left
, pRect
->rclBox
.top
,
513 pRect
->rclBox
.right
, pRect
->rclBox
.bottom
);
518 PEMRELLIPSE pEllipse
= (PEMRELLIPSE
) mr
;
519 Ellipse(hdc
, pEllipse
->rclBox
.left
, pEllipse
->rclBox
.top
,
520 pEllipse
->rclBox
.right
, pEllipse
->rclBox
.bottom
);
525 PEMRPOLYGON16 pPoly
= (PEMRPOLYGON16
) mr
;
526 /* Shouldn't use Polygon16 since pPoly->cpts is DWORD */
527 POINT
*pts
= HeapAlloc( GetProcessHeap(), 0,
528 pPoly
->cpts
* sizeof(POINT
) );
530 for(i
= 0; i
< pPoly
->cpts
; i
++)
531 CONV_POINT16TO32(pPoly
->apts
+ i
, pts
+ i
);
532 Polygon(hdc
, pts
, pPoly
->cpts
);
533 HeapFree( GetProcessHeap(), 0, pts
);
538 PEMRPOLYLINE16 pPoly
= (PEMRPOLYLINE16
) mr
;
539 /* Shouldn't use Polyline16 since pPoly->cpts is DWORD */
540 POINT
*pts
= HeapAlloc( GetProcessHeap(), 0,
541 pPoly
->cpts
* sizeof(POINT
) );
543 for(i
= 0; i
< pPoly
->cpts
; i
++)
544 CONV_POINT16TO32(pPoly
->apts
+ i
, pts
+ i
);
545 Polyline(hdc
, pts
, pPoly
->cpts
);
546 HeapFree( GetProcessHeap(), 0, pts
);
549 case EMR_POLYLINETO16
:
551 PEMRPOLYLINETO16 pPoly
= (PEMRPOLYLINETO16
) mr
;
552 /* Shouldn't use PolylineTo16 since pPoly->cpts is DWORD */
553 POINT
*pts
= HeapAlloc( GetProcessHeap(), 0,
554 pPoly
->cpts
* sizeof(POINT
) );
556 for(i
= 0; i
< pPoly
->cpts
; i
++)
557 CONV_POINT16TO32(pPoly
->apts
+ i
, pts
+ i
);
558 PolylineTo(hdc
, pts
, pPoly
->cpts
);
559 HeapFree( GetProcessHeap(), 0, pts
);
562 case EMR_POLYBEZIER16
:
564 PEMRPOLYBEZIER16 pPoly
= (PEMRPOLYBEZIER16
) mr
;
565 /* Shouldn't use PolyBezier16 since pPoly->cpts is DWORD */
566 POINT
*pts
= HeapAlloc( GetProcessHeap(), 0,
567 pPoly
->cpts
* sizeof(POINT
) );
569 for(i
= 0; i
< pPoly
->cpts
; i
++)
570 CONV_POINT16TO32(pPoly
->apts
+ i
, pts
+ i
);
571 PolyBezier(hdc
, pts
, pPoly
->cpts
);
572 HeapFree( GetProcessHeap(), 0, pts
);
575 case EMR_POLYBEZIERTO16
:
577 PEMRPOLYBEZIERTO16 pPoly
= (PEMRPOLYBEZIERTO16
) mr
;
578 /* Shouldn't use PolyBezierTo16 since pPoly->cpts is DWORD */
579 POINT
*pts
= HeapAlloc( GetProcessHeap(), 0,
580 pPoly
->cpts
* sizeof(POINT
) );
582 for(i
= 0; i
< pPoly
->cpts
; i
++)
583 CONV_POINT16TO32(pPoly
->apts
+ i
, pts
+ i
);
584 PolyBezierTo(hdc
, pts
, pPoly
->cpts
);
585 HeapFree( GetProcessHeap(), 0, pts
);
588 case EMR_POLYPOLYGON16
:
590 PEMRPOLYPOLYGON16 pPolyPoly
= (PEMRPOLYPOLYGON16
) mr
;
591 /* NB POINTS array doesn't start at pPolyPoly->apts it's actually
592 pPolyPoly->aPolyCounts + pPolyPoly->nPolys */
594 POINT
*pts
= HeapAlloc( GetProcessHeap(), 0,
595 pPolyPoly
->cpts
* sizeof(POINT
) );
597 for(i
= 0; i
< pPolyPoly
->cpts
; i
++)
598 CONV_POINT16TO32((POINT16
*) (pPolyPoly
->aPolyCounts
+
599 pPolyPoly
->nPolys
) + i
, pts
+ i
);
601 PolyPolygon(hdc
, pts
, (INT
*)pPolyPoly
->aPolyCounts
, pPolyPoly
->nPolys
);
602 HeapFree( GetProcessHeap(), 0, pts
);
605 case EMR_POLYPOLYLINE16
:
607 PEMRPOLYPOLYLINE16 pPolyPoly
= (PEMRPOLYPOLYLINE16
) mr
;
608 /* NB POINTS array doesn't start at pPolyPoly->apts it's actually
609 pPolyPoly->aPolyCounts + pPolyPoly->nPolys */
611 POINT
*pts
= HeapAlloc( GetProcessHeap(), 0,
612 pPolyPoly
->cpts
* sizeof(POINT
) );
614 for(i
= 0; i
< pPolyPoly
->cpts
; i
++)
615 CONV_POINT16TO32((POINT16
*) (pPolyPoly
->aPolyCounts
+
616 pPolyPoly
->nPolys
) + i
, pts
+ i
);
618 PolyPolyline(hdc
, pts
, pPolyPoly
->aPolyCounts
, pPolyPoly
->nPolys
);
619 HeapFree( GetProcessHeap(), 0, pts
);
623 case EMR_STRETCHDIBITS
:
625 EMRSTRETCHDIBITS
*pStretchDIBits
= (EMRSTRETCHDIBITS
*)mr
;
628 pStretchDIBits
->xDest
,
629 pStretchDIBits
->yDest
,
630 pStretchDIBits
->cxDest
,
631 pStretchDIBits
->cyDest
,
632 pStretchDIBits
->xSrc
,
633 pStretchDIBits
->ySrc
,
634 pStretchDIBits
->cxSrc
,
635 pStretchDIBits
->cySrc
,
636 (BYTE
*)mr
+ pStretchDIBits
->offBitsSrc
,
637 (const BITMAPINFO
*)((BYTE
*)mr
+ pStretchDIBits
->offBmiSrc
),
638 pStretchDIBits
->iUsageSrc
,
639 pStretchDIBits
->dwRop
);
643 case EMR_EXTTEXTOUTA
:
645 PEMREXTTEXTOUTA pExtTextOutA
= (PEMREXTTEXTOUTA
)mr
;
648 rc
.left
= pExtTextOutA
->emrtext
.rcl
.left
;
649 rc
.top
= pExtTextOutA
->emrtext
.rcl
.top
;
650 rc
.right
= pExtTextOutA
->emrtext
.rcl
.right
;
651 rc
.bottom
= pExtTextOutA
->emrtext
.rcl
.bottom
;
652 ExtTextOutA(hdc
, pExtTextOutA
->emrtext
.ptlReference
.x
, pExtTextOutA
->emrtext
.ptlReference
.y
,
653 pExtTextOutA
->emrtext
.fOptions
, &rc
,
654 (LPSTR
)((BYTE
*)mr
+ pExtTextOutA
->emrtext
.offString
), pExtTextOutA
->emrtext
.nChars
,
655 (INT
*)((BYTE
*)mr
+ pExtTextOutA
->emrtext
.offDx
));
659 case EMR_EXTTEXTOUTW
:
661 PEMREXTTEXTOUTW pExtTextOutW
= (PEMREXTTEXTOUTW
)mr
;
664 rc
.left
= pExtTextOutW
->emrtext
.rcl
.left
;
665 rc
.top
= pExtTextOutW
->emrtext
.rcl
.top
;
666 rc
.right
= pExtTextOutW
->emrtext
.rcl
.right
;
667 rc
.bottom
= pExtTextOutW
->emrtext
.rcl
.bottom
;
668 ExtTextOutW(hdc
, pExtTextOutW
->emrtext
.ptlReference
.x
, pExtTextOutW
->emrtext
.ptlReference
.y
,
669 pExtTextOutW
->emrtext
.fOptions
, &rc
,
670 (LPWSTR
)((BYTE
*)mr
+ pExtTextOutW
->emrtext
.offString
), pExtTextOutW
->emrtext
.nChars
,
671 (INT
*)((BYTE
*)mr
+ pExtTextOutW
->emrtext
.offDx
));
675 case EMR_CREATEPALETTE
:
677 PEMRCREATEPALETTE lpCreatePal
= (PEMRCREATEPALETTE
)mr
;
679 (handletable
->objectHandle
)[ lpCreatePal
->ihPal
] =
680 CreatePalette( &lpCreatePal
->lgpl
);
685 case EMR_SELECTPALETTE
:
687 PEMRSELECTPALETTE lpSelectPal
= (PEMRSELECTPALETTE
)mr
;
689 if( lpSelectPal
->ihPal
& 0x80000000 ) {
690 SelectPalette( hdc
, GetStockObject(lpSelectPal
->ihPal
& 0x7fffffff), TRUE
);
692 (handletable
->objectHandle
)[ lpSelectPal
->ihPal
] =
693 SelectPalette( hdc
, (handletable
->objectHandle
)[lpSelectPal
->ihPal
], TRUE
);
698 case EMR_REALIZEPALETTE
:
700 RealizePalette( hdc
);
704 case EMR_EXTSELECTCLIPRGN
:
706 PEMREXTSELECTCLIPRGN lpRgn
= (PEMREXTSELECTCLIPRGN
)mr
;
708 if ((lpRgn
->cbRgnData
== 0) && (lpRgn
->iMode
== RGN_COPY
)) {
709 ExtSelectClipRgn( hdc
, 0, RGN_COPY
);
711 FIXME("EMR_EXTSELECTCLIPRGN cbRgnData %lu\n", lpRgn
->cbRgnData
);
713 /* Need to make a region out of the RGNDATA we have */
714 /* ExtCreateRegion(....); */
715 /* ExtSelectClipRgn( hdc, ..., (INT)(lpRgn->iMode) ); */
727 case EMR_SETWORLDTRANSFORM
:
729 PEMRSETWORLDTRANSFORM lpXfrm
= (PEMRSETWORLDTRANSFORM
)mr
;
730 SetWorldTransform( hdc
, &lpXfrm
->xform
);
736 PEMRPOLYBEZIER lpPolyBez
= (PEMRPOLYBEZIER
)mr
;
737 PolyBezier(hdc
, (const LPPOINT
)lpPolyBez
->aptl
, (UINT
)lpPolyBez
->cptl
);
743 PEMRPOLYGON lpPoly
= (PEMRPOLYGON
)mr
;
744 Polygon( hdc
, (const LPPOINT
)lpPoly
->aptl
, (UINT
)lpPoly
->cptl
);
750 PEMRPOLYLINE lpPolyLine
= (PEMRPOLYLINE
)mr
;
751 Polyline(hdc
, (const LPPOINT
)lpPolyLine
->aptl
, (UINT
)lpPolyLine
->cptl
);
755 case EMR_POLYBEZIERTO
:
757 PEMRPOLYBEZIERTO lpPolyBezierTo
= (PEMRPOLYBEZIERTO
)mr
;
758 PolyBezierTo( hdc
, (const LPPOINT
)lpPolyBezierTo
->aptl
,
759 (UINT
)lpPolyBezierTo
->cptl
);
765 PEMRPOLYLINETO lpPolyLineTo
= (PEMRPOLYLINETO
)mr
;
766 PolylineTo( hdc
, (const LPPOINT
)lpPolyLineTo
->aptl
,
767 (UINT
)lpPolyLineTo
->cptl
);
771 case EMR_POLYPOLYLINE
:
773 PEMRPOLYPOLYLINE pPolyPolyline
= (PEMRPOLYPOLYLINE
) mr
;
774 /* NB Points at pPolyPolyline->aPolyCounts + pPolyPolyline->nPolys */
776 PolyPolyline(hdc
, (LPPOINT
)(pPolyPolyline
->aPolyCounts
+
777 pPolyPolyline
->nPolys
),
778 pPolyPolyline
->aPolyCounts
,
779 pPolyPolyline
->nPolys
);
784 case EMR_POLYPOLYGON
:
786 PEMRPOLYPOLYGON pPolyPolygon
= (PEMRPOLYPOLYGON
) mr
;
788 /* NB Points at pPolyPolygon->aPolyCounts + pPolyPolygon->nPolys */
790 PolyPolygon(hdc
, (LPPOINT
)(pPolyPolygon
->aPolyCounts
+
791 pPolyPolygon
->nPolys
),
792 (INT
*)pPolyPolygon
->aPolyCounts
, pPolyPolygon
->nPolys
);
796 case EMR_SETBRUSHORGEX
:
798 PEMRSETBRUSHORGEX lpSetBrushOrgEx
= (PEMRSETBRUSHORGEX
)mr
;
801 (INT
)lpSetBrushOrgEx
->ptlOrigin
.x
,
802 (INT
)lpSetBrushOrgEx
->ptlOrigin
.y
,
810 PEMRSETPIXELV lpSetPixelV
= (PEMRSETPIXELV
)mr
;
813 (INT
)lpSetPixelV
->ptlPixel
.x
,
814 (INT
)lpSetPixelV
->ptlPixel
.y
,
815 lpSetPixelV
->crColor
);
820 case EMR_SETMAPPERFLAGS
:
822 PEMRSETMAPPERFLAGS lpSetMapperFlags
= (PEMRSETMAPPERFLAGS
)mr
;
824 SetMapperFlags( hdc
, lpSetMapperFlags
->dwFlags
);
829 case EMR_SETCOLORADJUSTMENT
:
831 PEMRSETCOLORADJUSTMENT lpSetColorAdjust
= (PEMRSETCOLORADJUSTMENT
)mr
;
833 SetColorAdjustment( hdc
, &lpSetColorAdjust
->ColorAdjustment
);
838 case EMR_OFFSETCLIPRGN
:
840 PEMROFFSETCLIPRGN lpOffsetClipRgn
= (PEMROFFSETCLIPRGN
)mr
;
843 (INT
)lpOffsetClipRgn
->ptlOffset
.x
,
844 (INT
)lpOffsetClipRgn
->ptlOffset
.y
);
849 case EMR_EXCLUDECLIPRECT
:
851 PEMREXCLUDECLIPRECT lpExcludeClipRect
= (PEMREXCLUDECLIPRECT
)mr
;
853 ExcludeClipRect( hdc
,
854 lpExcludeClipRect
->rclClip
.left
,
855 lpExcludeClipRect
->rclClip
.top
,
856 lpExcludeClipRect
->rclClip
.right
,
857 lpExcludeClipRect
->rclClip
.bottom
);
862 case EMR_SCALEVIEWPORTEXTEX
:
864 PEMRSCALEVIEWPORTEXTEX lpScaleViewportExtEx
= (PEMRSCALEVIEWPORTEXTEX
)mr
;
866 ScaleViewportExtEx( hdc
,
867 lpScaleViewportExtEx
->xNum
,
868 lpScaleViewportExtEx
->xDenom
,
869 lpScaleViewportExtEx
->yNum
,
870 lpScaleViewportExtEx
->yDenom
,
876 case EMR_SCALEWINDOWEXTEX
:
878 PEMRSCALEWINDOWEXTEX lpScaleWindowExtEx
= (PEMRSCALEWINDOWEXTEX
)mr
;
880 ScaleWindowExtEx( hdc
,
881 lpScaleWindowExtEx
->xNum
,
882 lpScaleWindowExtEx
->xDenom
,
883 lpScaleWindowExtEx
->yNum
,
884 lpScaleWindowExtEx
->yDenom
,
890 case EMR_MODIFYWORLDTRANSFORM
:
892 PEMRMODIFYWORLDTRANSFORM lpModifyWorldTrans
= (PEMRMODIFYWORLDTRANSFORM
)mr
;
894 ModifyWorldTransform( hdc
, &lpModifyWorldTrans
->xform
,
895 lpModifyWorldTrans
->iMode
);
902 PEMRANGLEARC lpAngleArc
= (PEMRANGLEARC
)mr
;
905 (INT
)lpAngleArc
->ptlCenter
.x
, (INT
)lpAngleArc
->ptlCenter
.y
,
906 lpAngleArc
->nRadius
, lpAngleArc
->eStartAngle
,
907 lpAngleArc
->eSweepAngle
);
914 PEMRROUNDRECT lpRoundRect
= (PEMRROUNDRECT
)mr
;
917 lpRoundRect
->rclBox
.left
,
918 lpRoundRect
->rclBox
.top
,
919 lpRoundRect
->rclBox
.right
,
920 lpRoundRect
->rclBox
.bottom
,
921 lpRoundRect
->szlCorner
.cx
,
922 lpRoundRect
->szlCorner
.cy
);
929 PEMRARC lpArc
= (PEMRARC
)mr
;
932 (INT
)lpArc
->rclBox
.left
,
933 (INT
)lpArc
->rclBox
.top
,
934 (INT
)lpArc
->rclBox
.right
,
935 (INT
)lpArc
->rclBox
.bottom
,
936 (INT
)lpArc
->ptlStart
.x
,
937 (INT
)lpArc
->ptlStart
.y
,
938 (INT
)lpArc
->ptlEnd
.x
,
939 (INT
)lpArc
->ptlEnd
.y
);
946 PEMRCHORD lpChord
= (PEMRCHORD
)mr
;
949 (INT
)lpChord
->rclBox
.left
,
950 (INT
)lpChord
->rclBox
.top
,
951 (INT
)lpChord
->rclBox
.right
,
952 (INT
)lpChord
->rclBox
.bottom
,
953 (INT
)lpChord
->ptlStart
.x
,
954 (INT
)lpChord
->ptlStart
.y
,
955 (INT
)lpChord
->ptlEnd
.x
,
956 (INT
)lpChord
->ptlEnd
.y
);
963 PEMRPIE lpPie
= (PEMRPIE
)mr
;
966 (INT
)lpPie
->rclBox
.left
,
967 (INT
)lpPie
->rclBox
.top
,
968 (INT
)lpPie
->rclBox
.right
,
969 (INT
)lpPie
->rclBox
.bottom
,
970 (INT
)lpPie
->ptlStart
.x
,
971 (INT
)lpPie
->ptlStart
.y
,
972 (INT
)lpPie
->ptlEnd
.x
,
973 (INT
)lpPie
->ptlEnd
.y
);
980 PEMRARC lpArcTo
= (PEMRARC
)mr
;
983 (INT
)lpArcTo
->rclBox
.left
,
984 (INT
)lpArcTo
->rclBox
.top
,
985 (INT
)lpArcTo
->rclBox
.right
,
986 (INT
)lpArcTo
->rclBox
.bottom
,
987 (INT
)lpArcTo
->ptlStart
.x
,
988 (INT
)lpArcTo
->ptlStart
.y
,
989 (INT
)lpArcTo
->ptlEnd
.x
,
990 (INT
)lpArcTo
->ptlEnd
.y
);
995 case EMR_EXTFLOODFILL
:
997 PEMREXTFLOODFILL lpExtFloodFill
= (PEMREXTFLOODFILL
)mr
;
1000 (INT
)lpExtFloodFill
->ptlStart
.x
,
1001 (INT
)lpExtFloodFill
->ptlStart
.y
,
1002 lpExtFloodFill
->crColor
,
1003 (UINT
)lpExtFloodFill
->iMode
);
1010 PEMRPOLYDRAW lpPolyDraw
= (PEMRPOLYDRAW
)mr
;
1012 (const LPPOINT
)lpPolyDraw
->aptl
,
1013 lpPolyDraw
->abTypes
,
1014 (INT
)lpPolyDraw
->cptl
);
1019 case EMR_SETARCDIRECTION
:
1021 PEMRSETARCDIRECTION lpSetArcDirection
= (PEMRSETARCDIRECTION
)mr
;
1022 SetArcDirection( hdc
, (INT
)lpSetArcDirection
->iArcDirection
);
1026 case EMR_SETMITERLIMIT
:
1028 PEMRSETMITERLIMIT lpSetMiterLimit
= (PEMRSETMITERLIMIT
)mr
;
1029 SetMiterLimit( hdc
, lpSetMiterLimit
->eMiterLimit
, NULL
);
1045 case EMR_CLOSEFIGURE
:
1053 /*PEMRFILLPATH lpFillPath = (PEMRFILLPATH)mr;*/
1058 case EMR_STROKEANDFILLPATH
:
1060 /*PEMRSTROKEANDFILLPATH lpStrokeAndFillPath = (PEMRSTROKEANDFILLPATH)mr;*/
1061 StrokeAndFillPath( hdc
);
1065 case EMR_STROKEPATH
:
1067 /*PEMRSTROKEPATH lpStrokePath = (PEMRSTROKEPATH)mr;*/
1072 case EMR_FLATTENPATH
:
1084 case EMR_SELECTCLIPPATH
:
1086 PEMRSELECTCLIPPATH lpSelectClipPath
= (PEMRSELECTCLIPPATH
)mr
;
1087 SelectClipPath( hdc
, (INT
)lpSelectClipPath
->iMode
);
1097 case EMR_CREATECOLORSPACE
:
1099 PEMRCREATECOLORSPACE lpCreateColorSpace
= (PEMRCREATECOLORSPACE
)mr
;
1100 (handletable
->objectHandle
)[lpCreateColorSpace
->ihCS
] =
1101 CreateColorSpaceA( &lpCreateColorSpace
->lcs
);
1105 case EMR_SETCOLORSPACE
:
1107 PEMRSETCOLORSPACE lpSetColorSpace
= (PEMRSETCOLORSPACE
)mr
;
1109 (handletable
->objectHandle
)[lpSetColorSpace
->ihCS
] );
1113 case EMR_DELETECOLORSPACE
:
1115 PEMRDELETECOLORSPACE lpDeleteColorSpace
= (PEMRDELETECOLORSPACE
)mr
;
1116 DeleteColorSpace( (handletable
->objectHandle
)[lpDeleteColorSpace
->ihCS
] );
1120 case EMR_SETICMMODE
:
1122 PERMSETICMMODE lpSetICMMode
= (PERMSETICMMODE
)mr
;
1123 SetICMMode( hdc
, (INT
)lpSetICMMode
->iMode
);
1127 case EMR_PIXELFORMAT
:
1130 PEMRPIXELFORMAT lpPixelFormat
= (PEMRPIXELFORMAT
)mr
;
1132 iPixelFormat
= ChoosePixelFormat( hdc
, &lpPixelFormat
->pfd
);
1133 SetPixelFormat( hdc
, iPixelFormat
, &lpPixelFormat
->pfd
);
1138 case EMR_SETPALETTEENTRIES
:
1140 PEMRSETPALETTEENTRIES lpSetPaletteEntries
= (PEMRSETPALETTEENTRIES
)mr
;
1142 SetPaletteEntries( (handletable
->objectHandle
)[lpSetPaletteEntries
->ihPal
],
1143 (UINT
)lpSetPaletteEntries
->iStart
,
1144 (UINT
)lpSetPaletteEntries
->cEntries
,
1145 lpSetPaletteEntries
->aPalEntries
);
1150 case EMR_RESIZEPALETTE
:
1152 PEMRRESIZEPALETTE lpResizePalette
= (PEMRRESIZEPALETTE
)mr
;
1154 ResizePalette( (handletable
->objectHandle
)[lpResizePalette
->ihPal
],
1155 (UINT
)lpResizePalette
->cEntries
);
1160 case EMR_CREATEDIBPATTERNBRUSHPT
:
1162 PEMRCREATEDIBPATTERNBRUSHPT lpCreate
= (PEMRCREATEDIBPATTERNBRUSHPT
)mr
;
1164 /* This is a BITMAPINFO struct followed directly by bitmap bits */
1165 LPVOID lpPackedStruct
= HeapAlloc( GetProcessHeap(),
1167 lpCreate
->cbBmi
+ lpCreate
->cbBits
);
1168 /* Now pack this structure */
1169 memcpy( lpPackedStruct
,
1170 ((BYTE
*)lpCreate
) + lpCreate
->offBmi
,
1172 memcpy( ((BYTE
*)lpPackedStruct
) + lpCreate
->cbBmi
,
1173 ((BYTE
*)lpCreate
) + lpCreate
->offBits
,
1176 (handletable
->objectHandle
)[lpCreate
->ihBrush
] =
1177 CreateDIBPatternBrushPt( lpPackedStruct
,
1178 (UINT
)lpCreate
->iUsage
);
1183 case EMR_CREATEMONOBRUSH
:
1185 PEMRCREATEMONOBRUSH pCreateMonoBrush
= (PEMRCREATEMONOBRUSH
)mr
;
1186 BITMAPINFO
*pbi
= (BITMAPINFO
*)((BYTE
*)mr
+ pCreateMonoBrush
->offBmi
);
1187 HBITMAP hBmp
= CreateDIBitmap(0, (BITMAPINFOHEADER
*)pbi
, CBM_INIT
,
1188 (BYTE
*)mr
+ pCreateMonoBrush
->offBits
, pbi
, pCreateMonoBrush
->iUsage
);
1189 (handletable
->objectHandle
)[pCreateMonoBrush
->ihBrush
] = CreatePatternBrush(hBmp
);
1190 /* CreatePatternBrush created a copy of the bitmap */
1197 PEMRBITBLT pBitBlt
= (PEMRBITBLT
)mr
;
1198 HDC hdcSrc
= CreateCompatibleDC(hdc
);
1199 HBRUSH hBrush
, hBrushOld
;
1200 HBITMAP hBmp
, hBmpOld
;
1201 BITMAPINFO
*pbi
= (BITMAPINFO
*)((BYTE
*)mr
+ pBitBlt
->offBmiSrc
);
1203 SetWorldTransform(hdcSrc
, &pBitBlt
->xformSrc
);
1205 hBrush
= CreateSolidBrush(pBitBlt
->crBkColorSrc
);
1206 hBrushOld
= SelectObject(hdcSrc
, hBrush
);
1207 PatBlt(hdcSrc
, pBitBlt
->rclBounds
.left
, pBitBlt
->rclBounds
.top
,
1208 pBitBlt
->rclBounds
.right
- pBitBlt
->rclBounds
.left
,
1209 pBitBlt
->rclBounds
.bottom
- pBitBlt
->rclBounds
.top
, PATCOPY
);
1210 SelectObject(hdcSrc
, hBrushOld
);
1211 DeleteObject(hBrush
);
1213 hBmp
= CreateDIBitmap(0, (BITMAPINFOHEADER
*)pbi
, CBM_INIT
,
1214 (BYTE
*)mr
+ pBitBlt
->offBitsSrc
, pbi
, pBitBlt
->iUsageSrc
);
1215 hBmpOld
= SelectObject(hdcSrc
, hBmp
);
1225 SelectObject(hdcSrc
, hBmpOld
);
1231 case EMR_STRETCHBLT
:
1233 PEMRSTRETCHBLT pStretchBlt
= (PEMRSTRETCHBLT
)mr
;
1234 HDC hdcSrc
= CreateCompatibleDC(hdc
);
1235 HBRUSH hBrush
, hBrushOld
;
1236 HBITMAP hBmp
, hBmpOld
;
1237 BITMAPINFO
*pbi
= (BITMAPINFO
*)((BYTE
*)mr
+ pStretchBlt
->offBmiSrc
);
1239 SetWorldTransform(hdcSrc
, &pStretchBlt
->xformSrc
);
1241 hBrush
= CreateSolidBrush(pStretchBlt
->crBkColorSrc
);
1242 hBrushOld
= SelectObject(hdcSrc
, hBrush
);
1243 PatBlt(hdcSrc
, pStretchBlt
->rclBounds
.left
, pStretchBlt
->rclBounds
.top
,
1244 pStretchBlt
->rclBounds
.right
- pStretchBlt
->rclBounds
.left
,
1245 pStretchBlt
->rclBounds
.bottom
- pStretchBlt
->rclBounds
.top
, PATCOPY
);
1246 SelectObject(hdcSrc
, hBrushOld
);
1247 DeleteObject(hBrush
);
1249 hBmp
= CreateDIBitmap(0, (BITMAPINFOHEADER
*)pbi
, CBM_INIT
,
1250 (BYTE
*)mr
+ pStretchBlt
->offBitsSrc
, pbi
, pStretchBlt
->iUsageSrc
);
1251 hBmpOld
= SelectObject(hdcSrc
, hBmp
);
1255 pStretchBlt
->cxDest
,
1256 pStretchBlt
->cyDest
,
1262 pStretchBlt
->dwRop
);
1263 SelectObject(hdcSrc
, hBmpOld
);
1271 PEMRMASKBLT pMaskBlt
= (PEMRMASKBLT
)mr
;
1272 HDC hdcSrc
= CreateCompatibleDC(hdc
);
1273 HBRUSH hBrush
, hBrushOld
;
1274 HBITMAP hBmp
, hBmpOld
, hBmpMask
;
1277 SetWorldTransform(hdcSrc
, &pMaskBlt
->xformSrc
);
1279 hBrush
= CreateSolidBrush(pMaskBlt
->crBkColorSrc
);
1280 hBrushOld
= SelectObject(hdcSrc
, hBrush
);
1281 PatBlt(hdcSrc
, pMaskBlt
->rclBounds
.left
, pMaskBlt
->rclBounds
.top
,
1282 pMaskBlt
->rclBounds
.right
- pMaskBlt
->rclBounds
.left
,
1283 pMaskBlt
->rclBounds
.bottom
- pMaskBlt
->rclBounds
.top
, PATCOPY
);
1284 SelectObject(hdcSrc
, hBrushOld
);
1285 DeleteObject(hBrush
);
1287 pbi
= (BITMAPINFO
*)((BYTE
*)mr
+ pMaskBlt
->offBmiMask
);
1288 hBmpMask
= CreateDIBitmap(0, (BITMAPINFOHEADER
*)pbi
, CBM_INIT
,
1289 (BYTE
*)mr
+ pMaskBlt
->offBitsMask
, pbi
, pMaskBlt
->iUsageMask
);
1291 pbi
= (BITMAPINFO
*)((BYTE
*)mr
+ pMaskBlt
->offBmiSrc
);
1292 hBmp
= CreateDIBitmap(0, (BITMAPINFOHEADER
*)pbi
, CBM_INIT
,
1293 (BYTE
*)mr
+ pMaskBlt
->offBitsSrc
, pbi
, pMaskBlt
->iUsageSrc
);
1294 hBmpOld
= SelectObject(hdcSrc
, hBmp
);
1307 SelectObject(hdcSrc
, hBmpOld
);
1309 DeleteObject(hBmpMask
);
1316 PEMRPLGBLT pPlgBlt
= (PEMRPLGBLT
)mr
;
1317 HDC hdcSrc
= CreateCompatibleDC(hdc
);
1318 HBRUSH hBrush
, hBrushOld
;
1319 HBITMAP hBmp
, hBmpOld
, hBmpMask
;
1323 SetWorldTransform(hdcSrc
, &pPlgBlt
->xformSrc
);
1325 pts
[0].x
= pPlgBlt
->aptlDst
[0].x
; pts
[0].y
= pPlgBlt
->aptlDst
[0].y
;
1326 pts
[1].x
= pPlgBlt
->aptlDst
[1].x
; pts
[1].y
= pPlgBlt
->aptlDst
[1].y
;
1327 pts
[2].x
= pPlgBlt
->aptlDst
[2].x
; pts
[2].y
= pPlgBlt
->aptlDst
[2].y
;
1329 hBrush
= CreateSolidBrush(pPlgBlt
->crBkColorSrc
);
1330 hBrushOld
= SelectObject(hdcSrc
, hBrush
);
1331 PatBlt(hdcSrc
, pPlgBlt
->rclBounds
.left
, pPlgBlt
->rclBounds
.top
,
1332 pPlgBlt
->rclBounds
.right
- pPlgBlt
->rclBounds
.left
,
1333 pPlgBlt
->rclBounds
.bottom
- pPlgBlt
->rclBounds
.top
, PATCOPY
);
1334 SelectObject(hdcSrc
, hBrushOld
);
1335 DeleteObject(hBrush
);
1337 pbi
= (BITMAPINFO
*)((BYTE
*)mr
+ pPlgBlt
->offBmiMask
);
1338 hBmpMask
= CreateDIBitmap(0, (BITMAPINFOHEADER
*)pbi
, CBM_INIT
,
1339 (BYTE
*)mr
+ pPlgBlt
->offBitsMask
, pbi
, pPlgBlt
->iUsageMask
);
1341 pbi
= (BITMAPINFO
*)((BYTE
*)mr
+ pPlgBlt
->offBmiSrc
);
1342 hBmp
= CreateDIBitmap(0, (BITMAPINFOHEADER
*)pbi
, CBM_INIT
,
1343 (BYTE
*)mr
+ pPlgBlt
->offBitsSrc
, pbi
, pPlgBlt
->iUsageSrc
);
1344 hBmpOld
= SelectObject(hdcSrc
, hBmp
);
1355 SelectObject(hdcSrc
, hBmpOld
);
1357 DeleteObject(hBmpMask
);
1362 case EMR_SETDIBITSTODEVICE
:
1364 PEMRSETDIBITSTODEVICE pSetDIBitsToDevice
= (PEMRSETDIBITSTODEVICE
)mr
;
1366 SetDIBitsToDevice(hdc
,
1367 pSetDIBitsToDevice
->xDest
,
1368 pSetDIBitsToDevice
->yDest
,
1369 pSetDIBitsToDevice
->cxSrc
,
1370 pSetDIBitsToDevice
->cySrc
,
1371 pSetDIBitsToDevice
->xSrc
,
1372 pSetDIBitsToDevice
->ySrc
,
1373 pSetDIBitsToDevice
->iStartScan
,
1374 pSetDIBitsToDevice
->cScans
,
1375 (BYTE
*)mr
+ pSetDIBitsToDevice
->offBitsSrc
,
1376 (BITMAPINFO
*)((BYTE
*)mr
+ pSetDIBitsToDevice
->offBmiSrc
),
1377 pSetDIBitsToDevice
->iUsageSrc
);
1381 case EMR_POLYTEXTOUTA
:
1383 PEMRPOLYTEXTOUTA pPolyTextOutA
= (PEMRPOLYTEXTOUTA
)mr
;
1384 POLYTEXTA
*polytextA
= HeapAlloc(GetProcessHeap(), 0, pPolyTextOutA
->cStrings
* sizeof(POLYTEXTA
));
1386 XFORM xform
, xformOld
;
1389 gModeOld
= SetGraphicsMode(hdc
, pPolyTextOutA
->iGraphicsMode
);
1390 GetWorldTransform(hdc
, &xformOld
);
1392 xform
.eM11
= pPolyTextOutA
->exScale
;
1395 xform
.eM22
= pPolyTextOutA
->eyScale
;
1398 SetWorldTransform(hdc
, &xform
);
1400 /* Set up POLYTEXTA structures */
1401 for(i
= 0; i
< pPolyTextOutA
->cStrings
; i
++)
1403 polytextA
[i
].x
= pPolyTextOutA
->aemrtext
[i
].ptlReference
.x
;
1404 polytextA
[i
].y
= pPolyTextOutA
->aemrtext
[i
].ptlReference
.y
;
1405 polytextA
[i
].n
= pPolyTextOutA
->aemrtext
[i
].nChars
;
1406 polytextA
[i
].lpstr
= (LPSTR
)((BYTE
*)mr
+ pPolyTextOutA
->aemrtext
[i
].offString
);
1407 polytextA
[i
].uiFlags
= pPolyTextOutA
->aemrtext
[i
].fOptions
;
1408 polytextA
[i
].rcl
.left
= pPolyTextOutA
->aemrtext
[i
].rcl
.left
;
1409 polytextA
[i
].rcl
.right
= pPolyTextOutA
->aemrtext
[i
].rcl
.right
;
1410 polytextA
[i
].rcl
.top
= pPolyTextOutA
->aemrtext
[i
].rcl
.top
;
1411 polytextA
[i
].rcl
.bottom
= pPolyTextOutA
->aemrtext
[i
].rcl
.bottom
;
1412 polytextA
[i
].pdx
= (int *)((BYTE
*)mr
+ pPolyTextOutA
->aemrtext
[i
].offDx
);
1414 PolyTextOutA(hdc
, polytextA
, pPolyTextOutA
->cStrings
);
1415 HeapFree(GetProcessHeap(), 0, polytextA
);
1417 SetWorldTransform(hdc
, &xformOld
);
1418 SetGraphicsMode(hdc
, gModeOld
);
1422 case EMR_POLYTEXTOUTW
:
1424 PEMRPOLYTEXTOUTW pPolyTextOutW
= (PEMRPOLYTEXTOUTW
)mr
;
1425 POLYTEXTW
*polytextW
= HeapAlloc(GetProcessHeap(), 0, pPolyTextOutW
->cStrings
* sizeof(POLYTEXTW
));
1427 XFORM xform
, xformOld
;
1430 gModeOld
= SetGraphicsMode(hdc
, pPolyTextOutW
->iGraphicsMode
);
1431 GetWorldTransform(hdc
, &xformOld
);
1433 xform
.eM11
= pPolyTextOutW
->exScale
;
1436 xform
.eM22
= pPolyTextOutW
->eyScale
;
1439 SetWorldTransform(hdc
, &xform
);
1441 /* Set up POLYTEXTW structures */
1442 for(i
= 0; i
< pPolyTextOutW
->cStrings
; i
++)
1444 polytextW
[i
].x
= pPolyTextOutW
->aemrtext
[i
].ptlReference
.x
;
1445 polytextW
[i
].y
= pPolyTextOutW
->aemrtext
[i
].ptlReference
.y
;
1446 polytextW
[i
].n
= pPolyTextOutW
->aemrtext
[i
].nChars
;
1447 polytextW
[i
].lpstr
= (LPWSTR
)((BYTE
*)mr
+ pPolyTextOutW
->aemrtext
[i
].offString
);
1448 polytextW
[i
].uiFlags
= pPolyTextOutW
->aemrtext
[i
].fOptions
;
1449 polytextW
[i
].rcl
.left
= pPolyTextOutW
->aemrtext
[i
].rcl
.left
;
1450 polytextW
[i
].rcl
.right
= pPolyTextOutW
->aemrtext
[i
].rcl
.right
;
1451 polytextW
[i
].rcl
.top
= pPolyTextOutW
->aemrtext
[i
].rcl
.top
;
1452 polytextW
[i
].rcl
.bottom
= pPolyTextOutW
->aemrtext
[i
].rcl
.bottom
;
1453 polytextW
[i
].pdx
= (int *)((BYTE
*)mr
+ pPolyTextOutW
->aemrtext
[i
].offDx
);
1455 PolyTextOutW(hdc
, polytextW
, pPolyTextOutW
->cStrings
);
1456 HeapFree(GetProcessHeap(), 0, polytextW
);
1458 SetWorldTransform(hdc
, &xformOld
);
1459 SetGraphicsMode(hdc
, gModeOld
);
1465 PEMRFILLRGN pFillRgn
= (PEMRFILLRGN
)mr
;
1466 HRGN hRgn
= ExtCreateRegion(NULL
, pFillRgn
->cbRgnData
, (RGNDATA
*)pFillRgn
->RgnData
);
1469 (handletable
->objectHandle
)[pFillRgn
->ihBrush
]);
1476 PEMRFRAMERGN pFrameRgn
= (PEMRFRAMERGN
)mr
;
1477 HRGN hRgn
= ExtCreateRegion(NULL
, pFrameRgn
->cbRgnData
, (RGNDATA
*)pFrameRgn
->RgnData
);
1480 (handletable
->objectHandle
)[pFrameRgn
->ihBrush
],
1481 pFrameRgn
->szlStroke
.cx
,
1482 pFrameRgn
->szlStroke
.cy
);
1489 PEMRINVERTRGN pInvertRgn
= (PEMRINVERTRGN
)mr
;
1490 HRGN hRgn
= ExtCreateRegion(NULL
, pInvertRgn
->cbRgnData
, (RGNDATA
*)pInvertRgn
->RgnData
);
1491 InvertRgn(hdc
, hRgn
);
1498 PEMRPAINTRGN pPaintRgn
= (PEMRPAINTRGN
)mr
;
1499 HRGN hRgn
= ExtCreateRegion(NULL
, pPaintRgn
->cbRgnData
, (RGNDATA
*)pPaintRgn
->RgnData
);
1500 PaintRgn(hdc
, hRgn
);
1505 case EMR_POLYDRAW16
:
1507 case EMR_GLSBOUNDEDRECORD
:
1509 /* From docs: If PlayEnhMetaFileRecord doesn't recognize a
1510 record then ignore and return TRUE. */
1511 FIXME("type %d is unimplemented\n", type
);
1518 /*****************************************************************************
1520 * EnumEnhMetaFile (GDI32.@)
1522 * Walk an enhanced metafile, calling a user-specified function _EnhMetaFunc_
1524 * record. Returns when either every record has been used or
1525 * when _EnhMetaFunc_ returns FALSE.
1529 * TRUE if every record is used, FALSE if any invocation of _EnhMetaFunc_
1535 BOOL WINAPI
EnumEnhMetaFile(
1536 HDC hdc
, /* [in] device context to pass to _EnhMetaFunc_ */
1537 HENHMETAFILE hmf
, /* [in] EMF to walk */
1538 ENHMFENUMPROC callback
, /* [in] callback function */
1539 LPVOID data
, /* [in] optional data for callback function */
1540 const RECT
*lpRect
/* [in] bounding rectangle for rendered metafile */
1544 ENHMETAHEADER
*emh
, *emhTemp
;
1550 FLOAT xSrcPixSize
, ySrcPixSize
, xscale
, yscale
;
1551 XFORM savedXform
, xform
;
1552 HPEN hPen
= (HPEN
)NULL
;
1553 HBRUSH hBrush
= (HBRUSH
)NULL
;
1554 HFONT hFont
= (HFONT
)NULL
;
1558 SetLastError(ERROR_INVALID_PARAMETER
);
1562 emh
= EMF_GetEnhMetaHeader(hmf
);
1564 SetLastError(ERROR_INVALID_HANDLE
);
1568 /* Copy the metafile into memory, because we need to avoid deadlock. */
1569 emhTemp
= HeapAlloc(GetProcessHeap(), 0, emh
->nSize
+ emh
->nBytes
);
1572 EMF_ReleaseEnhMetaHeader(hmf
);
1573 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1576 memcpy(emhTemp
, emh
, emh
->nSize
+ emh
->nBytes
);
1578 EMF_ReleaseEnhMetaHeader(hmf
);
1580 ht
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
1581 sizeof(HANDLETABLE
) * emh
->nHandles
);
1584 HeapFree(GetProcessHeap(), 0, emhTemp
);
1585 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
1588 ht
->objectHandle
[0] = hmf
;
1592 TRACE("rect: %d,%d - %d,%d. rclFrame: %ld,%ld - %ld,%ld\n",
1593 lpRect
->left
, lpRect
->top
, lpRect
->right
, lpRect
->bottom
,
1594 emh
->rclFrame
.left
, emh
->rclFrame
.top
, emh
->rclFrame
.right
,
1595 emh
->rclFrame
.bottom
);
1597 xSrcPixSize
= (FLOAT
) emh
->szlMillimeters
.cx
/ emh
->szlDevice
.cx
;
1598 ySrcPixSize
= (FLOAT
) emh
->szlMillimeters
.cy
/ emh
->szlDevice
.cy
;
1599 xscale
= (FLOAT
)(lpRect
->right
- lpRect
->left
) * 100.0 /
1600 (emh
->rclFrame
.right
- emh
->rclFrame
.left
) * xSrcPixSize
;
1601 yscale
= (FLOAT
)(lpRect
->bottom
- lpRect
->top
) * 100.0 /
1602 (emh
->rclFrame
.bottom
- emh
->rclFrame
.top
) * ySrcPixSize
;
1604 xform
.eM11
= xscale
;
1607 xform
.eM22
= yscale
;
1608 xform
.eDx
= (FLOAT
) lpRect
->left
- (lpRect
->right
- lpRect
->left
) *
1609 emh
->rclFrame
.left
/ (emh
->rclFrame
.right
- emh
->rclFrame
.left
);
1610 xform
.eDy
= (FLOAT
) lpRect
->top
- (lpRect
->bottom
- lpRect
->top
) *
1611 emh
->rclFrame
.top
/ (emh
->rclFrame
.bottom
- emh
->rclFrame
.top
);
1613 savedMode
= SetGraphicsMode(hdc
, GM_ADVANCED
);
1614 GetWorldTransform(hdc
, &savedXform
);
1616 if (!ModifyWorldTransform(hdc
, &xform
, MWT_RIGHTMULTIPLY
)) {
1617 ERR("World transform failed!\n");
1620 /* save the current pen, brush and font */
1621 hPen
= GetCurrentObject(hdc
, OBJ_PEN
);
1622 hBrush
= GetCurrentObject(hdc
, OBJ_BRUSH
);
1623 hFont
= GetCurrentObject(hdc
, OBJ_FONT
);
1626 TRACE("nSize = %ld, nBytes = %ld, nHandles = %d, nRecords = %ld, nPalEntries = %ld\n",
1627 emh
->nSize
, emh
->nBytes
, emh
->nHandles
, emh
->nRecords
, emh
->nPalEntries
);
1631 while(ret
&& offset
< emh
->nBytes
)
1633 emr
= (ENHMETARECORD
*)((char *)emh
+ offset
);
1634 TRACE("Calling EnumFunc with record type %ld, size %ld\n", emr
->iType
, emr
->nSize
);
1635 ret
= (*callback
)(hdc
, ht
, emr
, emh
->nHandles
, data
);
1636 offset
+= emr
->nSize
;
1641 /* restore pen, brush and font */
1642 SelectObject(hdc
, hBrush
);
1643 SelectObject(hdc
, hPen
);
1644 SelectObject(hdc
, hFont
);
1646 SetWorldTransform(hdc
, &savedXform
);
1648 SetGraphicsMode(hdc
, savedMode
);
1651 for(i
= 1; i
< emh
->nHandles
; i
++) /* Don't delete element 0 (hmf) */
1652 if( (ht
->objectHandle
)[i
] )
1653 DeleteObject( (ht
->objectHandle
)[i
] );
1655 HeapFree( GetProcessHeap(), 0, ht
);
1656 HeapFree(GetProcessHeap(), 0, emhTemp
);
1661 static INT CALLBACK
EMF_PlayEnhMetaFileCallback(HDC hdc
, HANDLETABLE
*ht
,
1663 INT handles
, LPVOID data
)
1665 return PlayEnhMetaFileRecord(hdc
, ht
, emr
, handles
);
1668 /**************************************************************************
1669 * PlayEnhMetaFile (GDI32.@)
1671 * Renders an enhanced metafile into a specified rectangle *lpRect
1672 * in device context hdc.
1675 BOOL WINAPI
PlayEnhMetaFile(
1676 HDC hdc
, /* [in] DC to render into */
1677 HENHMETAFILE hmf
, /* [in] metafile to render */
1678 const RECT
*lpRect
/* [in] rectangle to place metafile inside */
1681 return EnumEnhMetaFile(hdc
, hmf
, EMF_PlayEnhMetaFileCallback
, NULL
,
1685 /*****************************************************************************
1686 * DeleteEnhMetaFile (GDI32.@)
1688 * Deletes an enhanced metafile and frees the associated storage.
1690 BOOL WINAPI
DeleteEnhMetaFile(HENHMETAFILE hmf
)
1692 return EMF_Delete_HENHMETAFILE( hmf
);
1695 /*****************************************************************************
1696 * CopyEnhMetaFileA (GDI32.@) Duplicate an enhanced metafile
1700 HENHMETAFILE WINAPI
CopyEnhMetaFileA(
1701 HENHMETAFILE hmfSrc
,
1704 ENHMETAHEADER
*emrSrc
= EMF_GetEnhMetaHeader( hmfSrc
), *emrDst
;
1705 HENHMETAFILE hmfDst
;
1707 if(!emrSrc
) return FALSE
;
1709 emrDst
= HeapAlloc( GetProcessHeap(), 0, emrSrc
->nBytes
);
1710 memcpy( emrDst
, emrSrc
, emrSrc
->nBytes
);
1711 hmfDst
= EMF_Create_HENHMETAFILE( emrDst
, 0, 0 );
1714 hFile
= CreateFileA( file
, GENERIC_WRITE
| GENERIC_READ
, 0, NULL
,
1715 CREATE_ALWAYS
, 0, 0);
1716 WriteFile( hFile
, emrSrc
, emrSrc
->nBytes
, 0, 0);
1717 hmfDst
= EMF_GetEnhMetaFile( hFile
);
1719 EMF_ReleaseEnhMetaHeader( hmfSrc
);
1724 /* Struct to be used to be passed in the LPVOID parameter for cbEnhPaletteCopy */
1725 typedef struct tagEMF_PaletteCopy
1728 LPPALETTEENTRY lpPe
;
1731 /***************************************************************
1732 * Find the EMR_EOF record and then use it to find the
1733 * palette entries for this enhanced metafile.
1734 * The lpData is actually a pointer to a EMF_PaletteCopy struct
1735 * which contains the max number of elements to copy and where
1738 * NOTE: To be used by GetEnhMetaFilePaletteEntries only!
1740 INT CALLBACK
cbEnhPaletteCopy( HDC a
,
1742 LPENHMETARECORD lpEMR
,
1747 if ( lpEMR
->iType
== EMR_EOF
)
1749 PEMREOF lpEof
= (PEMREOF
)lpEMR
;
1750 EMF_PaletteCopy
* info
= (EMF_PaletteCopy
*)lpData
;
1751 DWORD dwNumPalToCopy
= min( lpEof
->nPalEntries
, info
->cEntries
);
1753 TRACE( "copying 0x%08lx palettes\n", dwNumPalToCopy
);
1755 memcpy( (LPVOID
)info
->lpPe
,
1756 (LPVOID
)(((LPSTR
)lpEof
) + lpEof
->offPalEntries
),
1757 sizeof( *(info
->lpPe
) ) * dwNumPalToCopy
);
1759 /* Update the passed data as a return code */
1760 info
->lpPe
= NULL
; /* Palettes were copied! */
1761 info
->cEntries
= (UINT
)dwNumPalToCopy
;
1763 return FALSE
; /* That's all we need */
1769 /*****************************************************************************
1770 * GetEnhMetaFilePaletteEntries (GDI32.@)
1772 * Copy the palette and report size
1774 * BUGS: Error codes (SetLastError) are not set on failures
1776 UINT WINAPI
GetEnhMetaFilePaletteEntries( HENHMETAFILE hEmf
,
1778 LPPALETTEENTRY lpPe
)
1780 ENHMETAHEADER
* enhHeader
= EMF_GetEnhMetaHeader( hEmf
);
1781 UINT uReturnValue
= GDI_ERROR
;
1782 EMF_PaletteCopy infoForCallBack
;
1784 TRACE( "(%04x,%d,%p)\n", hEmf
, cEntries
, lpPe
);
1786 /* First check if there are any palettes associated with
1788 if ( enhHeader
->nPalEntries
== 0 )
1790 /* No palette associated with this enhanced metafile */
1795 /* Is the user requesting the number of palettes? */
1798 uReturnValue
= (UINT
)enhHeader
->nPalEntries
;
1802 /* Copy cEntries worth of PALETTEENTRY structs into the buffer */
1803 infoForCallBack
.cEntries
= cEntries
;
1804 infoForCallBack
.lpPe
= lpPe
;
1806 if ( !EnumEnhMetaFile( 0, hEmf
, cbEnhPaletteCopy
,
1807 &infoForCallBack
, NULL
) )
1812 /* Verify that the callback executed correctly */
1813 if ( infoForCallBack
.lpPe
!= NULL
)
1815 /* Callback proc had error! */
1816 ERR( "cbEnhPaletteCopy didn't execute correctly\n" );
1820 uReturnValue
= infoForCallBack
.cEntries
;
1824 EMF_ReleaseEnhMetaHeader( hEmf
);
1826 return uReturnValue
;
1829 /******************************************************************
1830 * SetWinMetaFileBits (GDI32.@)
1832 * Translate from old style to new style.
1834 * BUGS: - This doesn't take the DC and scaling into account
1835 * - Most record conversions aren't implemented
1836 * - Handle slot assignement is primative and most likely doesn't work
1838 HENHMETAFILE WINAPI
SetWinMetaFileBits(UINT cbBuffer
,
1839 CONST BYTE
*lpbBuffer
,
1841 CONST METAFILEPICT
*lpmfp
1845 LPVOID lpNewEnhMetaFileBuffer
= NULL
;
1846 UINT uNewEnhMetaFileBufferSize
= 0;
1847 BOOL bFoundEOF
= FALSE
;
1849 FIXME( "(%d,%p,%04x,%p):stub\n", cbBuffer
, lpbBuffer
, hdcRef
, lpmfp
);
1851 /* 1. Get the header - skip over this and get straight to the records */
1853 uNewEnhMetaFileBufferSize
= sizeof( ENHMETAHEADER
);
1854 lpNewEnhMetaFileBuffer
= HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY
,
1855 uNewEnhMetaFileBufferSize
);
1857 if( lpNewEnhMetaFileBuffer
== NULL
)
1862 /* Fill in the header record */
1864 LPENHMETAHEADER lpNewEnhMetaFileHeader
= (LPENHMETAHEADER
)lpNewEnhMetaFileBuffer
;
1866 lpNewEnhMetaFileHeader
->iType
= EMR_HEADER
;
1867 lpNewEnhMetaFileHeader
->nSize
= sizeof( ENHMETAHEADER
);
1869 /* FIXME: Not right. Must be able to get this from the DC */
1870 lpNewEnhMetaFileHeader
->rclBounds
.left
= 0;
1871 lpNewEnhMetaFileHeader
->rclBounds
.right
= 0;
1872 lpNewEnhMetaFileHeader
->rclBounds
.top
= 0;
1873 lpNewEnhMetaFileHeader
->rclBounds
.bottom
= 0;
1875 /* FIXME: Not right. Must be able to get this from the DC */
1876 lpNewEnhMetaFileHeader
->rclFrame
.left
= 0;
1877 lpNewEnhMetaFileHeader
->rclFrame
.right
= 0;
1878 lpNewEnhMetaFileHeader
->rclFrame
.top
= 0;
1879 lpNewEnhMetaFileHeader
->rclFrame
.bottom
= 0;
1881 lpNewEnhMetaFileHeader
->nHandles
= 0; /* No handles yet */
1883 /* FIXME: Add in the rest of the fields to the header */
1898 (char*)lpbBuffer
+= ((METAHEADER
*)lpbBuffer
)->mtHeaderSize
* 2; /* Point past the header - FIXME: metafile quirk? */
1900 /* 2. Enum over individual records and convert them to the new type of records */
1904 LPMETARECORD lpMetaRecord
= (LPMETARECORD
)lpbBuffer
;
1906 #define EMF_ReAllocAndAdjustPointers( a , b ) \
1909 lpTmp = HeapReAlloc( GetProcessHeap(), 0, \
1910 lpNewEnhMetaFileBuffer, \
1911 uNewEnhMetaFileBufferSize + (b) ); \
1912 if( lpTmp == NULL ) { ERR( "No memory!\n" ); goto error; } \
1913 lpNewEnhMetaFileBuffer = lpTmp; \
1914 lpRecord = (a)( (char*)lpNewEnhMetaFileBuffer + uNewEnhMetaFileBufferSize ); \
1915 uNewEnhMetaFileBufferSize += (b); \
1918 switch( lpMetaRecord
->rdFunction
)
1923 size_t uRecord
= sizeof(*lpRecord
);
1925 EMF_ReAllocAndAdjustPointers(PEMREOF
,uRecord
);
1927 /* Fill the new record - FIXME: This is not right */
1928 lpRecord
->emr
.iType
= EMR_EOF
;
1929 lpRecord
->emr
.nSize
= sizeof( *lpRecord
);
1930 lpRecord
->nPalEntries
= 0; /* FIXME */
1931 lpRecord
->offPalEntries
= 0; /* FIXME */
1932 lpRecord
->nSizeLast
= 0; /* FIXME */
1934 /* No more records after this one */
1937 FIXME( "META_EOF conversion not correct\n" );
1941 case META_SETMAPMODE
:
1943 PEMRSETMAPMODE lpRecord
;
1944 size_t uRecord
= sizeof(*lpRecord
);
1946 EMF_ReAllocAndAdjustPointers(PEMRSETMAPMODE
,uRecord
);
1948 lpRecord
->emr
.iType
= EMR_SETMAPMODE
;
1949 lpRecord
->emr
.nSize
= sizeof( *lpRecord
);
1951 lpRecord
->iMode
= lpMetaRecord
->rdParm
[0];
1956 case META_DELETEOBJECT
: /* Select and Delete structures are the same */
1957 case META_SELECTOBJECT
:
1959 PEMRDELETEOBJECT lpRecord
;
1960 size_t uRecord
= sizeof(*lpRecord
);
1962 EMF_ReAllocAndAdjustPointers(PEMRDELETEOBJECT
,uRecord
);
1964 if( lpMetaRecord
->rdFunction
== META_DELETEOBJECT
)
1966 lpRecord
->emr
.iType
= EMR_DELETEOBJECT
;
1970 lpRecord
->emr
.iType
= EMR_SELECTOBJECT
;
1972 lpRecord
->emr
.nSize
= sizeof( *lpRecord
);
1974 lpRecord
->ihObject
= lpMetaRecord
->rdParm
[0]; /* FIXME: Handle */
1979 case META_POLYGON
: /* This is just plain busted. I don't know what I'm doing */
1981 PEMRPOLYGON16 lpRecord
; /* FIXME: Should it be a poly or poly16? */
1982 size_t uRecord
= sizeof(*lpRecord
);
1984 EMF_ReAllocAndAdjustPointers(PEMRPOLYGON16
,uRecord
);
1986 /* FIXME: This is mostly all wrong */
1987 lpRecord
->emr
.iType
= EMR_POLYGON16
;
1988 lpRecord
->emr
.nSize
= sizeof( *lpRecord
);
1990 lpRecord
->rclBounds
.left
= 0;
1991 lpRecord
->rclBounds
.right
= 0;
1992 lpRecord
->rclBounds
.top
= 0;
1993 lpRecord
->rclBounds
.bottom
= 0;
1996 lpRecord
->apts
[0].x
= 0;
1997 lpRecord
->apts
[0].y
= 0;
1999 FIXME( "META_POLYGON conversion not correct\n" );
2004 case META_SETPOLYFILLMODE
:
2006 PEMRSETPOLYFILLMODE lpRecord
;
2007 size_t uRecord
= sizeof(*lpRecord
);
2009 EMF_ReAllocAndAdjustPointers(PEMRSETPOLYFILLMODE
,uRecord
);
2011 lpRecord
->emr
.iType
= EMR_SETPOLYFILLMODE
;
2012 lpRecord
->emr
.nSize
= sizeof( *lpRecord
);
2014 lpRecord
->iMode
= lpMetaRecord
->rdParm
[0];
2019 case META_SETWINDOWORG
:
2021 PEMRSETWINDOWORGEX lpRecord
; /* Seems to be the closest thing */
2022 size_t uRecord
= sizeof(*lpRecord
);
2024 EMF_ReAllocAndAdjustPointers(PEMRSETWINDOWORGEX
,uRecord
);
2026 lpRecord
->emr
.iType
= EMR_SETWINDOWORGEX
;
2027 lpRecord
->emr
.nSize
= sizeof( *lpRecord
);
2029 lpRecord
->ptlOrigin
.x
= lpMetaRecord
->rdParm
[1];
2030 lpRecord
->ptlOrigin
.y
= lpMetaRecord
->rdParm
[0];
2035 case META_SETWINDOWEXT
: /* Structure is the same for SETWINDOWEXT & SETVIEWPORTEXT */
2036 case META_SETVIEWPORTEXT
:
2038 PEMRSETWINDOWEXTEX lpRecord
;
2039 size_t uRecord
= sizeof(*lpRecord
);
2041 EMF_ReAllocAndAdjustPointers(PEMRSETWINDOWEXTEX
,uRecord
);
2043 if ( lpMetaRecord
->rdFunction
== META_SETWINDOWEXT
)
2045 lpRecord
->emr
.iType
= EMR_SETWINDOWORGEX
;
2049 lpRecord
->emr
.iType
= EMR_SETVIEWPORTEXTEX
;
2051 lpRecord
->emr
.nSize
= sizeof( *lpRecord
);
2053 lpRecord
->szlExtent
.cx
= lpMetaRecord
->rdParm
[1];
2054 lpRecord
->szlExtent
.cy
= lpMetaRecord
->rdParm
[0];
2059 case META_CREATEBRUSHINDIRECT
:
2061 PEMRCREATEBRUSHINDIRECT lpRecord
;
2062 size_t uRecord
= sizeof(*lpRecord
);
2064 EMF_ReAllocAndAdjustPointers(PEMRCREATEBRUSHINDIRECT
,uRecord
);
2066 lpRecord
->emr
.iType
= EMR_CREATEBRUSHINDIRECT
;
2067 lpRecord
->emr
.nSize
= sizeof( *lpRecord
);
2069 lpRecord
->ihBrush
= ((LPENHMETAHEADER
)lpNewEnhMetaFileBuffer
)->nHandles
;
2070 lpRecord
->lb
.lbStyle
= ((LPLOGBRUSH16
)lpMetaRecord
->rdParm
)->lbStyle
;
2071 lpRecord
->lb
.lbColor
= ((LPLOGBRUSH16
)lpMetaRecord
->rdParm
)->lbColor
;
2072 lpRecord
->lb
.lbHatch
= ((LPLOGBRUSH16
)lpMetaRecord
->rdParm
)->lbHatch
;
2074 ((LPENHMETAHEADER
)lpNewEnhMetaFileBuffer
)->nHandles
+= 1; /* New handle */
2080 /* These are all unimplemented and as such are intended to fall through to the default case */
2081 case META_SETBKCOLOR
:
2082 case META_SETBKMODE
:
2084 case META_SETRELABS
:
2085 case META_SETSTRETCHBLTMODE
:
2086 case META_SETTEXTCOLOR
:
2087 case META_SETVIEWPORTORG
:
2088 case META_OFFSETWINDOWORG
:
2089 case META_SCALEWINDOWEXT
:
2090 case META_OFFSETVIEWPORTORG
:
2091 case META_SCALEVIEWPORTEXT
:
2094 case META_EXCLUDECLIPRECT
:
2095 case META_INTERSECTCLIPRECT
:
2098 case META_FLOODFILL
:
2100 case META_RECTANGLE
:
2101 case META_ROUNDRECT
:
2105 case META_OFFSETCLIPRGN
:
2107 case META_POLYPOLYGON
:
2109 case META_RESTOREDC
:
2111 case META_CREATEPATTERNBRUSH
:
2112 case META_CREATEPENINDIRECT
:
2113 case META_CREATEFONTINDIRECT
:
2114 case META_CREATEPALETTE
:
2115 case META_SETTEXTALIGN
:
2116 case META_SELECTPALETTE
:
2117 case META_SETMAPPERFLAGS
:
2118 case META_REALIZEPALETTE
:
2120 case META_EXTTEXTOUT
:
2121 case META_STRETCHDIB
:
2122 case META_DIBSTRETCHBLT
:
2123 case META_STRETCHBLT
:
2125 case META_CREATEREGION
:
2126 case META_FILLREGION
:
2127 case META_FRAMEREGION
:
2128 case META_INVERTREGION
:
2129 case META_PAINTREGION
:
2130 case META_SELECTCLIPREGION
:
2131 case META_DIBCREATEPATTERNBRUSH
:
2132 case META_DIBBITBLT
:
2133 case META_SETTEXTCHAREXTRA
:
2134 case META_SETTEXTJUSTIFICATION
:
2135 case META_EXTFLOODFILL
:
2136 case META_SETDIBTODEV
:
2138 case META_ANIMATEPALETTE
:
2139 case META_SETPALENTRIES
:
2140 case META_RESIZEPALETTE
:
2143 case META_STARTPAGE
:
2147 case META_CREATEBRUSH
:
2148 case META_CREATEBITMAPINDIRECT
:
2149 case META_CREATEBITMAP
:
2150 /* Fall through to unimplemented */
2153 /* Not implemented yet */
2154 FIXME( "Conversion of record type 0x%x not implemented.\n", lpMetaRecord
->rdFunction
);
2159 /* Move to the next record */
2160 (char*)lpbBuffer
+= ((LPMETARECORD
)lpbBuffer
)->rdSize
* 2; /* FIXME: Seem to be doing this in metafile.c */
2162 #undef ReAllocAndAdjustPointers
2165 /* We know the last of the header information now */
2166 ((LPENHMETAHEADER
)lpNewEnhMetaFileBuffer
)->nBytes
= uNewEnhMetaFileBufferSize
;
2168 /* Create the enhanced metafile */
2169 hMf
= SetEnhMetaFileBits( uNewEnhMetaFileBufferSize
, (const BYTE
*)lpNewEnhMetaFileBuffer
);
2172 ERR( "Problem creating metafile. Did the conversion fail somewhere?\n" );
2177 /* Free the data associated with our copy since it's been copied */
2178 HeapFree( GetProcessHeap(), 0, lpNewEnhMetaFileBuffer
);