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"
44 #include "wine/debug.h"
46 WINE_DEFAULT_DEBUG_CHANNEL(enhmetafile);
52 BOOL on_disk; /* true if metafile is on disk */
56 /****************************************************************************
57 * EMF_Create_HENHMETAFILE
59 HENHMETAFILE EMF_Create_HENHMETAFILE(ENHMETAHEADER *emh, BOOL on_disk )
62 ENHMETAFILEOBJ *metaObj = GDI_AllocObject( sizeof(ENHMETAFILEOBJ),
63 ENHMETAFILE_MAGIC, &hmf, NULL );
67 metaObj->on_disk = on_disk;
68 GDI_ReleaseObj( hmf );
73 /****************************************************************************
74 * EMF_Delete_HENHMETAFILE
76 static BOOL EMF_Delete_HENHMETAFILE( HENHMETAFILE hmf )
78 ENHMETAFILEOBJ *metaObj = (ENHMETAFILEOBJ *)GDI_GetObjPtr( hmf,
80 if(!metaObj) return FALSE;
83 UnmapViewOfFile( metaObj->emh );
85 HeapFree( GetProcessHeap(), 0, metaObj->emh );
86 return GDI_FreeObject( hmf, metaObj );
89 /******************************************************************
90 * EMF_GetEnhMetaHeader
92 * Returns ptr to ENHMETAHEADER associated with HENHMETAFILE
94 static ENHMETAHEADER *EMF_GetEnhMetaHeader( HENHMETAFILE hmf )
96 ENHMETAHEADER *ret = NULL;
97 ENHMETAFILEOBJ *metaObj = (ENHMETAFILEOBJ *)GDI_GetObjPtr( hmf, ENHMETAFILE_MAGIC );
98 TRACE("hmf %04x -> enhmetaObj %p\n", hmf, metaObj);
102 GDI_ReleaseObj( hmf );
107 /*****************************************************************************
111 static HENHMETAFILE EMF_GetEnhMetaFile( HANDLE hFile )
116 hMapping = CreateFileMappingA( hFile, NULL, PAGE_READONLY, 0, 0, NULL );
117 emh = MapViewOfFile( hMapping, FILE_MAP_READ, 0, 0, 0 );
118 CloseHandle( hMapping );
122 if (emh->iType != EMR_HEADER || emh->dSignature != ENHMETA_SIGNATURE) {
123 WARN("Invalid emf header type 0x%08lx sig 0x%08lx.\n",
124 emh->iType, emh->dSignature);
125 UnmapViewOfFile( emh );
128 return EMF_Create_HENHMETAFILE( emh, TRUE );
132 /*****************************************************************************
133 * GetEnhMetaFileA (GDI32.@)
137 HENHMETAFILE WINAPI GetEnhMetaFileA(
138 LPCSTR lpszMetaFile /* [in] filename of enhanced metafile */
144 hFile = CreateFileA(lpszMetaFile, GENERIC_READ, FILE_SHARE_READ, 0,
145 OPEN_EXISTING, 0, 0);
146 if (hFile == INVALID_HANDLE_VALUE) {
147 WARN("could not open %s\n", lpszMetaFile);
150 hmf = EMF_GetEnhMetaFile( hFile );
151 CloseHandle( hFile );
155 /*****************************************************************************
156 * GetEnhMetaFileW (GDI32.@)
158 HENHMETAFILE WINAPI GetEnhMetaFileW(
159 LPCWSTR lpszMetaFile) /* [in] filename of enhanced metafile */
164 hFile = CreateFileW(lpszMetaFile, GENERIC_READ, FILE_SHARE_READ, 0,
165 OPEN_EXISTING, 0, 0);
166 if (hFile == INVALID_HANDLE_VALUE) {
167 WARN("could not open %s\n", debugstr_w(lpszMetaFile));
170 hmf = EMF_GetEnhMetaFile( hFile );
171 CloseHandle( hFile );
175 /*****************************************************************************
176 * GetEnhMetaFileHeader (GDI32.@)
178 * If buf is NULL, returns the size of buffer required.
179 * Otherwise, copy up to bufsize bytes of enhanced metafile header into
182 UINT WINAPI GetEnhMetaFileHeader(
183 HENHMETAFILE hmf, /* [in] enhanced metafile */
184 UINT bufsize, /* [in] size of buffer */
185 LPENHMETAHEADER buf /* [out] buffer */
191 emh = EMF_GetEnhMetaHeader(hmf);
192 if(!emh) return FALSE;
194 if (!buf) return size;
195 size = min(size, bufsize);
196 memmove(buf, emh, size);
201 /*****************************************************************************
202 * GetEnhMetaFileDescriptionA (GDI32.@)
204 UINT WINAPI GetEnhMetaFileDescriptionA(
205 HENHMETAFILE hmf, /* [in] enhanced metafile */
206 UINT size, /* [in] size of buf */
207 LPSTR buf /* [out] buffer to receive description */
210 LPENHMETAHEADER emh = EMF_GetEnhMetaHeader(hmf);
214 if(!emh) return FALSE;
215 if(emh->nDescription == 0 || emh->offDescription == 0) return 0;
216 descrW = (WCHAR *) ((char *) emh + emh->offDescription);
217 len = WideCharToMultiByte( CP_ACP, 0, descrW, emh->nDescription, NULL, 0, NULL, NULL );
219 if (!buf || !size ) return len;
221 len = min( size, len );
222 WideCharToMultiByte( CP_ACP, 0, descrW, emh->nDescription, buf, len, NULL, NULL );
226 /*****************************************************************************
227 * GetEnhMetaFileDescriptionW (GDI32.@)
229 * Copies the description string of an enhanced metafile into a buffer
232 * If _buf_ is NULL, returns size of _buf_ required. Otherwise, returns
233 * number of characters copied.
235 UINT WINAPI GetEnhMetaFileDescriptionW(
236 HENHMETAFILE hmf, /* [in] enhanced metafile */
237 UINT size, /* [in] size of buf */
238 LPWSTR buf /* [out] buffer to receive description */
241 LPENHMETAHEADER emh = EMF_GetEnhMetaHeader(hmf);
243 if(!emh) return FALSE;
244 if(emh->nDescription == 0 || emh->offDescription == 0) return 0;
245 if (!buf || !size ) return emh->nDescription;
247 memmove(buf, (char *) emh + emh->offDescription, min(size,emh->nDescription)*sizeof(WCHAR));
248 return min(size, emh->nDescription);
251 /****************************************************************************
252 * SetEnhMetaFileBits (GDI32.@)
254 * Creates an enhanced metafile by copying _bufsize_ bytes from _buf_.
256 HENHMETAFILE WINAPI SetEnhMetaFileBits(UINT bufsize, const BYTE *buf)
258 ENHMETAHEADER *emh = HeapAlloc( GetProcessHeap(), 0, bufsize );
259 memmove(emh, buf, bufsize);
260 return EMF_Create_HENHMETAFILE( emh, FALSE );
263 /*****************************************************************************
264 * GetEnhMetaFileBits (GDI32.@)
267 UINT WINAPI GetEnhMetaFileBits(
273 LPENHMETAHEADER emh = EMF_GetEnhMetaHeader( hmf );
279 if( buf == NULL ) return size;
281 size = min( size, bufsize );
282 memmove(buf, emh, size);
286 /*****************************************************************************
287 * PlayEnhMetaFileRecord (GDI32.@)
289 * Render a single enhanced metafile record in the device context hdc.
292 * TRUE (non zero) on success, FALSE on error.
294 * Many unimplemented records.
295 * No error handling on record play failures (ie checking return codes)
297 BOOL WINAPI PlayEnhMetaFileRecord(
298 HDC hdc, /* [in] device context in which to render EMF record */
299 LPHANDLETABLE handletable, /* [in] array of handles to be used in rendering record */
300 const ENHMETARECORD *mr, /* [in] EMF record to render */
301 UINT handles /* [in] size of handle array */
306 "hdc = %08x, handletable = %p, record = %p, numHandles = %d\n",
307 hdc, handletable, mr, handles);
308 if (!mr) return FALSE;
312 TRACE(" type=%d\n", type);
321 PEMRGDICOMMENT lpGdiComment = (PEMRGDICOMMENT)mr;
322 /* In an enhanced metafile, there can be both public and private GDI comments */
323 GdiComment( hdc, lpGdiComment->cbData, lpGdiComment->Data );
328 PEMRSETMAPMODE pSetMapMode = (PEMRSETMAPMODE) mr;
329 SetMapMode(hdc, pSetMapMode->iMode);
334 PEMRSETBKMODE pSetBkMode = (PEMRSETBKMODE) mr;
335 SetBkMode(hdc, pSetBkMode->iMode);
340 PEMRSETBKCOLOR pSetBkColor = (PEMRSETBKCOLOR) mr;
341 SetBkColor(hdc, pSetBkColor->crColor);
344 case EMR_SETPOLYFILLMODE:
346 PEMRSETPOLYFILLMODE pSetPolyFillMode = (PEMRSETPOLYFILLMODE) mr;
347 SetPolyFillMode(hdc, pSetPolyFillMode->iMode);
352 PEMRSETROP2 pSetROP2 = (PEMRSETROP2) mr;
353 SetROP2(hdc, pSetROP2->iMode);
356 case EMR_SETSTRETCHBLTMODE:
358 PEMRSETSTRETCHBLTMODE pSetStretchBltMode = (PEMRSETSTRETCHBLTMODE) mr;
359 SetStretchBltMode(hdc, pSetStretchBltMode->iMode);
362 case EMR_SETTEXTALIGN:
364 PEMRSETTEXTALIGN pSetTextAlign = (PEMRSETTEXTALIGN) mr;
365 SetTextAlign(hdc, pSetTextAlign->iMode);
368 case EMR_SETTEXTCOLOR:
370 PEMRSETTEXTCOLOR pSetTextColor = (PEMRSETTEXTCOLOR) mr;
371 SetTextColor(hdc, pSetTextColor->crColor);
381 PEMRRESTOREDC pRestoreDC = (PEMRRESTOREDC) mr;
382 RestoreDC(hdc, pRestoreDC->iRelative);
385 case EMR_INTERSECTCLIPRECT:
387 PEMRINTERSECTCLIPRECT pClipRect = (PEMRINTERSECTCLIPRECT) mr;
388 IntersectClipRect(hdc, pClipRect->rclClip.left, pClipRect->rclClip.top,
389 pClipRect->rclClip.right, pClipRect->rclClip.bottom);
392 case EMR_SELECTOBJECT:
394 PEMRSELECTOBJECT pSelectObject = (PEMRSELECTOBJECT) mr;
395 if( pSelectObject->ihObject & 0x80000000 ) {
396 /* High order bit is set - it's a stock object
397 * Strip the high bit to get the index.
398 * See MSDN article Q142319
400 SelectObject( hdc, GetStockObject( pSelectObject->ihObject &
403 /* High order bit wasn't set - not a stock object
406 (handletable->objectHandle)[pSelectObject->ihObject] );
410 case EMR_DELETEOBJECT:
412 PEMRDELETEOBJECT pDeleteObject = (PEMRDELETEOBJECT) mr;
413 DeleteObject( (handletable->objectHandle)[pDeleteObject->ihObject]);
414 (handletable->objectHandle)[pDeleteObject->ihObject] = 0;
417 case EMR_SETWINDOWORGEX:
420 * FIXME: The call to SetWindowOrgEx prevents EMFs from being scrolled
421 * by an application. This is very BAD!!!
424 PEMRSETWINDOWORGEX pSetWindowOrgEx = (PEMRSETWINDOWORGEX) mr;
425 SetWindowOrgEx(hdc, pSetWindowOrgEx->ptlOrigin.x,
426 pSetWindowOrgEx->ptlOrigin.y, NULL);
430 case EMR_SETWINDOWEXTEX:
432 PEMRSETWINDOWEXTEX pSetWindowExtEx = (PEMRSETWINDOWEXTEX) mr;
433 SetWindowExtEx(hdc, pSetWindowExtEx->szlExtent.cx,
434 pSetWindowExtEx->szlExtent.cy, NULL);
437 case EMR_SETVIEWPORTORGEX:
439 PEMRSETVIEWPORTORGEX pSetViewportOrgEx = (PEMRSETVIEWPORTORGEX) mr;
440 SetViewportOrgEx(hdc, pSetViewportOrgEx->ptlOrigin.x,
441 pSetViewportOrgEx->ptlOrigin.y, NULL);
444 case EMR_SETVIEWPORTEXTEX:
446 PEMRSETVIEWPORTEXTEX pSetViewportExtEx = (PEMRSETVIEWPORTEXTEX) mr;
447 SetViewportExtEx(hdc, pSetViewportExtEx->szlExtent.cx,
448 pSetViewportExtEx->szlExtent.cy, NULL);
453 PEMRCREATEPEN pCreatePen = (PEMRCREATEPEN) mr;
454 (handletable->objectHandle)[pCreatePen->ihPen] =
455 CreatePenIndirect(&pCreatePen->lopn);
458 case EMR_EXTCREATEPEN:
460 PEMREXTCREATEPEN pPen = (PEMREXTCREATEPEN) mr;
462 lb.lbStyle = pPen->elp.elpBrushStyle;
463 lb.lbColor = pPen->elp.elpColor;
464 lb.lbHatch = pPen->elp.elpHatch;
466 if(pPen->offBmi || pPen->offBits)
467 FIXME("EMR_EXTCREATEPEN: Need to copy brush bitmap\n");
469 (handletable->objectHandle)[pPen->ihPen] =
470 ExtCreatePen(pPen->elp.elpPenStyle, pPen->elp.elpWidth, &lb,
471 pPen->elp.elpNumEntries, pPen->elp.elpStyleEntry);
474 case EMR_CREATEBRUSHINDIRECT:
476 PEMRCREATEBRUSHINDIRECT pBrush = (PEMRCREATEBRUSHINDIRECT) mr;
477 (handletable->objectHandle)[pBrush->ihBrush] =
478 CreateBrushIndirect(&pBrush->lb);
481 case EMR_EXTCREATEFONTINDIRECTW:
483 PEMREXTCREATEFONTINDIRECTW pFont = (PEMREXTCREATEFONTINDIRECTW) mr;
484 (handletable->objectHandle)[pFont->ihFont] =
485 CreateFontIndirectW(&pFont->elfw.elfLogFont);
490 PEMRMOVETOEX pMoveToEx = (PEMRMOVETOEX) mr;
491 MoveToEx(hdc, pMoveToEx->ptl.x, pMoveToEx->ptl.y, NULL);
496 PEMRLINETO pLineTo = (PEMRLINETO) mr;
497 LineTo(hdc, pLineTo->ptl.x, pLineTo->ptl.y);
502 PEMRRECTANGLE pRect = (PEMRRECTANGLE) mr;
503 Rectangle(hdc, pRect->rclBox.left, pRect->rclBox.top,
504 pRect->rclBox.right, pRect->rclBox.bottom);
509 PEMRELLIPSE pEllipse = (PEMRELLIPSE) mr;
510 Ellipse(hdc, pEllipse->rclBox.left, pEllipse->rclBox.top,
511 pEllipse->rclBox.right, pEllipse->rclBox.bottom);
516 PEMRPOLYGON16 pPoly = (PEMRPOLYGON16) mr;
517 /* Shouldn't use Polygon16 since pPoly->cpts is DWORD */
518 POINT *pts = HeapAlloc( GetProcessHeap(), 0,
519 pPoly->cpts * sizeof(POINT) );
521 for(i = 0; i < pPoly->cpts; i++)
522 CONV_POINT16TO32(pPoly->apts + i, pts + i);
523 Polygon(hdc, pts, pPoly->cpts);
524 HeapFree( GetProcessHeap(), 0, pts );
529 PEMRPOLYLINE16 pPoly = (PEMRPOLYLINE16) mr;
530 /* Shouldn't use Polyline16 since pPoly->cpts is DWORD */
531 POINT *pts = HeapAlloc( GetProcessHeap(), 0,
532 pPoly->cpts * sizeof(POINT) );
534 for(i = 0; i < pPoly->cpts; i++)
535 CONV_POINT16TO32(pPoly->apts + i, pts + i);
536 Polyline(hdc, pts, pPoly->cpts);
537 HeapFree( GetProcessHeap(), 0, pts );
540 case EMR_POLYLINETO16:
542 PEMRPOLYLINETO16 pPoly = (PEMRPOLYLINETO16) mr;
543 /* Shouldn't use PolylineTo16 since pPoly->cpts is DWORD */
544 POINT *pts = HeapAlloc( GetProcessHeap(), 0,
545 pPoly->cpts * sizeof(POINT) );
547 for(i = 0; i < pPoly->cpts; i++)
548 CONV_POINT16TO32(pPoly->apts + i, pts + i);
549 PolylineTo(hdc, pts, pPoly->cpts);
550 HeapFree( GetProcessHeap(), 0, pts );
553 case EMR_POLYBEZIER16:
555 PEMRPOLYBEZIER16 pPoly = (PEMRPOLYBEZIER16) mr;
556 /* Shouldn't use PolyBezier16 since pPoly->cpts is DWORD */
557 POINT *pts = HeapAlloc( GetProcessHeap(), 0,
558 pPoly->cpts * sizeof(POINT) );
560 for(i = 0; i < pPoly->cpts; i++)
561 CONV_POINT16TO32(pPoly->apts + i, pts + i);
562 PolyBezier(hdc, pts, pPoly->cpts);
563 HeapFree( GetProcessHeap(), 0, pts );
566 case EMR_POLYBEZIERTO16:
568 PEMRPOLYBEZIERTO16 pPoly = (PEMRPOLYBEZIERTO16) mr;
569 /* Shouldn't use PolyBezierTo16 since pPoly->cpts is DWORD */
570 POINT *pts = HeapAlloc( GetProcessHeap(), 0,
571 pPoly->cpts * sizeof(POINT) );
573 for(i = 0; i < pPoly->cpts; i++)
574 CONV_POINT16TO32(pPoly->apts + i, pts + i);
575 PolyBezierTo(hdc, pts, pPoly->cpts);
576 HeapFree( GetProcessHeap(), 0, pts );
579 case EMR_POLYPOLYGON16:
581 PEMRPOLYPOLYGON16 pPolyPoly = (PEMRPOLYPOLYGON16) mr;
582 /* NB POINTS array doesn't start at pPolyPoly->apts it's actually
583 pPolyPoly->aPolyCounts + pPolyPoly->nPolys */
585 POINT *pts = HeapAlloc( GetProcessHeap(), 0,
586 pPolyPoly->cpts * sizeof(POINT) );
588 for(i = 0; i < pPolyPoly->cpts; i++)
589 CONV_POINT16TO32((POINT16*) (pPolyPoly->aPolyCounts +
590 pPolyPoly->nPolys) + i, pts + i);
592 PolyPolygon(hdc, pts, (INT*)pPolyPoly->aPolyCounts, pPolyPoly->nPolys);
593 HeapFree( GetProcessHeap(), 0, pts );
596 case EMR_POLYPOLYLINE16:
598 PEMRPOLYPOLYLINE16 pPolyPoly = (PEMRPOLYPOLYLINE16) mr;
599 /* NB POINTS array doesn't start at pPolyPoly->apts it's actually
600 pPolyPoly->aPolyCounts + pPolyPoly->nPolys */
602 POINT *pts = HeapAlloc( GetProcessHeap(), 0,
603 pPolyPoly->cpts * sizeof(POINT) );
605 for(i = 0; i < pPolyPoly->cpts; i++)
606 CONV_POINT16TO32((POINT16*) (pPolyPoly->aPolyCounts +
607 pPolyPoly->nPolys) + i, pts + i);
609 PolyPolyline(hdc, pts, pPolyPoly->aPolyCounts, pPolyPoly->nPolys);
610 HeapFree( GetProcessHeap(), 0, pts );
614 case EMR_STRETCHDIBITS:
616 EMRSTRETCHDIBITS *pStretchDIBits = (EMRSTRETCHDIBITS *)mr;
619 pStretchDIBits->xDest,
620 pStretchDIBits->yDest,
621 pStretchDIBits->cxDest,
622 pStretchDIBits->cyDest,
623 pStretchDIBits->xSrc,
624 pStretchDIBits->ySrc,
625 pStretchDIBits->cxSrc,
626 pStretchDIBits->cySrc,
627 (BYTE *)mr + pStretchDIBits->offBitsSrc,
628 (const BITMAPINFO *)((BYTE *)mr + pStretchDIBits->offBmiSrc),
629 pStretchDIBits->iUsageSrc,
630 pStretchDIBits->dwRop);
634 case EMR_EXTTEXTOUTA:
636 PEMREXTTEXTOUTA pExtTextOutA = (PEMREXTTEXTOUTA)mr;
639 rc.left = pExtTextOutA->emrtext.rcl.left;
640 rc.top = pExtTextOutA->emrtext.rcl.top;
641 rc.right = pExtTextOutA->emrtext.rcl.right;
642 rc.bottom = pExtTextOutA->emrtext.rcl.bottom;
643 ExtTextOutA(hdc, pExtTextOutA->emrtext.ptlReference.x, pExtTextOutA->emrtext.ptlReference.y,
644 pExtTextOutA->emrtext.fOptions, &rc,
645 (LPSTR)((BYTE *)mr + pExtTextOutA->emrtext.offString), pExtTextOutA->emrtext.nChars,
646 (INT *)((BYTE *)mr + pExtTextOutA->emrtext.offDx));
650 case EMR_EXTTEXTOUTW:
652 PEMREXTTEXTOUTW pExtTextOutW = (PEMREXTTEXTOUTW)mr;
655 rc.left = pExtTextOutW->emrtext.rcl.left;
656 rc.top = pExtTextOutW->emrtext.rcl.top;
657 rc.right = pExtTextOutW->emrtext.rcl.right;
658 rc.bottom = pExtTextOutW->emrtext.rcl.bottom;
659 ExtTextOutW(hdc, pExtTextOutW->emrtext.ptlReference.x, pExtTextOutW->emrtext.ptlReference.y,
660 pExtTextOutW->emrtext.fOptions, &rc,
661 (LPWSTR)((BYTE *)mr + pExtTextOutW->emrtext.offString), pExtTextOutW->emrtext.nChars,
662 (INT *)((BYTE *)mr + pExtTextOutW->emrtext.offDx));
666 case EMR_CREATEPALETTE:
668 PEMRCREATEPALETTE lpCreatePal = (PEMRCREATEPALETTE)mr;
670 (handletable->objectHandle)[ lpCreatePal->ihPal ] =
671 CreatePalette( &lpCreatePal->lgpl );
676 case EMR_SELECTPALETTE:
678 PEMRSELECTPALETTE lpSelectPal = (PEMRSELECTPALETTE)mr;
680 if( lpSelectPal->ihPal & 0x80000000 ) {
681 SelectPalette( hdc, GetStockObject(lpSelectPal->ihPal & 0x7fffffff), TRUE);
683 (handletable->objectHandle)[ lpSelectPal->ihPal ] =
684 SelectPalette( hdc, (handletable->objectHandle)[lpSelectPal->ihPal], TRUE);
689 case EMR_REALIZEPALETTE:
691 RealizePalette( hdc );
695 case EMR_EXTSELECTCLIPRGN:
697 PEMREXTSELECTCLIPRGN lpRgn = (PEMREXTSELECTCLIPRGN)mr;
698 HRGN hRgn = ExtCreateRegion(NULL, lpRgn->cbRgnData, (RGNDATA *)lpRgn->RgnData);
699 ExtSelectClipRgn(hdc, hRgn, (INT)(lpRgn->iMode));
700 /* ExtSelectClipRgn created a copy of the region */
711 case EMR_SETWORLDTRANSFORM:
713 PEMRSETWORLDTRANSFORM lpXfrm = (PEMRSETWORLDTRANSFORM)mr;
714 SetWorldTransform( hdc, &lpXfrm->xform );
720 PEMRPOLYBEZIER lpPolyBez = (PEMRPOLYBEZIER)mr;
721 PolyBezier(hdc, (const LPPOINT)lpPolyBez->aptl, (UINT)lpPolyBez->cptl);
727 PEMRPOLYGON lpPoly = (PEMRPOLYGON)mr;
728 Polygon( hdc, (const LPPOINT)lpPoly->aptl, (UINT)lpPoly->cptl );
734 PEMRPOLYLINE lpPolyLine = (PEMRPOLYLINE)mr;
735 Polyline(hdc, (const LPPOINT)lpPolyLine->aptl, (UINT)lpPolyLine->cptl);
739 case EMR_POLYBEZIERTO:
741 PEMRPOLYBEZIERTO lpPolyBezierTo = (PEMRPOLYBEZIERTO)mr;
742 PolyBezierTo( hdc, (const LPPOINT)lpPolyBezierTo->aptl,
743 (UINT)lpPolyBezierTo->cptl );
749 PEMRPOLYLINETO lpPolyLineTo = (PEMRPOLYLINETO)mr;
750 PolylineTo( hdc, (const LPPOINT)lpPolyLineTo->aptl,
751 (UINT)lpPolyLineTo->cptl );
755 case EMR_POLYPOLYLINE:
757 PEMRPOLYPOLYLINE pPolyPolyline = (PEMRPOLYPOLYLINE) mr;
758 /* NB Points at pPolyPolyline->aPolyCounts + pPolyPolyline->nPolys */
760 PolyPolyline(hdc, (LPPOINT)(pPolyPolyline->aPolyCounts +
761 pPolyPolyline->nPolys),
762 pPolyPolyline->aPolyCounts,
763 pPolyPolyline->nPolys );
768 case EMR_POLYPOLYGON:
770 PEMRPOLYPOLYGON pPolyPolygon = (PEMRPOLYPOLYGON) mr;
772 /* NB Points at pPolyPolygon->aPolyCounts + pPolyPolygon->nPolys */
774 PolyPolygon(hdc, (LPPOINT)(pPolyPolygon->aPolyCounts +
775 pPolyPolygon->nPolys),
776 (INT*)pPolyPolygon->aPolyCounts, pPolyPolygon->nPolys );
780 case EMR_SETBRUSHORGEX:
782 PEMRSETBRUSHORGEX lpSetBrushOrgEx = (PEMRSETBRUSHORGEX)mr;
785 (INT)lpSetBrushOrgEx->ptlOrigin.x,
786 (INT)lpSetBrushOrgEx->ptlOrigin.y,
794 PEMRSETPIXELV lpSetPixelV = (PEMRSETPIXELV)mr;
797 (INT)lpSetPixelV->ptlPixel.x,
798 (INT)lpSetPixelV->ptlPixel.y,
799 lpSetPixelV->crColor );
804 case EMR_SETMAPPERFLAGS:
806 PEMRSETMAPPERFLAGS lpSetMapperFlags = (PEMRSETMAPPERFLAGS)mr;
808 SetMapperFlags( hdc, lpSetMapperFlags->dwFlags );
813 case EMR_SETCOLORADJUSTMENT:
815 PEMRSETCOLORADJUSTMENT lpSetColorAdjust = (PEMRSETCOLORADJUSTMENT)mr;
817 SetColorAdjustment( hdc, &lpSetColorAdjust->ColorAdjustment );
822 case EMR_OFFSETCLIPRGN:
824 PEMROFFSETCLIPRGN lpOffsetClipRgn = (PEMROFFSETCLIPRGN)mr;
827 (INT)lpOffsetClipRgn->ptlOffset.x,
828 (INT)lpOffsetClipRgn->ptlOffset.y );
833 case EMR_EXCLUDECLIPRECT:
835 PEMREXCLUDECLIPRECT lpExcludeClipRect = (PEMREXCLUDECLIPRECT)mr;
837 ExcludeClipRect( hdc,
838 lpExcludeClipRect->rclClip.left,
839 lpExcludeClipRect->rclClip.top,
840 lpExcludeClipRect->rclClip.right,
841 lpExcludeClipRect->rclClip.bottom );
846 case EMR_SCALEVIEWPORTEXTEX:
848 PEMRSCALEVIEWPORTEXTEX lpScaleViewportExtEx = (PEMRSCALEVIEWPORTEXTEX)mr;
850 ScaleViewportExtEx( hdc,
851 lpScaleViewportExtEx->xNum,
852 lpScaleViewportExtEx->xDenom,
853 lpScaleViewportExtEx->yNum,
854 lpScaleViewportExtEx->yDenom,
860 case EMR_SCALEWINDOWEXTEX:
862 PEMRSCALEWINDOWEXTEX lpScaleWindowExtEx = (PEMRSCALEWINDOWEXTEX)mr;
864 ScaleWindowExtEx( hdc,
865 lpScaleWindowExtEx->xNum,
866 lpScaleWindowExtEx->xDenom,
867 lpScaleWindowExtEx->yNum,
868 lpScaleWindowExtEx->yDenom,
874 case EMR_MODIFYWORLDTRANSFORM:
876 PEMRMODIFYWORLDTRANSFORM lpModifyWorldTrans = (PEMRMODIFYWORLDTRANSFORM)mr;
878 ModifyWorldTransform( hdc, &lpModifyWorldTrans->xform,
879 lpModifyWorldTrans->iMode );
886 PEMRANGLEARC lpAngleArc = (PEMRANGLEARC)mr;
889 (INT)lpAngleArc->ptlCenter.x, (INT)lpAngleArc->ptlCenter.y,
890 lpAngleArc->nRadius, lpAngleArc->eStartAngle,
891 lpAngleArc->eSweepAngle );
898 PEMRROUNDRECT lpRoundRect = (PEMRROUNDRECT)mr;
901 lpRoundRect->rclBox.left,
902 lpRoundRect->rclBox.top,
903 lpRoundRect->rclBox.right,
904 lpRoundRect->rclBox.bottom,
905 lpRoundRect->szlCorner.cx,
906 lpRoundRect->szlCorner.cy );
913 PEMRARC lpArc = (PEMRARC)mr;
916 (INT)lpArc->rclBox.left,
917 (INT)lpArc->rclBox.top,
918 (INT)lpArc->rclBox.right,
919 (INT)lpArc->rclBox.bottom,
920 (INT)lpArc->ptlStart.x,
921 (INT)lpArc->ptlStart.y,
922 (INT)lpArc->ptlEnd.x,
923 (INT)lpArc->ptlEnd.y );
930 PEMRCHORD lpChord = (PEMRCHORD)mr;
933 (INT)lpChord->rclBox.left,
934 (INT)lpChord->rclBox.top,
935 (INT)lpChord->rclBox.right,
936 (INT)lpChord->rclBox.bottom,
937 (INT)lpChord->ptlStart.x,
938 (INT)lpChord->ptlStart.y,
939 (INT)lpChord->ptlEnd.x,
940 (INT)lpChord->ptlEnd.y );
947 PEMRPIE lpPie = (PEMRPIE)mr;
950 (INT)lpPie->rclBox.left,
951 (INT)lpPie->rclBox.top,
952 (INT)lpPie->rclBox.right,
953 (INT)lpPie->rclBox.bottom,
954 (INT)lpPie->ptlStart.x,
955 (INT)lpPie->ptlStart.y,
956 (INT)lpPie->ptlEnd.x,
957 (INT)lpPie->ptlEnd.y );
964 PEMRARC lpArcTo = (PEMRARC)mr;
967 (INT)lpArcTo->rclBox.left,
968 (INT)lpArcTo->rclBox.top,
969 (INT)lpArcTo->rclBox.right,
970 (INT)lpArcTo->rclBox.bottom,
971 (INT)lpArcTo->ptlStart.x,
972 (INT)lpArcTo->ptlStart.y,
973 (INT)lpArcTo->ptlEnd.x,
974 (INT)lpArcTo->ptlEnd.y );
979 case EMR_EXTFLOODFILL:
981 PEMREXTFLOODFILL lpExtFloodFill = (PEMREXTFLOODFILL)mr;
984 (INT)lpExtFloodFill->ptlStart.x,
985 (INT)lpExtFloodFill->ptlStart.y,
986 lpExtFloodFill->crColor,
987 (UINT)lpExtFloodFill->iMode );
994 PEMRPOLYDRAW lpPolyDraw = (PEMRPOLYDRAW)mr;
996 (const LPPOINT)lpPolyDraw->aptl,
998 (INT)lpPolyDraw->cptl );
1003 case EMR_SETARCDIRECTION:
1005 PEMRSETARCDIRECTION lpSetArcDirection = (PEMRSETARCDIRECTION)mr;
1006 SetArcDirection( hdc, (INT)lpSetArcDirection->iArcDirection );
1010 case EMR_SETMITERLIMIT:
1012 PEMRSETMITERLIMIT lpSetMiterLimit = (PEMRSETMITERLIMIT)mr;
1013 SetMiterLimit( hdc, lpSetMiterLimit->eMiterLimit, NULL );
1029 case EMR_CLOSEFIGURE:
1037 /*PEMRFILLPATH lpFillPath = (PEMRFILLPATH)mr;*/
1042 case EMR_STROKEANDFILLPATH:
1044 /*PEMRSTROKEANDFILLPATH lpStrokeAndFillPath = (PEMRSTROKEANDFILLPATH)mr;*/
1045 StrokeAndFillPath( hdc );
1049 case EMR_STROKEPATH:
1051 /*PEMRSTROKEPATH lpStrokePath = (PEMRSTROKEPATH)mr;*/
1056 case EMR_FLATTENPATH:
1068 case EMR_SELECTCLIPPATH:
1070 PEMRSELECTCLIPPATH lpSelectClipPath = (PEMRSELECTCLIPPATH)mr;
1071 SelectClipPath( hdc, (INT)lpSelectClipPath->iMode );
1081 case EMR_CREATECOLORSPACE:
1083 PEMRCREATECOLORSPACE lpCreateColorSpace = (PEMRCREATECOLORSPACE)mr;
1084 (handletable->objectHandle)[lpCreateColorSpace->ihCS] =
1085 CreateColorSpaceA( &lpCreateColorSpace->lcs );
1089 case EMR_SETCOLORSPACE:
1091 PEMRSETCOLORSPACE lpSetColorSpace = (PEMRSETCOLORSPACE)mr;
1093 (handletable->objectHandle)[lpSetColorSpace->ihCS] );
1097 case EMR_DELETECOLORSPACE:
1099 PEMRDELETECOLORSPACE lpDeleteColorSpace = (PEMRDELETECOLORSPACE)mr;
1100 DeleteColorSpace( (handletable->objectHandle)[lpDeleteColorSpace->ihCS] );
1104 case EMR_SETICMMODE:
1106 PERMSETICMMODE lpSetICMMode = (PERMSETICMMODE)mr;
1107 SetICMMode( hdc, (INT)lpSetICMMode->iMode );
1111 case EMR_PIXELFORMAT:
1114 PEMRPIXELFORMAT lpPixelFormat = (PEMRPIXELFORMAT)mr;
1116 iPixelFormat = ChoosePixelFormat( hdc, &lpPixelFormat->pfd );
1117 SetPixelFormat( hdc, iPixelFormat, &lpPixelFormat->pfd );
1122 case EMR_SETPALETTEENTRIES:
1124 PEMRSETPALETTEENTRIES lpSetPaletteEntries = (PEMRSETPALETTEENTRIES)mr;
1126 SetPaletteEntries( (handletable->objectHandle)[lpSetPaletteEntries->ihPal],
1127 (UINT)lpSetPaletteEntries->iStart,
1128 (UINT)lpSetPaletteEntries->cEntries,
1129 lpSetPaletteEntries->aPalEntries );
1134 case EMR_RESIZEPALETTE:
1136 PEMRRESIZEPALETTE lpResizePalette = (PEMRRESIZEPALETTE)mr;
1138 ResizePalette( (handletable->objectHandle)[lpResizePalette->ihPal],
1139 (UINT)lpResizePalette->cEntries );
1144 case EMR_CREATEDIBPATTERNBRUSHPT:
1146 PEMRCREATEDIBPATTERNBRUSHPT lpCreate = (PEMRCREATEDIBPATTERNBRUSHPT)mr;
1148 /* This is a BITMAPINFO struct followed directly by bitmap bits */
1149 LPVOID lpPackedStruct = HeapAlloc( GetProcessHeap(),
1151 lpCreate->cbBmi + lpCreate->cbBits );
1152 /* Now pack this structure */
1153 memcpy( lpPackedStruct,
1154 ((BYTE*)lpCreate) + lpCreate->offBmi,
1156 memcpy( ((BYTE*)lpPackedStruct) + lpCreate->cbBmi,
1157 ((BYTE*)lpCreate) + lpCreate->offBits,
1160 (handletable->objectHandle)[lpCreate->ihBrush] =
1161 CreateDIBPatternBrushPt( lpPackedStruct,
1162 (UINT)lpCreate->iUsage );
1167 case EMR_CREATEMONOBRUSH:
1169 PEMRCREATEMONOBRUSH pCreateMonoBrush = (PEMRCREATEMONOBRUSH)mr;
1170 BITMAPINFO *pbi = (BITMAPINFO *)((BYTE *)mr + pCreateMonoBrush->offBmi);
1171 HBITMAP hBmp = CreateDIBitmap(0, (BITMAPINFOHEADER *)pbi, CBM_INIT,
1172 (BYTE *)mr + pCreateMonoBrush->offBits, pbi, pCreateMonoBrush->iUsage);
1173 (handletable->objectHandle)[pCreateMonoBrush->ihBrush] = CreatePatternBrush(hBmp);
1174 /* CreatePatternBrush created a copy of the bitmap */
1181 PEMRBITBLT pBitBlt = (PEMRBITBLT)mr;
1182 HDC hdcSrc = CreateCompatibleDC(hdc);
1183 HBRUSH hBrush, hBrushOld;
1184 HBITMAP hBmp, hBmpOld;
1185 BITMAPINFO *pbi = (BITMAPINFO *)((BYTE *)mr + pBitBlt->offBmiSrc);
1187 SetWorldTransform(hdcSrc, &pBitBlt->xformSrc);
1189 hBrush = CreateSolidBrush(pBitBlt->crBkColorSrc);
1190 hBrushOld = SelectObject(hdcSrc, hBrush);
1191 PatBlt(hdcSrc, pBitBlt->rclBounds.left, pBitBlt->rclBounds.top,
1192 pBitBlt->rclBounds.right - pBitBlt->rclBounds.left,
1193 pBitBlt->rclBounds.bottom - pBitBlt->rclBounds.top, PATCOPY);
1194 SelectObject(hdcSrc, hBrushOld);
1195 DeleteObject(hBrush);
1197 hBmp = CreateDIBitmap(0, (BITMAPINFOHEADER *)pbi, CBM_INIT,
1198 (BYTE *)mr + pBitBlt->offBitsSrc, pbi, pBitBlt->iUsageSrc);
1199 hBmpOld = SelectObject(hdcSrc, hBmp);
1209 SelectObject(hdcSrc, hBmpOld);
1215 case EMR_STRETCHBLT:
1217 PEMRSTRETCHBLT pStretchBlt= (PEMRSTRETCHBLT)mr;
1218 HDC hdcSrc = CreateCompatibleDC(hdc);
1219 HBRUSH hBrush, hBrushOld;
1220 HBITMAP hBmp, hBmpOld;
1221 BITMAPINFO *pbi = (BITMAPINFO *)((BYTE *)mr + pStretchBlt->offBmiSrc);
1223 SetWorldTransform(hdcSrc, &pStretchBlt->xformSrc);
1225 hBrush = CreateSolidBrush(pStretchBlt->crBkColorSrc);
1226 hBrushOld = SelectObject(hdcSrc, hBrush);
1227 PatBlt(hdcSrc, pStretchBlt->rclBounds.left, pStretchBlt->rclBounds.top,
1228 pStretchBlt->rclBounds.right - pStretchBlt->rclBounds.left,
1229 pStretchBlt->rclBounds.bottom - pStretchBlt->rclBounds.top, PATCOPY);
1230 SelectObject(hdcSrc, hBrushOld);
1231 DeleteObject(hBrush);
1233 hBmp = CreateDIBitmap(0, (BITMAPINFOHEADER *)pbi, CBM_INIT,
1234 (BYTE *)mr + pStretchBlt->offBitsSrc, pbi, pStretchBlt->iUsageSrc);
1235 hBmpOld = SelectObject(hdcSrc, hBmp);
1239 pStretchBlt->cxDest,
1240 pStretchBlt->cyDest,
1246 pStretchBlt->dwRop);
1247 SelectObject(hdcSrc, hBmpOld);
1255 PEMRMASKBLT pMaskBlt= (PEMRMASKBLT)mr;
1256 HDC hdcSrc = CreateCompatibleDC(hdc);
1257 HBRUSH hBrush, hBrushOld;
1258 HBITMAP hBmp, hBmpOld, hBmpMask;
1261 SetWorldTransform(hdcSrc, &pMaskBlt->xformSrc);
1263 hBrush = CreateSolidBrush(pMaskBlt->crBkColorSrc);
1264 hBrushOld = SelectObject(hdcSrc, hBrush);
1265 PatBlt(hdcSrc, pMaskBlt->rclBounds.left, pMaskBlt->rclBounds.top,
1266 pMaskBlt->rclBounds.right - pMaskBlt->rclBounds.left,
1267 pMaskBlt->rclBounds.bottom - pMaskBlt->rclBounds.top, PATCOPY);
1268 SelectObject(hdcSrc, hBrushOld);
1269 DeleteObject(hBrush);
1271 pbi = (BITMAPINFO *)((BYTE *)mr + pMaskBlt->offBmiMask);
1272 hBmpMask = CreateDIBitmap(0, (BITMAPINFOHEADER *)pbi, CBM_INIT,
1273 (BYTE *)mr + pMaskBlt->offBitsMask, pbi, pMaskBlt->iUsageMask);
1275 pbi = (BITMAPINFO *)((BYTE *)mr + pMaskBlt->offBmiSrc);
1276 hBmp = CreateDIBitmap(0, (BITMAPINFOHEADER *)pbi, CBM_INIT,
1277 (BYTE *)mr + pMaskBlt->offBitsSrc, pbi, pMaskBlt->iUsageSrc);
1278 hBmpOld = SelectObject(hdcSrc, hBmp);
1291 SelectObject(hdcSrc, hBmpOld);
1293 DeleteObject(hBmpMask);
1300 PEMRPLGBLT pPlgBlt= (PEMRPLGBLT)mr;
1301 HDC hdcSrc = CreateCompatibleDC(hdc);
1302 HBRUSH hBrush, hBrushOld;
1303 HBITMAP hBmp, hBmpOld, hBmpMask;
1307 SetWorldTransform(hdcSrc, &pPlgBlt->xformSrc);
1309 pts[0].x = pPlgBlt->aptlDst[0].x; pts[0].y = pPlgBlt->aptlDst[0].y;
1310 pts[1].x = pPlgBlt->aptlDst[1].x; pts[1].y = pPlgBlt->aptlDst[1].y;
1311 pts[2].x = pPlgBlt->aptlDst[2].x; pts[2].y = pPlgBlt->aptlDst[2].y;
1313 hBrush = CreateSolidBrush(pPlgBlt->crBkColorSrc);
1314 hBrushOld = SelectObject(hdcSrc, hBrush);
1315 PatBlt(hdcSrc, pPlgBlt->rclBounds.left, pPlgBlt->rclBounds.top,
1316 pPlgBlt->rclBounds.right - pPlgBlt->rclBounds.left,
1317 pPlgBlt->rclBounds.bottom - pPlgBlt->rclBounds.top, PATCOPY);
1318 SelectObject(hdcSrc, hBrushOld);
1319 DeleteObject(hBrush);
1321 pbi = (BITMAPINFO *)((BYTE *)mr + pPlgBlt->offBmiMask);
1322 hBmpMask = CreateDIBitmap(0, (BITMAPINFOHEADER *)pbi, CBM_INIT,
1323 (BYTE *)mr + pPlgBlt->offBitsMask, pbi, pPlgBlt->iUsageMask);
1325 pbi = (BITMAPINFO *)((BYTE *)mr + pPlgBlt->offBmiSrc);
1326 hBmp = CreateDIBitmap(0, (BITMAPINFOHEADER *)pbi, CBM_INIT,
1327 (BYTE *)mr + pPlgBlt->offBitsSrc, pbi, pPlgBlt->iUsageSrc);
1328 hBmpOld = SelectObject(hdcSrc, hBmp);
1339 SelectObject(hdcSrc, hBmpOld);
1341 DeleteObject(hBmpMask);
1346 case EMR_SETDIBITSTODEVICE:
1348 PEMRSETDIBITSTODEVICE pSetDIBitsToDevice = (PEMRSETDIBITSTODEVICE)mr;
1350 SetDIBitsToDevice(hdc,
1351 pSetDIBitsToDevice->xDest,
1352 pSetDIBitsToDevice->yDest,
1353 pSetDIBitsToDevice->cxSrc,
1354 pSetDIBitsToDevice->cySrc,
1355 pSetDIBitsToDevice->xSrc,
1356 pSetDIBitsToDevice->ySrc,
1357 pSetDIBitsToDevice->iStartScan,
1358 pSetDIBitsToDevice->cScans,
1359 (BYTE *)mr + pSetDIBitsToDevice->offBitsSrc,
1360 (BITMAPINFO *)((BYTE *)mr + pSetDIBitsToDevice->offBmiSrc),
1361 pSetDIBitsToDevice->iUsageSrc);
1365 case EMR_POLYTEXTOUTA:
1367 PEMRPOLYTEXTOUTA pPolyTextOutA = (PEMRPOLYTEXTOUTA)mr;
1368 POLYTEXTA *polytextA = HeapAlloc(GetProcessHeap(), 0, pPolyTextOutA->cStrings * sizeof(POLYTEXTA));
1370 XFORM xform, xformOld;
1373 gModeOld = SetGraphicsMode(hdc, pPolyTextOutA->iGraphicsMode);
1374 GetWorldTransform(hdc, &xformOld);
1376 xform.eM11 = pPolyTextOutA->exScale;
1379 xform.eM22 = pPolyTextOutA->eyScale;
1382 SetWorldTransform(hdc, &xform);
1384 /* Set up POLYTEXTA structures */
1385 for(i = 0; i < pPolyTextOutA->cStrings; i++)
1387 polytextA[i].x = pPolyTextOutA->aemrtext[i].ptlReference.x;
1388 polytextA[i].y = pPolyTextOutA->aemrtext[i].ptlReference.y;
1389 polytextA[i].n = pPolyTextOutA->aemrtext[i].nChars;
1390 polytextA[i].lpstr = (LPSTR)((BYTE *)mr + pPolyTextOutA->aemrtext[i].offString);
1391 polytextA[i].uiFlags = pPolyTextOutA->aemrtext[i].fOptions;
1392 polytextA[i].rcl.left = pPolyTextOutA->aemrtext[i].rcl.left;
1393 polytextA[i].rcl.right = pPolyTextOutA->aemrtext[i].rcl.right;
1394 polytextA[i].rcl.top = pPolyTextOutA->aemrtext[i].rcl.top;
1395 polytextA[i].rcl.bottom = pPolyTextOutA->aemrtext[i].rcl.bottom;
1396 polytextA[i].pdx = (int *)((BYTE *)mr + pPolyTextOutA->aemrtext[i].offDx);
1398 PolyTextOutA(hdc, polytextA, pPolyTextOutA->cStrings);
1399 HeapFree(GetProcessHeap(), 0, polytextA);
1401 SetWorldTransform(hdc, &xformOld);
1402 SetGraphicsMode(hdc, gModeOld);
1406 case EMR_POLYTEXTOUTW:
1408 PEMRPOLYTEXTOUTW pPolyTextOutW = (PEMRPOLYTEXTOUTW)mr;
1409 POLYTEXTW *polytextW = HeapAlloc(GetProcessHeap(), 0, pPolyTextOutW->cStrings * sizeof(POLYTEXTW));
1411 XFORM xform, xformOld;
1414 gModeOld = SetGraphicsMode(hdc, pPolyTextOutW->iGraphicsMode);
1415 GetWorldTransform(hdc, &xformOld);
1417 xform.eM11 = pPolyTextOutW->exScale;
1420 xform.eM22 = pPolyTextOutW->eyScale;
1423 SetWorldTransform(hdc, &xform);
1425 /* Set up POLYTEXTW structures */
1426 for(i = 0; i < pPolyTextOutW->cStrings; i++)
1428 polytextW[i].x = pPolyTextOutW->aemrtext[i].ptlReference.x;
1429 polytextW[i].y = pPolyTextOutW->aemrtext[i].ptlReference.y;
1430 polytextW[i].n = pPolyTextOutW->aemrtext[i].nChars;
1431 polytextW[i].lpstr = (LPWSTR)((BYTE *)mr + pPolyTextOutW->aemrtext[i].offString);
1432 polytextW[i].uiFlags = pPolyTextOutW->aemrtext[i].fOptions;
1433 polytextW[i].rcl.left = pPolyTextOutW->aemrtext[i].rcl.left;
1434 polytextW[i].rcl.right = pPolyTextOutW->aemrtext[i].rcl.right;
1435 polytextW[i].rcl.top = pPolyTextOutW->aemrtext[i].rcl.top;
1436 polytextW[i].rcl.bottom = pPolyTextOutW->aemrtext[i].rcl.bottom;
1437 polytextW[i].pdx = (int *)((BYTE *)mr + pPolyTextOutW->aemrtext[i].offDx);
1439 PolyTextOutW(hdc, polytextW, pPolyTextOutW->cStrings);
1440 HeapFree(GetProcessHeap(), 0, polytextW);
1442 SetWorldTransform(hdc, &xformOld);
1443 SetGraphicsMode(hdc, gModeOld);
1449 PEMRFILLRGN pFillRgn = (PEMRFILLRGN)mr;
1450 HRGN hRgn = ExtCreateRegion(NULL, pFillRgn->cbRgnData, (RGNDATA *)pFillRgn->RgnData);
1453 (handletable->objectHandle)[pFillRgn->ihBrush]);
1460 PEMRFRAMERGN pFrameRgn = (PEMRFRAMERGN)mr;
1461 HRGN hRgn = ExtCreateRegion(NULL, pFrameRgn->cbRgnData, (RGNDATA *)pFrameRgn->RgnData);
1464 (handletable->objectHandle)[pFrameRgn->ihBrush],
1465 pFrameRgn->szlStroke.cx,
1466 pFrameRgn->szlStroke.cy);
1473 PEMRINVERTRGN pInvertRgn = (PEMRINVERTRGN)mr;
1474 HRGN hRgn = ExtCreateRegion(NULL, pInvertRgn->cbRgnData, (RGNDATA *)pInvertRgn->RgnData);
1475 InvertRgn(hdc, hRgn);
1482 PEMRPAINTRGN pPaintRgn = (PEMRPAINTRGN)mr;
1483 HRGN hRgn = ExtCreateRegion(NULL, pPaintRgn->cbRgnData, (RGNDATA *)pPaintRgn->RgnData);
1484 PaintRgn(hdc, hRgn);
1489 case EMR_POLYDRAW16:
1491 case EMR_GLSBOUNDEDRECORD:
1493 /* From docs: If PlayEnhMetaFileRecord doesn't recognize a
1494 record then ignore and return TRUE. */
1495 FIXME("type %d is unimplemented\n", type);
1502 /*****************************************************************************
1504 * EnumEnhMetaFile (GDI32.@)
1506 * Walk an enhanced metafile, calling a user-specified function _EnhMetaFunc_
1508 * record. Returns when either every record has been used or
1509 * when _EnhMetaFunc_ returns FALSE.
1513 * TRUE if every record is used, FALSE if any invocation of _EnhMetaFunc_
1519 BOOL WINAPI EnumEnhMetaFile(
1520 HDC hdc, /* [in] device context to pass to _EnhMetaFunc_ */
1521 HENHMETAFILE hmf, /* [in] EMF to walk */
1522 ENHMFENUMPROC callback, /* [in] callback function */
1523 LPVOID data, /* [in] optional data for callback function */
1524 const RECT *lpRect /* [in] bounding rectangle for rendered metafile */
1534 FLOAT xSrcPixSize, ySrcPixSize, xscale, yscale;
1535 XFORM savedXform, xform;
1536 HPEN hPen = (HPEN)NULL;
1537 HBRUSH hBrush = (HBRUSH)NULL;
1538 HFONT hFont = (HFONT)NULL;
1542 SetLastError(ERROR_INVALID_PARAMETER);
1546 emh = EMF_GetEnhMetaHeader(hmf);
1548 SetLastError(ERROR_INVALID_HANDLE);
1552 ht = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
1553 sizeof(HANDLETABLE) * emh->nHandles );
1556 SetLastError(ERROR_NOT_ENOUGH_MEMORY);
1559 ht->objectHandle[0] = hmf;
1563 TRACE("rect: %d,%d - %d,%d. rclFrame: %ld,%ld - %ld,%ld\n",
1564 lpRect->left, lpRect->top, lpRect->right, lpRect->bottom,
1565 emh->rclFrame.left, emh->rclFrame.top, emh->rclFrame.right,
1566 emh->rclFrame.bottom);
1568 xSrcPixSize = (FLOAT) emh->szlMillimeters.cx / emh->szlDevice.cx;
1569 ySrcPixSize = (FLOAT) emh->szlMillimeters.cy / emh->szlDevice.cy;
1570 xscale = (FLOAT)(lpRect->right - lpRect->left) * 100.0 /
1571 (emh->rclFrame.right - emh->rclFrame.left) * xSrcPixSize;
1572 yscale = (FLOAT)(lpRect->bottom - lpRect->top) * 100.0 /
1573 (emh->rclFrame.bottom - emh->rclFrame.top) * ySrcPixSize;
1575 xform.eM11 = xscale;
1578 xform.eM22 = yscale;
1579 xform.eDx = (FLOAT) lpRect->left - (lpRect->right - lpRect->left) *
1580 emh->rclFrame.left / (emh->rclFrame.right - emh->rclFrame.left);
1581 xform.eDy = (FLOAT) lpRect->top - (lpRect->bottom - lpRect->top) *
1582 emh->rclFrame.top / (emh->rclFrame.bottom - emh->rclFrame.top);
1584 savedMode = SetGraphicsMode(hdc, GM_ADVANCED);
1585 GetWorldTransform(hdc, &savedXform);
1587 if (!ModifyWorldTransform(hdc, &xform, MWT_RIGHTMULTIPLY)) {
1588 ERR("World transform failed!\n");
1591 /* save the current pen, brush and font */
1592 hPen = GetCurrentObject(hdc, OBJ_PEN);
1593 hBrush = GetCurrentObject(hdc, OBJ_BRUSH);
1594 hFont = GetCurrentObject(hdc, OBJ_FONT);
1597 TRACE("nSize = %ld, nBytes = %ld, nHandles = %d, nRecords = %ld, nPalEntries = %ld\n",
1598 emh->nSize, emh->nBytes, emh->nHandles, emh->nRecords, emh->nPalEntries);
1602 while(ret && offset < emh->nBytes)
1604 emr = (ENHMETARECORD *)((char *)emh + offset);
1605 TRACE("Calling EnumFunc with record type %ld, size %ld\n", emr->iType, emr->nSize);
1606 ret = (*callback)(hdc, ht, emr, emh->nHandles, data);
1607 offset += emr->nSize;
1612 /* restore pen, brush and font */
1613 SelectObject(hdc, hBrush);
1614 SelectObject(hdc, hPen);
1615 SelectObject(hdc, hFont);
1617 SetWorldTransform(hdc, &savedXform);
1619 SetGraphicsMode(hdc, savedMode);
1622 for(i = 1; i < emh->nHandles; i++) /* Don't delete element 0 (hmf) */
1623 if( (ht->objectHandle)[i] )
1624 DeleteObject( (ht->objectHandle)[i] );
1626 HeapFree( GetProcessHeap(), 0, ht );
1630 static INT CALLBACK EMF_PlayEnhMetaFileCallback(HDC hdc, HANDLETABLE *ht,
1632 INT handles, LPVOID data)
1634 return PlayEnhMetaFileRecord(hdc, ht, emr, handles);
1637 /**************************************************************************
1638 * PlayEnhMetaFile (GDI32.@)
1640 * Renders an enhanced metafile into a specified rectangle *lpRect
1641 * in device context hdc.
1644 BOOL WINAPI PlayEnhMetaFile(
1645 HDC hdc, /* [in] DC to render into */
1646 HENHMETAFILE hmf, /* [in] metafile to render */
1647 const RECT *lpRect /* [in] rectangle to place metafile inside */
1650 return EnumEnhMetaFile(hdc, hmf, EMF_PlayEnhMetaFileCallback, NULL,
1654 /*****************************************************************************
1655 * DeleteEnhMetaFile (GDI32.@)
1657 * Deletes an enhanced metafile and frees the associated storage.
1659 BOOL WINAPI DeleteEnhMetaFile(HENHMETAFILE hmf)
1661 return EMF_Delete_HENHMETAFILE( hmf );
1664 /*****************************************************************************
1665 * CopyEnhMetaFileA (GDI32.@) Duplicate an enhanced metafile
1669 HENHMETAFILE WINAPI CopyEnhMetaFileA(
1670 HENHMETAFILE hmfSrc,
1673 ENHMETAHEADER *emrSrc = EMF_GetEnhMetaHeader( hmfSrc ), *emrDst;
1674 HENHMETAFILE hmfDst;
1676 if(!emrSrc) return FALSE;
1678 emrDst = HeapAlloc( GetProcessHeap(), 0, emrSrc->nBytes );
1679 memcpy( emrDst, emrSrc, emrSrc->nBytes );
1680 hmfDst = EMF_Create_HENHMETAFILE( emrDst, FALSE );
1683 hFile = CreateFileA( file, GENERIC_WRITE | GENERIC_READ, 0, NULL,
1684 CREATE_ALWAYS, 0, 0);
1685 WriteFile( hFile, emrSrc, emrSrc->nBytes, 0, 0);
1686 hmfDst = EMF_GetEnhMetaFile( hFile );
1687 CloseHandle( hFile );
1693 /* Struct to be used to be passed in the LPVOID parameter for cbEnhPaletteCopy */
1694 typedef struct tagEMF_PaletteCopy
1697 LPPALETTEENTRY lpPe;
1700 /***************************************************************
1701 * Find the EMR_EOF record and then use it to find the
1702 * palette entries for this enhanced metafile.
1703 * The lpData is actually a pointer to a EMF_PaletteCopy struct
1704 * which contains the max number of elements to copy and where
1707 * NOTE: To be used by GetEnhMetaFilePaletteEntries only!
1709 INT CALLBACK cbEnhPaletteCopy( HDC a,
1711 LPENHMETARECORD lpEMR,
1716 if ( lpEMR->iType == EMR_EOF )
1718 PEMREOF lpEof = (PEMREOF)lpEMR;
1719 EMF_PaletteCopy* info = (EMF_PaletteCopy*)lpData;
1720 DWORD dwNumPalToCopy = min( lpEof->nPalEntries, info->cEntries );
1722 TRACE( "copying 0x%08lx palettes\n", dwNumPalToCopy );
1724 memcpy( (LPVOID)info->lpPe,
1725 (LPVOID)(((LPSTR)lpEof) + lpEof->offPalEntries),
1726 sizeof( *(info->lpPe) ) * dwNumPalToCopy );
1728 /* Update the passed data as a return code */
1729 info->lpPe = NULL; /* Palettes were copied! */
1730 info->cEntries = (UINT)dwNumPalToCopy;
1732 return FALSE; /* That's all we need */
1738 /*****************************************************************************
1739 * GetEnhMetaFilePaletteEntries (GDI32.@)
1741 * Copy the palette and report size
1743 * BUGS: Error codes (SetLastError) are not set on failures
1745 UINT WINAPI GetEnhMetaFilePaletteEntries( HENHMETAFILE hEmf,
1747 LPPALETTEENTRY lpPe )
1749 ENHMETAHEADER* enhHeader = EMF_GetEnhMetaHeader( hEmf );
1750 EMF_PaletteCopy infoForCallBack;
1752 TRACE( "(%04x,%d,%p)\n", hEmf, cEntries, lpPe );
1754 /* First check if there are any palettes associated with
1756 if ( enhHeader->nPalEntries == 0 ) return 0;
1758 /* Is the user requesting the number of palettes? */
1759 if ( lpPe == NULL ) return (UINT)enhHeader->nPalEntries;
1761 /* Copy cEntries worth of PALETTEENTRY structs into the buffer */
1762 infoForCallBack.cEntries = cEntries;
1763 infoForCallBack.lpPe = lpPe;
1765 if ( !EnumEnhMetaFile( 0, hEmf, cbEnhPaletteCopy,
1766 &infoForCallBack, NULL ) )
1769 /* Verify that the callback executed correctly */
1770 if ( infoForCallBack.lpPe != NULL )
1772 /* Callback proc had error! */
1773 ERR( "cbEnhPaletteCopy didn't execute correctly\n" );
1777 return infoForCallBack.cEntries;
1780 /******************************************************************
1781 * SetWinMetaFileBits (GDI32.@)
1783 * Translate from old style to new style.
1785 * BUGS: - This doesn't take the DC and scaling into account
1786 * - Most record conversions aren't implemented
1787 * - Handle slot assignement is primative and most likely doesn't work
1789 HENHMETAFILE WINAPI SetWinMetaFileBits(UINT cbBuffer,
1790 CONST BYTE *lpbBuffer,
1792 CONST METAFILEPICT *lpmfp
1796 LPVOID lpNewEnhMetaFileBuffer = NULL;
1797 UINT uNewEnhMetaFileBufferSize = 0;
1798 BOOL bFoundEOF = FALSE;
1800 FIXME( "(%d,%p,%04x,%p):stub\n", cbBuffer, lpbBuffer, hdcRef, lpmfp );
1802 /* 1. Get the header - skip over this and get straight to the records */
1804 uNewEnhMetaFileBufferSize = sizeof( ENHMETAHEADER );
1805 lpNewEnhMetaFileBuffer = HeapAlloc( GetProcessHeap(), HEAP_ZERO_MEMORY,
1806 uNewEnhMetaFileBufferSize );
1808 if( lpNewEnhMetaFileBuffer == NULL )
1813 /* Fill in the header record */
1815 LPENHMETAHEADER lpNewEnhMetaFileHeader = (LPENHMETAHEADER)lpNewEnhMetaFileBuffer;
1817 lpNewEnhMetaFileHeader->iType = EMR_HEADER;
1818 lpNewEnhMetaFileHeader->nSize = sizeof( ENHMETAHEADER );
1820 /* FIXME: Not right. Must be able to get this from the DC */
1821 lpNewEnhMetaFileHeader->rclBounds.left = 0;
1822 lpNewEnhMetaFileHeader->rclBounds.right = 0;
1823 lpNewEnhMetaFileHeader->rclBounds.top = 0;
1824 lpNewEnhMetaFileHeader->rclBounds.bottom = 0;
1826 /* FIXME: Not right. Must be able to get this from the DC */
1827 lpNewEnhMetaFileHeader->rclFrame.left = 0;
1828 lpNewEnhMetaFileHeader->rclFrame.right = 0;
1829 lpNewEnhMetaFileHeader->rclFrame.top = 0;
1830 lpNewEnhMetaFileHeader->rclFrame.bottom = 0;
1832 lpNewEnhMetaFileHeader->dSignature=ENHMETA_SIGNATURE;
1833 lpNewEnhMetaFileHeader->nVersion=0x10000;
1834 lpNewEnhMetaFileHeader->nBytes = lpNewEnhMetaFileHeader->nSize;
1835 lpNewEnhMetaFileHeader->sReserved=0;
1837 /* FIXME: if there is a description add it */
1838 lpNewEnhMetaFileHeader->nDescription=0;
1839 lpNewEnhMetaFileHeader->offDescription=0;
1841 lpNewEnhMetaFileHeader->nHandles = 0; /* No handles yet */
1842 lpNewEnhMetaFileHeader->nRecords = 0;
1844 /* I am pretty sure this starts at 0 and grows as entries are added */
1845 lpNewEnhMetaFileHeader->nPalEntries = 0;
1847 /* Size in Pixels */
1848 lpNewEnhMetaFileHeader->szlDevice.cx = GetDeviceCaps(hdcRef,HORZRES);
1849 lpNewEnhMetaFileHeader->szlDevice.cy = GetDeviceCaps(hdcRef,VERTRES);
1852 lpNewEnhMetaFileHeader->szlMillimeters.cx =
1853 GetDeviceCaps(hdcRef,HORZSIZE);
1854 lpNewEnhMetaFileHeader->szlMillimeters.cy =
1855 GetDeviceCaps(hdcRef,VERTSIZE);
1857 /* FIXME: Add in the rest of the fields to the header */
1863 (char*)lpbBuffer += ((METAHEADER*)lpbBuffer)->mtHeaderSize * 2; /* Point past the header - FIXME: metafile quirk? */
1865 /* 2. Enum over individual records and convert them to the new type of records */
1869 LPMETARECORD lpMetaRecord = (LPMETARECORD)lpbBuffer;
1871 #define EMF_ReAllocAndAdjustPointers( a , b ) \
1874 lpTmp = HeapReAlloc( GetProcessHeap(), 0, \
1875 lpNewEnhMetaFileBuffer, \
1876 uNewEnhMetaFileBufferSize + (b) ); \
1877 if( lpTmp == NULL ) { ERR( "No memory!\n" ); goto error; } \
1878 lpNewEnhMetaFileBuffer = lpTmp; \
1879 lpRecord = (a)( (char*)lpNewEnhMetaFileBuffer + uNewEnhMetaFileBufferSize ); \
1880 uNewEnhMetaFileBufferSize += (b); \
1883 switch( lpMetaRecord->rdFunction )
1888 size_t uRecord = sizeof(*lpRecord);
1890 EMF_ReAllocAndAdjustPointers(PEMREOF,uRecord);
1892 /* Fill the new record - FIXME: This is not right */
1893 lpRecord->emr.iType = EMR_EOF;
1894 lpRecord->emr.nSize = sizeof( *lpRecord );
1895 lpRecord->nPalEntries = 0; /* FIXME */
1896 lpRecord->offPalEntries = 0; /* FIXME */
1897 lpRecord->nSizeLast = 0; /* FIXME */
1899 /* No more records after this one */
1902 FIXME( "META_EOF conversion not correct\n" );
1906 case META_SETMAPMODE:
1908 PEMRSETMAPMODE lpRecord;
1909 size_t uRecord = sizeof(*lpRecord);
1911 EMF_ReAllocAndAdjustPointers(PEMRSETMAPMODE,uRecord);
1913 lpRecord->emr.iType = EMR_SETMAPMODE;
1914 lpRecord->emr.nSize = sizeof( *lpRecord );
1916 lpRecord->iMode = lpMetaRecord->rdParm[0];
1921 case META_DELETEOBJECT: /* Select and Delete structures are the same */
1922 case META_SELECTOBJECT:
1924 PEMRDELETEOBJECT lpRecord;
1925 size_t uRecord = sizeof(*lpRecord);
1927 EMF_ReAllocAndAdjustPointers(PEMRDELETEOBJECT,uRecord);
1929 if( lpMetaRecord->rdFunction == META_DELETEOBJECT )
1931 lpRecord->emr.iType = EMR_DELETEOBJECT;
1935 lpRecord->emr.iType = EMR_SELECTOBJECT;
1937 lpRecord->emr.nSize = sizeof( *lpRecord );
1939 lpRecord->ihObject = lpMetaRecord->rdParm[0]; /* FIXME: Handle */
1944 case META_POLYGON: /* This is just plain busted. I don't know what I'm doing */
1946 PEMRPOLYGON16 lpRecord; /* FIXME: Should it be a poly or poly16? */
1947 size_t uRecord = sizeof(*lpRecord);
1949 EMF_ReAllocAndAdjustPointers(PEMRPOLYGON16,uRecord);
1951 /* FIXME: This is mostly all wrong */
1952 lpRecord->emr.iType = EMR_POLYGON16;
1953 lpRecord->emr.nSize = sizeof( *lpRecord );
1955 lpRecord->rclBounds.left = 0;
1956 lpRecord->rclBounds.right = 0;
1957 lpRecord->rclBounds.top = 0;
1958 lpRecord->rclBounds.bottom = 0;
1961 lpRecord->apts[0].x = 0;
1962 lpRecord->apts[0].y = 0;
1964 FIXME( "META_POLYGON conversion not correct\n" );
1969 case META_SETPOLYFILLMODE:
1971 PEMRSETPOLYFILLMODE lpRecord;
1972 size_t uRecord = sizeof(*lpRecord);
1974 EMF_ReAllocAndAdjustPointers(PEMRSETPOLYFILLMODE,uRecord);
1976 lpRecord->emr.iType = EMR_SETPOLYFILLMODE;
1977 lpRecord->emr.nSize = sizeof( *lpRecord );
1979 lpRecord->iMode = lpMetaRecord->rdParm[0];
1984 case META_SETWINDOWORG:
1986 PEMRSETWINDOWORGEX lpRecord; /* Seems to be the closest thing */
1987 size_t uRecord = sizeof(*lpRecord);
1989 EMF_ReAllocAndAdjustPointers(PEMRSETWINDOWORGEX,uRecord);
1991 lpRecord->emr.iType = EMR_SETWINDOWORGEX;
1992 lpRecord->emr.nSize = sizeof( *lpRecord );
1994 lpRecord->ptlOrigin.x = lpMetaRecord->rdParm[1];
1995 lpRecord->ptlOrigin.y = lpMetaRecord->rdParm[0];
2000 case META_SETWINDOWEXT: /* Structure is the same for SETWINDOWEXT & SETVIEWPORTEXT */
2001 case META_SETVIEWPORTEXT:
2003 PEMRSETWINDOWEXTEX lpRecord;
2004 size_t uRecord = sizeof(*lpRecord);
2006 EMF_ReAllocAndAdjustPointers(PEMRSETWINDOWEXTEX,uRecord);
2008 if ( lpMetaRecord->rdFunction == META_SETWINDOWEXT )
2010 lpRecord->emr.iType = EMR_SETWINDOWORGEX;
2014 lpRecord->emr.iType = EMR_SETVIEWPORTEXTEX;
2016 lpRecord->emr.nSize = sizeof( *lpRecord );
2018 lpRecord->szlExtent.cx = lpMetaRecord->rdParm[1];
2019 lpRecord->szlExtent.cy = lpMetaRecord->rdParm[0];
2024 case META_CREATEBRUSHINDIRECT:
2026 PEMRCREATEBRUSHINDIRECT lpRecord;
2027 size_t uRecord = sizeof(*lpRecord);
2029 EMF_ReAllocAndAdjustPointers(PEMRCREATEBRUSHINDIRECT,uRecord);
2031 lpRecord->emr.iType = EMR_CREATEBRUSHINDIRECT;
2032 lpRecord->emr.nSize = sizeof( *lpRecord );
2034 lpRecord->ihBrush = ((LPENHMETAHEADER)lpNewEnhMetaFileBuffer)->nHandles;
2035 lpRecord->lb.lbStyle = ((LPLOGBRUSH16)lpMetaRecord->rdParm)->lbStyle;
2036 lpRecord->lb.lbColor = ((LPLOGBRUSH16)lpMetaRecord->rdParm)->lbColor;
2037 lpRecord->lb.lbHatch = ((LPLOGBRUSH16)lpMetaRecord->rdParm)->lbHatch;
2039 ((LPENHMETAHEADER)lpNewEnhMetaFileBuffer)->nHandles += 1; /* New handle */
2047 PEMRLINETO lpRecord;
2048 size_t uRecord = sizeof(*lpRecord);
2050 EMF_ReAllocAndAdjustPointers(PEMRLINETO,uRecord);
2052 if ( lpMetaRecord->rdFunction == META_LINETO )
2054 lpRecord->emr.iType = EMR_LINETO;
2058 lpRecord->emr.iType = EMR_MOVETOEX;
2060 lpRecord->emr.nSize = sizeof( *lpRecord );
2062 lpRecord->ptl.x = lpMetaRecord->rdParm[1];
2063 lpRecord->ptl.y = lpMetaRecord->rdParm[0];
2068 case META_SETTEXTCOLOR:
2069 case META_SETBKCOLOR:
2071 PEMRSETBKCOLOR lpRecord;
2072 size_t uRecord = sizeof(*lpRecord);
2074 EMF_ReAllocAndAdjustPointers(PEMRSETBKCOLOR,uRecord);
2076 if ( lpMetaRecord->rdFunction == META_SETTEXTCOLOR )
2078 lpRecord->emr.iType = EMR_SETTEXTCOLOR;
2082 lpRecord->emr.iType = EMR_SETBKCOLOR;
2084 lpRecord->emr.nSize = sizeof( *lpRecord );
2086 lpRecord->crColor = MAKELONG(lpMetaRecord->rdParm[0],
2087 lpMetaRecord->rdParm[1]);
2094 /* These are all unimplemented and as such are intended to fall through to the default case */
2095 case META_SETBKMODE:
2097 case META_SETRELABS:
2098 case META_SETSTRETCHBLTMODE:
2099 case META_SETVIEWPORTORG:
2100 case META_OFFSETWINDOWORG:
2101 case META_SCALEWINDOWEXT:
2102 case META_OFFSETVIEWPORTORG:
2103 case META_SCALEVIEWPORTEXT:
2104 case META_EXCLUDECLIPRECT:
2105 case META_INTERSECTCLIPRECT:
2108 case META_FLOODFILL:
2110 case META_RECTANGLE:
2111 case META_ROUNDRECT:
2115 case META_OFFSETCLIPRGN:
2117 case META_POLYPOLYGON:
2119 case META_RESTOREDC:
2121 case META_CREATEPATTERNBRUSH:
2122 case META_CREATEPENINDIRECT:
2123 case META_CREATEFONTINDIRECT:
2124 case META_CREATEPALETTE:
2125 case META_SETTEXTALIGN:
2126 case META_SELECTPALETTE:
2127 case META_SETMAPPERFLAGS:
2128 case META_REALIZEPALETTE:
2130 case META_EXTTEXTOUT:
2131 case META_STRETCHDIB:
2132 case META_DIBSTRETCHBLT:
2133 case META_STRETCHBLT:
2135 case META_CREATEREGION:
2136 case META_FILLREGION:
2137 case META_FRAMEREGION:
2138 case META_INVERTREGION:
2139 case META_PAINTREGION:
2140 case META_SELECTCLIPREGION:
2141 case META_DIBCREATEPATTERNBRUSH:
2142 case META_DIBBITBLT:
2143 case META_SETTEXTCHAREXTRA:
2144 case META_SETTEXTJUSTIFICATION:
2145 case META_EXTFLOODFILL:
2146 case META_SETDIBTODEV:
2148 case META_ANIMATEPALETTE:
2149 case META_SETPALENTRIES:
2150 case META_RESIZEPALETTE:
2153 case META_STARTPAGE:
2157 case META_CREATEBRUSH:
2158 case META_CREATEBITMAPINDIRECT:
2159 case META_CREATEBITMAP:
2160 /* Fall through to unimplemented */
2163 /* Not implemented yet */
2164 FIXME( "Conversion of record type 0x%x not implemented.\n", lpMetaRecord->rdFunction );
2169 /* Move to the next record */
2170 (char*)lpbBuffer += ((LPMETARECORD)lpbBuffer)->rdSize * 2; /* FIXME: Seem to be doing this in metafile.c */
2172 #undef ReAllocAndAdjustPointers
2175 /* We know the last of the header information now */
2176 ((LPENHMETAHEADER)lpNewEnhMetaFileBuffer)->nBytes = uNewEnhMetaFileBufferSize;
2178 /* Create the enhanced metafile */
2179 hMf = SetEnhMetaFileBits( uNewEnhMetaFileBufferSize, (const BYTE*)lpNewEnhMetaFileBuffer );
2182 ERR( "Problem creating metafile. Did the conversion fail somewhere?\n" );
2187 /* Free the data associated with our copy since it's been copied */
2188 HeapFree( GetProcessHeap(), 0, lpNewEnhMetaFileBuffer );