ReactOS  0.4.14-dev-608-gd495a4f
metafile.c File Reference
#include "config.h"
#include <stdarg.h>
#include <string.h>
#include <fcntl.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winreg.h"
#include "winnls.h"
#include "winternl.h"
#include "gdi_private.h"
#include "wine/debug.h"
#include "pshpack1.h"
#include "poppack.h"
Include dependency graph for metafile.c:

Go to the source code of this file.

Classes

struct  METAHEADERDISK
 

Macros

#define META_UNIMP(x)
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (metafile)
 
static int MF_AddHandle (HANDLETABLE *ht, UINT htlen, HGDIOBJ hobj)
 
HMETAFILE MF_Create_HMETAFILE (METAHEADER *mh)
 
static POINTconvert_points (UINT count, const POINTS *pts)
 
BOOL WINAPI DeleteMetaFile (HMETAFILE hmf)
 
static METAHEADERMF_ReadMetaFile (HANDLE hfile)
 
HMETAFILE WINAPI GetMetaFileA (LPCSTR lpFilename)
 
HMETAFILE WINAPI GetMetaFileW (LPCWSTR lpFilename)
 
static METAHEADERMF_LoadDiskBasedMetaFile (METAHEADER *mh)
 
METAHEADERMF_CreateMetaHeaderDisk (METAHEADER *mh, LPCVOID filename, BOOL uni)
 
static METAHEADERget_metafile_bits (HMETAFILE hmf)
 
HMETAFILE WINAPI CopyMetaFileW (HMETAFILE hSrcMetaFile, LPCWSTR lpFilename)
 
HMETAFILE WINAPI CopyMetaFileA (HMETAFILE hSrcMetaFile, LPCSTR lpFilename)
 
BOOL WINAPI PlayMetaFile (HDC hdc, HMETAFILE hmf)
 
BOOL WINAPI EnumMetaFile (HDC hdc, HMETAFILE hmf, MFENUMPROC lpEnumFunc, LPARAM lpData)
 
static BOOL MF_Play_MetaCreateRegion (METARECORD *mr, HRGN hrgn)
 
static BOOL MF_Play_MetaExtTextOut (HDC hdc, METARECORD *mr)
 
BOOL WINAPI PlayMetaFileRecord (HDC hdc, HANDLETABLE *ht, METARECORD *mr, UINT handles)
 
HMETAFILE WINAPI SetMetaFileBitsEx (UINT size, const BYTE *lpData)
 
UINT WINAPI GetMetaFileBitsEx (HMETAFILE hmf, UINT nSize, LPVOID buf)
 
static BOOL add_mf_comment (HDC hdc, HENHMETAFILE emf)
 
static INT muldiv (INT m1, INT m2, INT d)
 
static BOOL set_window (HDC hdc, HENHMETAFILE emf, HDC ref_dc, INT map_mode)
 
UINT WINAPI GetWinMetaFileBits (HENHMETAFILE hemf, UINT cbBuffer, LPBYTE lpbBuffer, INT map_mode, HDC hdcRef)
 

Macro Definition Documentation

◆ META_UNIMP

#define META_UNIMP (   x)
Value:
case x: \
FIXME("PlayMetaFileRecord:record type "#x" not implemented.\n"); \
break;
GLint GLint GLint GLint GLint x
Definition: gl.h:1548

Function Documentation

◆ add_mf_comment()

static BOOL add_mf_comment ( HDC  hdc,
HENHMETAFILE  emf 
)
static

Definition at line 1129 of file metafile.c.

1130 {
1131  DWORD size = GetEnhMetaFileBits(emf, 0, NULL), i;
1132  BYTE *bits, *chunk_data;
1134  BOOL ret = FALSE;
1135  static const DWORD max_chunk_size = 0x2000;
1136 
1137  if(!size) return FALSE;
1138  chunk_data = bits = HeapAlloc(GetProcessHeap(), 0, size);
1139  if(!bits) return FALSE;
1140  if(!GetEnhMetaFileBits(emf, size, bits)) goto end;
1141 
1142  chunk = HeapAlloc(GetProcessHeap(), 0, FIELD_OFFSET(emf_in_wmf_comment, emf_data[max_chunk_size]));
1143  if(!chunk) goto end;
1144 
1145  chunk->magic = WMFC_MAGIC;
1146  chunk->unk04 = 1;
1147  chunk->unk06 = 0;
1148  chunk->unk08 = 0;
1149  chunk->unk0a = 1;
1150  chunk->checksum = 0; /* We fixup the first chunk's checksum before returning from GetWinMetaFileBits */
1151  chunk->unk0e = 0;
1152  chunk->num_chunks = (size + max_chunk_size - 1) / max_chunk_size;
1153  chunk->chunk_size = max_chunk_size;
1154  chunk->remaining_size = size;
1155  chunk->emf_size = size;
1156 
1157  for(i = 0; i < chunk->num_chunks; i++)
1158  {
1159  if(i == chunk->num_chunks - 1) /* last chunk */
1160  chunk->chunk_size = chunk->remaining_size;
1161 
1162  chunk->remaining_size -= chunk->chunk_size;
1163  memcpy(chunk->emf_data, chunk_data, chunk->chunk_size);
1164  chunk_data += chunk->chunk_size;
1165 
1166  if(!Escape(hdc, MFCOMMENT, FIELD_OFFSET(emf_in_wmf_comment, emf_data[chunk->chunk_size]), (char*)chunk, NULL))
1167  goto end;
1168  }
1169  ret = TRUE;
1170 end:
1171  HeapFree(GetProcessHeap(), 0, chunk);
1172  HeapFree(GetProcessHeap(), 0, bits);
1173  return ret;
1174 }
#define TRUE
Definition: types.h:120
STRING Escape(const STRING &str)
Definition: fontsub.cpp:1030
#define WMFC_MAGIC
Definition: gdi_private.h:135
GLuint GLuint end
Definition: gl.h:1545
#define MFCOMMENT
Definition: wingdi.h:1007
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
UINT WINAPI GetEnhMetaFileBits(_In_ HENHMETAFILE hEMF, _In_ UINT nSize, _Out_writes_bytes_opt_(nSize) LPBYTE lpData)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
unsigned long DWORD
Definition: ntddk_ex.h:95
int ret
HDC hdc
Definition: main.c:9
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by GetWinMetaFileBits().

◆ convert_points()

static POINT* convert_points ( UINT  count,
const POINTS pts 
)
static

Definition at line 118 of file metafile.c.

119 {
120  UINT i;
121  POINT *ret = HeapAlloc( GetProcessHeap(), 0, count * sizeof(*ret) );
122  if (ret)
123  {
124  for (i = 0; i < count; i++)
125  {
126  ret[i].x = pts[i].x;
127  ret[i].y = pts[i].y;
128  }
129  }
130  return ret;
131 }
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
SHORT x
Definition: windef.h:342
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
int ret
SHORT y
Definition: windef.h:343
unsigned int UINT
Definition: ndis.h:50

Referenced by PlayMetaFileRecord().

◆ CopyMetaFileA()

HMETAFILE WINAPI CopyMetaFileA ( HMETAFILE  hSrcMetaFile,
LPCSTR  lpFilename 
)

Definition at line 352 of file metafile.c.

353 {
354  UNICODE_STRING lpFilenameW;
355  HMETAFILE ret = 0;
356 
357  if (lpFilename) RtlCreateUnicodeStringFromAsciiz(&lpFilenameW, lpFilename);
358  else lpFilenameW.Buffer = NULL;
359 
360  ret = CopyMetaFileW( hSrcMetaFile, lpFilenameW.Buffer );
361  if (lpFilenameW.Buffer)
362  RtlFreeUnicodeString(&lpFilenameW);
363  return ret;
364 }
smooth NULL
Definition: ftsmooth.c:416
NTSYSAPI BOOLEAN NTAPI RtlCreateUnicodeStringFromAsciiz(_Out_ PUNICODE_STRING Destination, _In_ PCSZ Source)
NTSYSAPI VOID NTAPI RtlFreeUnicodeString(PUNICODE_STRING UnicodeString)
int ret
HMETAFILE WINAPI CopyMetaFileW(HMETAFILE hSrcMetaFile, LPCWSTR lpFilename)
Definition: metafile.c:323

Referenced by test_CopyMetaFile().

◆ CopyMetaFileW()

HMETAFILE WINAPI CopyMetaFileW ( HMETAFILE  hSrcMetaFile,
LPCWSTR  lpFilename 
)

Definition at line 323 of file metafile.c.

324 {
325  METAHEADER *mh = get_metafile_bits( hSrcMetaFile );
326  HANDLE hFile;
327 
328  TRACE("(%p,%s)\n", hSrcMetaFile, debugstr_w(lpFilename));
329 
330  if(!mh) return 0;
331 
332  if(lpFilename) { /* disk based metafile */
333  DWORD w;
334  if((hFile = CreateFileW(lpFilename, GENERIC_WRITE, 0, NULL,
335  CREATE_ALWAYS, 0, 0)) == INVALID_HANDLE_VALUE) {
336  HeapFree( GetProcessHeap(), 0, mh );
337  return 0;
338  }
339  WriteFile(hFile, mh, mh->mtSize * 2, &w, NULL);
341  }
342 
343  return MF_Create_HMETAFILE( mh );
344 }
BOOL WINAPI WriteFile(IN HANDLE hFile, IN LPCVOID lpBuffer, IN DWORD nNumberOfBytesToWrite OPTIONAL, OUT LPDWORD lpNumberOfBytesWritten, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:24
#define CloseHandle
Definition: compat.h:406
DWORD mtSize
Definition: wingdi.h:2312
GLubyte GLubyte GLubyte GLubyte w
Definition: glext.h:6102
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
static METAHEADER * get_metafile_bits(HMETAFILE hmf)
Definition: metafile.c:289
#define GENERIC_WRITE
Definition: nt_native.h:90
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
unsigned long DWORD
Definition: ntddk_ex.h:95
_In_ HANDLE hFile
Definition: mswsock.h:90
#define CREATE_ALWAYS
Definition: disk.h:72
#define CreateFileW
Definition: compat.h:408
HMETAFILE MF_Create_HMETAFILE(METAHEADER *mh)
Definition: metafile.c:107
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by CopyMetaFileA().

◆ DeleteMetaFile()

BOOL WINAPI DeleteMetaFile ( HMETAFILE  hmf)

Definition at line 139 of file metafile.c.

140 {
141  METAHEADER *mh = free_gdi_handle( hmf );
142  if (!mh) return FALSE;
143  return HeapFree( GetProcessHeap(), 0, mh );
144 }
#define GetProcessHeap()
Definition: compat.h:403
void * free_gdi_handle(HGDIOBJ handle) DECLSPEC_HIDDEN
Definition: rosglue.c:248
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by create_converted_emf(), GdipCreateMetafileFromWmf(), GetWinMetaFileBits(), test_CopyMetaFile(), test_gdiis(), test_mf_Blank(), test_mf_clipping(), test_mf_DCBrush(), test_mf_ExtTextOut_on_path(), test_mf_GetPath(), test_mf_Graphics(), test_mf_PatternBrush(), test_mf_SaveDC(), test_SetMetaFileBits(), and test_SetWinMetaFileBits().

◆ EnumMetaFile()

BOOL WINAPI EnumMetaFile ( HDC  hdc,
HMETAFILE  hmf,
MFENUMPROC  lpEnumFunc,
LPARAM  lpData 
)

Definition at line 464 of file metafile.c.

465 {
466  METAHEADER *mh = get_metafile_bits( hmf );
467  METARECORD *mr;
468  HANDLETABLE *ht;
469  BOOL result = TRUE;
470  int i;
471  unsigned int offset = 0;
472  HPEN hPen;
473  HBRUSH hBrush;
474  HFONT hFont;
475 
476  TRACE("(%p,%p,%p,%lx)\n", hdc, hmf, lpEnumFunc, lpData);
477 
478  if (!mh) return FALSE;
479 
480  /* save the current pen, brush and font */
481  hPen = GetCurrentObject(hdc, OBJ_PEN);
482  hBrush = GetCurrentObject(hdc, OBJ_BRUSH);
484 
486  sizeof(HANDLETABLE) * mh->mtNoObjects);
487 
488  /* loop through metafile records */
489  offset = mh->mtHeaderSize * 2;
490 
491  while (offset < (mh->mtSize * 2))
492  {
493  mr = (METARECORD *)((char *)mh + offset);
494  if(mr->rdFunction == META_EOF) {
495  TRACE("Got META_EOF so stopping\n");
496  break;
497  }
498  TRACE("Calling EnumFunc with record type %x\n",
499  mr->rdFunction);
500  if (!lpEnumFunc( hdc, ht, mr, mh->mtNoObjects, lpData ))
501  {
502  result = FALSE;
503  break;
504  }
505 
506  offset += (mr->rdSize * 2);
507  }
508 
509  /* restore pen, brush and font */
510  SelectObject(hdc, hBrush);
511  SelectObject(hdc, hPen);
513 
514  /* free objects in handle table */
515  for(i = 0; i < mh->mtNoObjects; i++)
516  if(*(ht->objectHandle + i) != 0)
517  DeleteObject(*(ht->objectHandle + i));
518 
519  HeapFree( GetProcessHeap(), 0, ht);
520  HeapFree( GetProcessHeap(), 0, mh);
521  return result;
522 }
#define TRUE
Definition: types.h:120
DWORD mtSize
Definition: wingdi.h:2312
GLintptr offset
Definition: glext.h:5920
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
WORD rdFunction
Definition: wingdi.h:2345
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
DWORD rdSize
Definition: wingdi.h:2344
HFONT hFont
Definition: main.c:53
#define OBJ_PEN
Definition: objidl.idl:1409
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static METAHEADER * get_metafile_bits(HMETAFILE hmf)
Definition: metafile.c:289
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
WORD mtHeaderSize
Definition: wingdi.h:2310
#define OBJ_FONT
Definition: objidl.idl:1414
HDC hdc
Definition: main.c:9
#define OBJ_BRUSH
Definition: objidl.idl:1410
WORD mtNoObjects
Definition: wingdi.h:2313
static const struct newhuff ht[]
Definition: huffman.h:296
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
GLuint64EXT * result
Definition: glext.h:11304
#define HeapFree(x, y, z)
Definition: compat.h:402
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:439
#define META_EOF
Definition: gdi_private.h:32

Referenced by create_converted_emf(), test_CopyMetaFile(), test_mf_Blank(), test_mf_clipping(), test_mf_DCBrush(), test_mf_ExtTextOut_on_path(), test_mf_GetPath(), test_mf_Graphics(), test_mf_PatternBrush(), and test_SetMetaFileBits().

◆ get_metafile_bits()

static METAHEADER* get_metafile_bits ( HMETAFILE  hmf)
static

Definition at line 289 of file metafile.c.

290 {
291  METAHEADER *ret, *mh = GDI_GetObjPtr( hmf, OBJ_METAFILE );
292 
293  if (!mh) return NULL;
294 
295  if (mh->mtType != METAFILE_DISK)
296  {
297  ret = HeapAlloc( GetProcessHeap(), 0, mh->mtSize * 2 );
298  if (ret) memcpy( ret, mh, mh->mtSize * 2 );
299  }
300  else ret = MF_LoadDiskBasedMetaFile( mh );
301 
302  GDI_ReleaseObj( hmf );
303  return ret;
304 }
#define METAFILE_DISK
Definition: gdi32p.h:77
DWORD mtSize
Definition: wingdi.h:2312
void GDI_ReleaseObj(HGDIOBJ) DECLSPEC_HIDDEN
Definition: rosglue.c:289
WORD mtType
Definition: wingdi.h:2309
smooth NULL
Definition: ftsmooth.c:416
#define OBJ_METAFILE
Definition: objidl.idl:1417
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
static METAHEADER * MF_LoadDiskBasedMetaFile(METAHEADER *mh)
Definition: metafile.c:243
int ret
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
void * GDI_GetObjPtr(HGDIOBJ, WORD) DECLSPEC_HIDDEN
Definition: rosglue.c:255

Referenced by CopyMetaFileW(), EnumMetaFile(), and PlayMetaFile().

◆ GetMetaFileA()

HMETAFILE WINAPI GetMetaFileA ( LPCSTR  lpFilename)

Definition at line 194 of file metafile.c.

195 {
196  METAHEADER *mh;
197  HANDLE hFile;
198 
199  TRACE("%s\n", lpFilename);
200 
201  if(!lpFilename)
202  return 0;
203 
204  if((hFile = CreateFileA(lpFilename, GENERIC_READ, FILE_SHARE_READ, NULL,
206  return 0;
207 
208  mh = MF_ReadMetaFile(hFile);
210  if(!mh) return 0;
211  return MF_Create_HMETAFILE( mh );
212 }
#define CloseHandle
Definition: compat.h:406
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
#define FILE_SHARE_READ
Definition: compat.h:125
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:434
#define TRACE(s)
Definition: solgame.cpp:4
#define GENERIC_READ
Definition: compat.h:124
_In_ HANDLE hFile
Definition: mswsock.h:90
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:407
HMETAFILE MF_Create_HMETAFILE(METAHEADER *mh)
Definition: metafile.c:107
static METAHEADER * MF_ReadMetaFile(HANDLE hfile)
Definition: metafile.c:152

◆ GetMetaFileBitsEx()

UINT WINAPI GetMetaFileBitsEx ( HMETAFILE  hmf,
UINT  nSize,
LPVOID  buf 
)

Definition at line 1091 of file metafile.c.

1092 {
1093  METAHEADER *mh = GDI_GetObjPtr( hmf, OBJ_METAFILE );
1094  UINT mfSize;
1095  BOOL mf_copy = FALSE;
1096 
1097  TRACE("(%p,%d,%p)\n", hmf, nSize, buf);
1098  if (!mh) return 0; /* FIXME: error code */
1099  if(mh->mtType == METAFILE_DISK)
1100  {
1101  mh = MF_LoadDiskBasedMetaFile( mh );
1102  if (!mh)
1103  {
1104  GDI_ReleaseObj( hmf );
1105  return 0;
1106  }
1107  mf_copy = TRUE;
1108  }
1109  mfSize = mh->mtSize * 2;
1110  if (buf)
1111  {
1112  if(mfSize > nSize) mfSize = nSize;
1113  memmove(buf, mh, mfSize);
1114  }
1115  if (mf_copy) HeapFree( GetProcessHeap(), 0, mh );
1116  GDI_ReleaseObj( hmf );
1117  TRACE("returning size %d\n", mfSize);
1118  return mfSize;
1119 }
#define METAFILE_DISK
Definition: gdi32p.h:77
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
#define TRUE
Definition: types.h:120
DWORD mtSize
Definition: wingdi.h:2312
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2031
void GDI_ReleaseObj(HGDIOBJ) DECLSPEC_HIDDEN
Definition: rosglue.c:289
WORD mtType
Definition: wingdi.h:2309
unsigned int BOOL
Definition: ntddk_ex.h:94
#define OBJ_METAFILE
Definition: objidl.idl:1417
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
static METAHEADER * MF_LoadDiskBasedMetaFile(METAHEADER *mh)
Definition: metafile.c:243
unsigned int UINT
Definition: ndis.h:50
void * GDI_GetObjPtr(HGDIOBJ, WORD) DECLSPEC_HIDDEN
Definition: rosglue.c:255
#define HeapFree(x, y, z)
Definition: compat.h:402

Referenced by compare_mf_bits(), create_converted_emf(), dump_mf_bits(), GdiConvertMetaFilePict(), GdipCreateMetafileFromWmf(), GetWinMetaFileBits(), and test_SetWinMetaFileBits().

◆ GetMetaFileW()

HMETAFILE WINAPI GetMetaFileW ( LPCWSTR  lpFilename)

Definition at line 217 of file metafile.c.

218 {
219  METAHEADER *mh;
220  HANDLE hFile;
221 
222  TRACE("%s\n", debugstr_w(lpFilename));
223 
224  if(!lpFilename)
225  return 0;
226 
227  if((hFile = CreateFileW(lpFilename, GENERIC_READ, FILE_SHARE_READ, NULL,
229  return 0;
230 
231  mh = MF_ReadMetaFile(hFile);
233  if(!mh) return 0;
234  return MF_Create_HMETAFILE( mh );
235 }
#define CloseHandle
Definition: compat.h:406
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
#define FILE_SHARE_READ
Definition: compat.h:125
#define debugstr_w
Definition: kernel32.h:32
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:434
#define TRACE(s)
Definition: solgame.cpp:4
#define GENERIC_READ
Definition: compat.h:124
_In_ HANDLE hFile
Definition: mswsock.h:90
#define CreateFileW
Definition: compat.h:408
HMETAFILE MF_Create_HMETAFILE(METAHEADER *mh)
Definition: metafile.c:107
static METAHEADER * MF_ReadMetaFile(HANDLE hfile)
Definition: metafile.c:152

Referenced by GdipCreateMetafileFromWmfFile().

◆ GetWinMetaFileBits()

UINT WINAPI GetWinMetaFileBits ( HENHMETAFILE  hemf,
UINT  cbBuffer,
LPBYTE  lpbBuffer,
INT  map_mode,
HDC  hdcRef 
)

Definition at line 1259 of file metafile.c.

1262 {
1263  HDC hdcmf;
1264  HMETAFILE hmf;
1265  UINT ret, full_size;
1266  RECT rc;
1267 
1268  GetClipBox(hdcRef, &rc);
1269 
1270  TRACE("(%p,%d,%p,%d,%p) rc=%s\n", hemf, cbBuffer, lpbBuffer,
1271  map_mode, hdcRef, wine_dbgstr_rect(&rc));
1272 
1273  hdcmf = CreateMetaFileW(NULL);
1274 
1275  add_mf_comment(hdcmf, hemf);
1276  SetMapMode(hdcmf, map_mode);
1277  if(!set_window(hdcmf, hemf, hdcRef, map_mode))
1278  goto error;
1279 
1280  PlayEnhMetaFile(hdcmf, hemf, &rc);
1281  hmf = CloseMetaFile(hdcmf);
1282  full_size = GetMetaFileBitsEx(hmf, 0, NULL);
1283  ret = GetMetaFileBitsEx(hmf, cbBuffer, lpbBuffer);
1284  DeleteMetaFile(hmf);
1285 
1286  if(ret && ret == full_size && lpbBuffer) /* fixup checksum, but only if retrieving all of the bits */
1287  {
1288  WORD checksum = 0;
1289  METARECORD *comment_rec = (METARECORD*)(lpbBuffer + sizeof(METAHEADER));
1290  UINT i;
1291 
1292  for(i = 0; i < full_size / 2; i++)
1293  checksum += ((WORD*)lpbBuffer)[i];
1294  comment_rec->rdParm[8] = ~checksum + 1;
1295  }
1296  return ret;
1297 
1298 error:
1299  DeleteMetaFile(CloseMetaFile(hdcmf));
1300  return 0;
1301 }
BOOL WINAPI DeleteMetaFile(HMETAFILE hmf)
Definition: metafile.c:139
#define error(str)
Definition: mkdosfs.c:1605
HDC WINAPI CreateMetaFileW(_In_opt_ LPCWSTR)
static HDC
Definition: imagelist.c:92
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
int WINAPI SetMapMode(_In_ HDC, _In_ int)
static BOOL add_mf_comment(HDC hdc, HENHMETAFILE emf)
Definition: metafile.c:1129
smooth NULL
Definition: ftsmooth.c:416
UINT WINAPI GetMetaFileBitsEx(HMETAFILE hmf, UINT nSize, LPVOID buf)
Definition: metafile.c:1091
HMETAFILE WINAPI CloseMetaFile(_In_ HDC hdc)
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI PlayEnhMetaFile(_In_ HDC, _In_ HENHMETAFILE, _In_ LPCRECT)
const char * wine_dbgstr_rect(const RECT *rect)
unsigned short WORD
Definition: ntddk_ex.h:93
int WINAPI GetClipBox(_In_ HDC, _Out_ LPRECT)
int ret
static cab_ULONG checksum(const cab_UBYTE *data, cab_UWORD bytes, cab_ULONG csum)
Definition: fdi.c:353
WORD rdParm[1]
Definition: wingdi.h:2346
unsigned int UINT
Definition: ndis.h:50
static BOOL set_window(HDC hdc, HENHMETAFILE emf, HDC ref_dc, INT map_mode)
Definition: metafile.c:1203

Referenced by GdiCreateLocalMetaFilePict(), and getwinmetafilebits().

◆ MF_AddHandle()

static int MF_AddHandle ( HANDLETABLE ht,
UINT  htlen,
HGDIOBJ  hobj 
)
static

Definition at line 84 of file metafile.c.

85 {
86  int i;
87 
88  for (i = 0; i < htlen; i++)
89  {
90  if (*(ht->objectHandle + i) == 0)
91  {
92  *(ht->objectHandle + i) = hobj;
93  return i;
94  }
95  }
96  return -1;
97 }
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static const struct newhuff ht[]
Definition: huffman.h:296

Referenced by PlayMetaFileRecord().

◆ MF_Create_HMETAFILE()

HMETAFILE MF_Create_HMETAFILE ( METAHEADER mh)

Definition at line 107 of file metafile.c.

108 {
109  return alloc_gdi_handle( mh, OBJ_METAFILE, NULL );
110 }
HGDIOBJ alloc_gdi_handle(void *obj, WORD type, const struct gdi_obj_funcs *funcs) DECLSPEC_HIDDEN
smooth NULL
Definition: ftsmooth.c:416
#define OBJ_METAFILE
Definition: objidl.idl:1417

Referenced by CloseMetaFile(), CopyMetaFileW(), GetMetaFileA(), GetMetaFileW(), and SetMetaFileBitsEx().

◆ MF_CreateMetaHeaderDisk()

METAHEADER* MF_CreateMetaHeaderDisk ( METAHEADER mh,
LPCVOID  filename,
BOOL  uni 
)

Definition at line 271 of file metafile.c.

272 {
273  METAHEADERDISK *mhd;
274 
275  mh = HeapReAlloc( GetProcessHeap(), 0, mh,
276  sizeof(METAHEADER) + sizeof(METAHEADERDISK));
277  mh->mtType = METAFILE_DISK;
278  mhd = (METAHEADERDISK *)((char *)mh + sizeof(METAHEADER));
279 
280  if( uni )
282  mhd->filename, sizeof mhd->filename, NULL, NULL);
283  else
284  lstrcpynA( mhd->filename, filename, sizeof mhd->filename );
285  return mh;
286 }
#define METAFILE_DISK
Definition: gdi32p.h:77
#define WideCharToMultiByte
Definition: compat.h:101
#define CP_ACP
Definition: compat.h:99
struct tagMETAHEADER METAHEADER
CHAR filename[0x100]
Definition: metafile.c:74
const char * filename
Definition: ioapi.h:135
WORD mtType
Definition: wingdi.h:2309
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:403
#define HeapReAlloc
Definition: compat.h:401
#define lstrcpynA
Definition: compat.h:416

Referenced by CreateMetaFileW().

◆ MF_LoadDiskBasedMetaFile()

static METAHEADER* MF_LoadDiskBasedMetaFile ( METAHEADER mh)
static

Definition at line 243 of file metafile.c.

244 {
245  METAHEADERDISK *mhd;
246  HANDLE hfile;
247  METAHEADER *mh2;
248 
249  if(mh->mtType != METAFILE_DISK) {
250  ERR("Not a disk based metafile\n");
251  return NULL;
252  }
253  mhd = (METAHEADERDISK *)((char *)mh + sizeof(METAHEADER));
254 
256  OPEN_EXISTING, 0, 0)) == INVALID_HANDLE_VALUE) {
257  WARN("Can't open file of disk based metafile\n");
258  return NULL;
259  }
260  mh2 = MF_ReadMetaFile(hfile);
261  CloseHandle(hfile);
262  return mh2;
263 }
#define METAFILE_DISK
Definition: gdi32p.h:77
#define CloseHandle
Definition: compat.h:406
#define WARN(fmt,...)
Definition: debug.h:111
struct tagMETAHEADER METAHEADER
CHAR filename[0x100]
Definition: metafile.c:74
#define INVALID_HANDLE_VALUE
Definition: compat.h:399
#define FILE_SHARE_READ
Definition: compat.h:125
WORD mtType
Definition: wingdi.h:2309
smooth NULL
Definition: ftsmooth.c:416
#define OPEN_EXISTING
Definition: compat.h:434
#define GENERIC_READ
Definition: compat.h:124
#define ERR(fmt,...)
Definition: debug.h:109
#define CreateFileA(a, b, c, d, e, f, g)
Definition: compat.h:407
static METAHEADER * MF_ReadMetaFile(HANDLE hfile)
Definition: metafile.c:152

Referenced by get_metafile_bits(), and GetMetaFileBitsEx().

◆ MF_Play_MetaCreateRegion()

static BOOL MF_Play_MetaCreateRegion ( METARECORD mr,
HRGN  hrgn 
)
static

Definition at line 1333 of file metafile.c.

1334 {
1335  WORD band, pair;
1336  WORD *start, *end;
1337  INT16 y0, y1;
1338  HRGN hrgn2 = CreateRectRgn( 0, 0, 0, 0 );
1339 
1340  for(band = 0, start = &(mr->rdParm[11]); band < mr->rdParm[5];
1341  band++, start = end + 1) {
1342  if(*start / 2 != (*start + 1) / 2) {
1343  WARN("Delimiter not even.\n");
1344  DeleteObject( hrgn2 );
1345  return FALSE;
1346  }
1347 
1348  end = start + *start + 3;
1349  if(end > (WORD *)mr + mr->rdSize) {
1350  WARN("End points outside record.\n");
1351  DeleteObject( hrgn2 );
1352  return FALSE;
1353  }
1354 
1355  if(*start != *end) {
1356  WARN("Mismatched delimiters.\n");
1357  DeleteObject( hrgn2 );
1358  return FALSE;
1359  }
1360 
1361  y0 = *(INT16 *)(start + 1);
1362  y1 = *(INT16 *)(start + 2);
1363  for(pair = 0; pair < *start / 2; pair++) {
1364  SetRectRgn( hrgn2, *(INT16 *)(start + 3 + 2*pair), y0,
1365  *(INT16 *)(start + 4 + 2*pair), y1 );
1367  }
1368  }
1369  DeleteObject( hrgn2 );
1370  return TRUE;
1371  }
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
_In_ CLIPOBJ _In_ BRUSHOBJ _In_ LONG _In_ LONG y1
Definition: winddi.h:3706
#define TRUE
Definition: types.h:120
static HRGN hrgn2
#define WARN(fmt,...)
Definition: debug.h:111
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
GLuint GLuint end
Definition: gl.h:1545
DWORD rdSize
Definition: wingdi.h:2344
#define RGN_OR
Definition: wingdi.h:358
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI SetRectRgn(_In_ HRGN, _In_ int, _In_ int, _In_ int, _In_ int)
unsigned short WORD
Definition: ntddk_ex.h:93
struct _pair * pair
static HRGN hrgn
Definition: win.c:55
WORD rdParm[1]
Definition: wingdi.h:2346
GLuint start
Definition: gl.h:1545
GLint y0
Definition: linetemp.h:96
Definition: _pair.h:47
signed short INT16

Referenced by PlayMetaFileRecord().

◆ MF_Play_MetaExtTextOut()

static BOOL MF_Play_MetaExtTextOut ( HDC  hdc,
METARECORD mr 
)
static

Definition at line 1380 of file metafile.c.

1381 {
1382  INT *dx = NULL;
1383  int i;
1384  SHORT *dxx;
1385  LPSTR sot;
1386  DWORD len;
1387  WORD s1;
1388  RECT rect;
1389  BOOL isrect = mr->rdParm[3] & (ETO_OPAQUE | ETO_CLIPPED);
1390 
1391  s1 = mr->rdParm[2]; /* String length */
1392  len = sizeof(METARECORD) + (((s1 + 1) >> 1) * 2) + 2 * sizeof(short)
1393  + sizeof(UINT16) + (isrect ? 4 * sizeof(SHORT) : 0);
1394  /* rec len without dx array */
1395 
1396  sot = (LPSTR)&mr->rdParm[4]; /* start_of_text */
1397  if (isrect)
1398  {
1399  rect.left = (SHORT)mr->rdParm[4];
1400  rect.top = (SHORT)mr->rdParm[5];
1401  rect.right = (SHORT)mr->rdParm[6];
1402  rect.bottom = (SHORT)mr->rdParm[7];
1403  sot += 4 * sizeof(SHORT); /* there is a rectangle, so add offset */
1404  }
1405 
1406  if (mr->rdSize == len / 2)
1407  dxx = NULL; /* determine if array is present */
1408  else
1409  if (mr->rdSize == (len + s1 * sizeof(INT16)) / 2)
1410  {
1411  dxx = (SHORT *)(sot+(((s1+1)>>1)*2));
1412  dx = HeapAlloc( GetProcessHeap(), 0, s1*sizeof(INT));
1413  if (dx) for (i = 0; i < s1; i++) dx[i] = dxx[i];
1414  }
1415  else {
1416  TRACE("%s len: %d\n", sot, mr->rdSize);
1417  WARN("Please report: ExtTextOut len=%d slen=%d rdSize=%d opt=%04x\n",
1418  len, s1, mr->rdSize, mr->rdParm[3]);
1419  dxx = NULL; /* shouldn't happen -- but if, we continue with NULL */
1420  }
1421  ExtTextOutA( hdc,
1422  (SHORT)mr->rdParm[1], /* X position */
1423  (SHORT)mr->rdParm[0], /* Y position */
1424  mr->rdParm[3], /* options */
1425  &rect, /* rectangle */
1426  sot, /* string */
1427  s1, dx); /* length, dx array */
1428  if (dx)
1429  {
1430  TRACE("%s len: %d dx0: %d\n", sot, mr->rdSize, dx[0]);
1431  HeapFree( GetProcessHeap(), 0, dx );
1432  }
1433  return TRUE;
1434 }
#define TRUE
Definition: types.h:120
#define WARN(fmt,...)
Definition: debug.h:111
char * LPSTR
Definition: xmlstorage.h:182
struct tagMETARECORD METARECORD
int32_t INT
Definition: typedefs.h:56
DWORD rdSize
Definition: wingdi.h:2344
& rect
Definition: startmenu.cpp:1413
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define ETO_OPAQUE
Definition: wingdi.h:646
unsigned int BOOL
Definition: ntddk_ex.h:94
short SHORT
Definition: pedump.c:59
smooth NULL
Definition: ftsmooth.c:416
#define ETO_CLIPPED
Definition: wingdi.h:647
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
if(!(yy_init))
Definition: macro.lex.yy.c:714
struct S1 s1
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned long DWORD
Definition: ntddk_ex.h:95
HDC hdc
Definition: main.c:9
GLenum GLsizei len
Definition: glext.h:6722
WORD rdParm[1]
Definition: wingdi.h:2346
unsigned short UINT16
GLint dx
Definition: linetemp.h:97
BOOL WINAPI ExtTextOutA(_In_ HDC hdc, _In_ int x, _In_ int y, _In_ UINT options, _In_opt_ const RECT *lprect, _In_reads_opt_(c) LPCSTR lpString, _In_ UINT c, _In_reads_opt_(c) const INT *lpDx)
#define HeapFree(x, y, z)
Definition: compat.h:402
signed short INT16

Referenced by PlayMetaFileRecord().

◆ MF_ReadMetaFile()

static METAHEADER* MF_ReadMetaFile ( HANDLE  hfile)
static

Definition at line 152 of file metafile.c.

153 {
154  METAHEADER *mh;
156 
157  size = sizeof(METAHEADER);
158  mh = HeapAlloc( GetProcessHeap(), 0, size );
159  if(!mh) return NULL;
160  if(ReadFile( hfile, mh, size, &BytesRead, NULL) == 0 ||
161  BytesRead != size) {
162  HeapFree( GetProcessHeap(), 0, mh );
163  return NULL;
164  }
165  if (mh->mtType != METAFILE_MEMORY || mh->mtVersion != MFVERSION ||
166  mh->mtHeaderSize != size / 2)
167  {
168  HeapFree( GetProcessHeap(), 0, mh );
169  return NULL;
170  }
171  size = mh->mtSize * 2;
172  mh = HeapReAlloc( GetProcessHeap(), 0, mh, size );
173  if(!mh) return NULL;
174  size -= sizeof(METAHEADER);
175  if(ReadFile( hfile, (char *)mh + sizeof(METAHEADER), size, &BytesRead,
176  NULL) == 0 ||
177  BytesRead != size) {
178  HeapFree( GetProcessHeap(), 0, mh );
179  return NULL;
180  }
181 
182  if (mh->mtType != METAFILE_MEMORY) {
183  WARN("Disk metafile had mtType = %04x\n", mh->mtType);
184  mh->mtType = METAFILE_MEMORY;
185  }
186  return mh;
187 }
DWORD mtSize
Definition: wingdi.h:2312
#define WARN(fmt,...)
Definition: debug.h:111
struct tagMETAHEADER METAHEADER
WORD mtType
Definition: wingdi.h:2309
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
WORD mtHeaderSize
Definition: wingdi.h:2310
unsigned long DWORD
Definition: ntddk_ex.h:95
WORD mtVersion
Definition: wingdi.h:2311
#define HeapReAlloc
Definition: compat.h:401
#define METAFILE_MEMORY
Definition: gdi32p.h:76
BOOL WINAPI ReadFile(IN HANDLE hFile, IN LPVOID lpBuffer, IN DWORD nNumberOfBytesToRead, OUT LPDWORD lpNumberOfBytesRead OPTIONAL, IN LPOVERLAPPED lpOverlapped OPTIONAL)
Definition: rw.c:123
#define HeapFree(x, y, z)
Definition: compat.h:402
_Must_inspect_result_ _In_ PFILE_OBJECT _In_opt_ PLARGE_INTEGER _In_ ULONG _In_ FLT_IO_OPERATION_FLAGS _Out_opt_ PULONG BytesRead
Definition: fltkernel.h:1255
#define MFVERSION
Definition: gdi_private.h:38

Referenced by GetMetaFileA(), GetMetaFileW(), and MF_LoadDiskBasedMetaFile().

◆ muldiv()

static INT muldiv ( INT  m1,
INT  m2,
INT  d 
)
static

Definition at line 1182 of file metafile.c.

1183 {
1184  LONGLONG ret;
1185 
1186  ret = ((LONGLONG)m1 * m2 + d/2) / d; /* Always add d/2 even if ret will be -ve */
1187 
1188  if((LONGLONG)m1 * m2 * 2 == (2 * ret - 1) * d) /* If the answer is exactly n.5 round towards zero */
1189  {
1190  if(ret > 0) ret--;
1191  else ret++;
1192  }
1193  return ret;
1194 }
int64_t LONGLONG
Definition: typedefs.h:66
#define d
Definition: ke_i.h:81
int ret

Referenced by set_window().

◆ PlayMetaFile()

BOOL WINAPI PlayMetaFile ( HDC  hdc,
HMETAFILE  hmf 
)

Definition at line 380 of file metafile.c.

381 {
382  METAHEADER *mh = get_metafile_bits( hmf );
383  METARECORD *mr;
384  HANDLETABLE *ht;
385  unsigned int offset = 0;
386  WORD i;
387  HPEN hPen;
388  HBRUSH hBrush;
389  HPALETTE hPal;
390  HRGN hRgn;
391 
392  if (!mh) return FALSE;
393 
394  /* save DC */
395  hPen = GetCurrentObject(hdc, OBJ_PEN);
396  hBrush = GetCurrentObject(hdc, OBJ_BRUSH);
397  hPal = GetCurrentObject(hdc, OBJ_PAL);
398 
399  hRgn = CreateRectRgn(0, 0, 0, 0);
400  if (!GetClipRgn(hdc, hRgn))
401  {
403  hRgn = 0;
404  }
405 
406  /* create the handle table */
408  sizeof(HANDLETABLE) * mh->mtNoObjects);
409  if(!ht)
410  {
411  HeapFree( GetProcessHeap(), 0, mh );
412  return FALSE;
413  }
414 
415  /* loop through metafile playing records */
416  offset = mh->mtHeaderSize * 2;
417  while (offset < mh->mtSize * 2)
418  {
419  mr = (METARECORD *)((char *)mh + offset);
420  TRACE("offset=%04x,size=%08x\n",
421  offset, mr->rdSize);
422  if (mr->rdSize < 3) { /* catch illegal record sizes */
423  TRACE("Entry got size %d at offset %d, total mf length is %d\n",
424  mr->rdSize,offset,mh->mtSize*2);
425  break;
426  }
427 
428  offset += mr->rdSize * 2;
429  if (mr->rdFunction == META_EOF) {
430  TRACE("Got META_EOF so stopping\n");
431  break;
432  }
433  PlayMetaFileRecord( hdc, ht, mr, mh->mtNoObjects );
434  }
435 
436  /* restore DC */
437  SelectObject(hdc, hPen);
438  SelectObject(hdc, hBrush);
439  SelectPalette(hdc, hPal, FALSE);
442 
443  /* free objects in handle table */
444  for(i = 0; i < mh->mtNoObjects; i++)
445  if(*(ht->objectHandle + i) != 0)
446  DeleteObject(*(ht->objectHandle + i));
447 
448  HeapFree( GetProcessHeap(), 0, ht );
449  HeapFree( GetProcessHeap(), 0, mh );
450  return TRUE;
451 }
#define TRUE
Definition: types.h:120
DWORD mtSize
Definition: wingdi.h:2312
GLintptr offset
Definition: glext.h:5920
static HRGN hRgn
Definition: mapping.c:33
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
WORD rdFunction
Definition: wingdi.h:2345
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
DWORD rdSize
Definition: wingdi.h:2344
#define OBJ_PEN
Definition: objidl.idl:1409
int WINAPI ExtSelectClipRgn(_In_ HDC, _In_opt_ HRGN, _In_ int)
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
static METAHEADER * get_metafile_bits(HMETAFILE hmf)
Definition: metafile.c:289
HPALETTE WINAPI SelectPalette(_In_ HDC, _In_ HPALETTE, _In_ BOOL)
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
WORD mtHeaderSize
Definition: wingdi.h:2310
unsigned short WORD
Definition: ntddk_ex.h:93
#define OBJ_PAL
Definition: objidl.idl:1413
HDC hdc
Definition: main.c:9
#define RGN_COPY
Definition: wingdi.h:356
#define OBJ_BRUSH
Definition: objidl.idl:1410
WORD mtNoObjects
Definition: wingdi.h:2313
static const struct newhuff ht[]
Definition: huffman.h:296
#define HEAP_ZERO_MEMORY
Definition: compat.h:123
BOOL WINAPI PlayMetaFileRecord(HDC hdc, HANDLETABLE *ht, METARECORD *mr, UINT handles)
Definition: metafile.c:540
int WINAPI GetClipRgn(_In_ HDC, _In_ HRGN)
#define HeapFree(x, y, z)
Definition: compat.h:402
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:439
#define META_EOF
Definition: gdi_private.h:32

◆ PlayMetaFileRecord()

BOOL WINAPI PlayMetaFileRecord ( HDC  hdc,
HANDLETABLE ht,
METARECORD mr,
UINT  handles 
)

Definition at line 540 of file metafile.c.

541 {
542  short s1;
543  POINT *pt;
544  BITMAPINFOHEADER *infohdr;
545 
546  TRACE("(%p %p %p %u) function %04x\n", hdc, ht, mr, handles, mr->rdFunction);
547 
548  switch (mr->rdFunction)
549  {
550  case META_EOF:
551  break;
552 
553  case META_DELETEOBJECT:
554  DeleteObject(*(ht->objectHandle + mr->rdParm[0]));
555  *(ht->objectHandle + mr->rdParm[0]) = 0;
556  break;
557 
558  case META_SETBKCOLOR:
559  SetBkColor(hdc, MAKELONG(mr->rdParm[0], mr->rdParm[1]));
560  break;
561 
562  case META_SETBKMODE:
563  SetBkMode(hdc, mr->rdParm[0]);
564  break;
565 
566  case META_SETMAPMODE:
567  SetMapMode(hdc, mr->rdParm[0]);
568  break;
569 
570  case META_SETROP2:
571  SetROP2(hdc, mr->rdParm[0]);
572  break;
573 
574  case META_SETRELABS:
575  SetRelAbs(hdc, mr->rdParm[0]);
576  break;
577 
579  SetPolyFillMode(hdc, mr->rdParm[0]);
580  break;
581 
583  SetStretchBltMode(hdc, mr->rdParm[0]);
584  break;
585 
586  case META_SETTEXTCOLOR:
587  SetTextColor(hdc, MAKELONG(mr->rdParm[0], mr->rdParm[1]));
588  break;
589 
590  case META_SETWINDOWORG:
591  SetWindowOrgEx(hdc, (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0], NULL);
592  break;
593 
594  case META_SETWINDOWEXT:
595  SetWindowExtEx(hdc, (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0], NULL);
596  break;
597 
598  case META_SETVIEWPORTORG:
599  SetViewportOrgEx(hdc, (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0], NULL);
600  break;
601 
602  case META_SETVIEWPORTEXT:
603  SetViewportExtEx(hdc, (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0], NULL);
604  break;
605 
607  OffsetWindowOrgEx(hdc, (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0], NULL);
608  break;
609 
610  case META_SCALEWINDOWEXT:
611  ScaleWindowExtEx(hdc, (SHORT)mr->rdParm[3], (SHORT)mr->rdParm[2],
612  (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0], NULL);
613  break;
614 
616  OffsetViewportOrgEx(hdc, (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0], NULL);
617  break;
618 
620  ScaleViewportExtEx(hdc, (SHORT)mr->rdParm[3], (SHORT)mr->rdParm[2],
621  (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0], NULL);
622  break;
623 
624  case META_LINETO:
625  LineTo(hdc, (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0]);
626  break;
627 
628  case META_MOVETO:
629  MoveToEx(hdc, (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0], NULL);
630  break;
631 
633  ExcludeClipRect( hdc, (SHORT)mr->rdParm[3], (SHORT)mr->rdParm[2],
634  (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0] );
635  break;
636 
638  IntersectClipRect( hdc, (SHORT)mr->rdParm[3], (SHORT)mr->rdParm[2],
639  (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0] );
640  break;
641 
642  case META_ARC:
643  Arc(hdc, (SHORT)mr->rdParm[7], (SHORT)mr->rdParm[6],
644  (SHORT)mr->rdParm[5], (SHORT)mr->rdParm[4],
645  (SHORT)mr->rdParm[3], (SHORT)mr->rdParm[2],
646  (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0]);
647  break;
648 
649  case META_ELLIPSE:
650  Ellipse(hdc, (SHORT)mr->rdParm[3], (SHORT)mr->rdParm[2],
651  (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0]);
652  break;
653 
654  case META_FLOODFILL:
655  FloodFill(hdc, (SHORT)mr->rdParm[3], (SHORT)mr->rdParm[2],
656  MAKELONG(mr->rdParm[0], mr->rdParm[1]));
657  break;
658 
659  case META_PIE:
660  Pie(hdc, (SHORT)mr->rdParm[7], (SHORT)mr->rdParm[6],
661  (SHORT)mr->rdParm[5], (SHORT)mr->rdParm[4],
662  (SHORT)mr->rdParm[3], (SHORT)mr->rdParm[2],
663  (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0]);
664  break;
665 
666  case META_RECTANGLE:
667  Rectangle(hdc, (SHORT)mr->rdParm[3], (SHORT)mr->rdParm[2],
668  (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0]);
669  break;
670 
671  case META_ROUNDRECT:
672  RoundRect(hdc, (SHORT)mr->rdParm[5], (SHORT)mr->rdParm[4],
673  (SHORT)mr->rdParm[3], (SHORT)mr->rdParm[2],
674  (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0]);
675  break;
676 
677  case META_PATBLT:
678  PatBlt(hdc, (SHORT)mr->rdParm[5], (SHORT)mr->rdParm[4],
679  (SHORT)mr->rdParm[3], (SHORT)mr->rdParm[2],
680  MAKELONG(mr->rdParm[0], mr->rdParm[1]));
681  break;
682 
683  case META_SAVEDC:
684  SaveDC(hdc);
685  break;
686 
687  case META_SETPIXEL:
688  SetPixel(hdc, (SHORT)mr->rdParm[3], (SHORT)mr->rdParm[2],
689  MAKELONG(mr->rdParm[0], mr->rdParm[1]));
690  break;
691 
692  case META_OFFSETCLIPRGN:
693  OffsetClipRgn( hdc, (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0] );
694  break;
695 
696  case META_TEXTOUT:
697  s1 = mr->rdParm[0];
698  TextOutA(hdc, (SHORT)mr->rdParm[((s1 + 1) >> 1) + 2],
699  (SHORT)mr->rdParm[((s1 + 1) >> 1) + 1],
700  (char *)(mr->rdParm + 1), s1);
701  break;
702 
703  case META_POLYGON:
704  if ((pt = convert_points( mr->rdParm[0], (POINTS *)(mr->rdParm + 1))))
705  {
706  Polygon(hdc, pt, mr->rdParm[0]);
707  HeapFree( GetProcessHeap(), 0, pt );
708  }
709  break;
710 
711  case META_POLYPOLYGON:
712  {
713  UINT i, total;
714  SHORT *counts = (SHORT *)(mr->rdParm + 1);
715 
716  for (i = total = 0; i < mr->rdParm[0]; i++) total += counts[i];
717  pt = convert_points( total, (POINTS *)(counts + mr->rdParm[0]) );
718  if (pt)
719  {
720  INT *cnt32 = HeapAlloc( GetProcessHeap(), 0, mr->rdParm[0] * sizeof(*cnt32) );
721  if (cnt32)
722  {
723  for (i = 0; i < mr->rdParm[0]; i++) cnt32[i] = counts[i];
724  PolyPolygon( hdc, pt, cnt32, mr->rdParm[0]);
725  HeapFree( GetProcessHeap(), 0, cnt32 );
726  }
727  }
728  HeapFree( GetProcessHeap(), 0, pt );
729  }
730  break;
731 
732  case META_POLYLINE:
733  if ((pt = convert_points( mr->rdParm[0], (POINTS *)(mr->rdParm + 1))))
734  {
735  Polyline( hdc, pt, mr->rdParm[0] );
736  HeapFree( GetProcessHeap(), 0, pt );
737  }
738  break;
739 
740  case META_RESTOREDC:
741  RestoreDC(hdc, (SHORT)mr->rdParm[0]);
742  break;
743 
744  case META_SELECTOBJECT:
745  SelectObject(hdc, *(ht->objectHandle + mr->rdParm[0]));
746  break;
747 
748  case META_CHORD:
749  Chord(hdc, (SHORT)mr->rdParm[7], (SHORT)mr->rdParm[6],
750  (SHORT)mr->rdParm[5], (SHORT)mr->rdParm[4],
751  (SHORT)mr->rdParm[3], (SHORT)mr->rdParm[2],
752  (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0]);
753  break;
754 
756  switch (mr->rdParm[0])
757  {
758  case BS_PATTERN:
759  infohdr = (BITMAPINFOHEADER *)(mr->rdParm + 2);
762  infohdr->biHeight,
763  infohdr->biPlanes,
764  infohdr->biBitCount,
765  mr->rdParm +
766  (sizeof(BITMAPINFOHEADER) / 2) + 4)));
767  break;
768 
769  case BS_DIBPATTERN:
770  infohdr = (BITMAPINFOHEADER *)(mr->rdParm + 2);
771  MF_AddHandle(ht, handles, CreateDIBPatternBrushPt( infohdr, mr->rdParm[1] ));
772  break;
773 
774  default:
775  ERR("META_CREATEPATTERNBRUSH: Unknown pattern type %d\n",
776  mr->rdParm[0]);
777  break;
778  }
779  break;
780 
782  {
783  LOGPEN pen;
784  pen.lopnStyle = mr->rdParm[0];
785  pen.lopnWidth.x = (SHORT)mr->rdParm[1];
786  pen.lopnWidth.y = (SHORT)mr->rdParm[2];
787  pen.lopnColor = MAKELONG( mr->rdParm[3], mr->rdParm[4] );
789  }
790  break;
791 
793  {
794  LOGFONTA font;
795  font.lfHeight = (SHORT)mr->rdParm[0];
796  font.lfWidth = (SHORT)mr->rdParm[1];
797  font.lfEscapement = (SHORT)mr->rdParm[2];
798  font.lfOrientation = (SHORT)mr->rdParm[3];
799  font.lfWeight = (SHORT)mr->rdParm[4];
800  font.lfItalic = LOBYTE(mr->rdParm[5]);
801  font.lfUnderline = HIBYTE(mr->rdParm[5]);
802  font.lfStrikeOut = LOBYTE(mr->rdParm[6]);
803  font.lfCharSet = HIBYTE(mr->rdParm[6]);
804  font.lfOutPrecision = LOBYTE(mr->rdParm[7]);
805  font.lfClipPrecision = HIBYTE(mr->rdParm[7]);
806  font.lfQuality = LOBYTE(mr->rdParm[8]);
807  font.lfPitchAndFamily = HIBYTE(mr->rdParm[8]);
808  memcpy( font.lfFaceName, mr->rdParm + 9, LF_FACESIZE );
810  }
811  break;
812 
814  {
815  LOGBRUSH brush;
816  brush.lbStyle = mr->rdParm[0];
817  brush.lbColor = MAKELONG( mr->rdParm[1], mr->rdParm[2] );
818  brush.lbHatch = mr->rdParm[3];
820  }
821  break;
822 
823  case META_CREATEPALETTE:
825  break;
826 
827  case META_SETTEXTALIGN:
828  SetTextAlign(hdc, mr->rdParm[0]);
829  break;
830 
831  case META_SELECTPALETTE:
832  GDISelectPalette(hdc, *(ht->objectHandle + mr->rdParm[1]), mr->rdParm[0]);
833  break;
834 
835  case META_SETMAPPERFLAGS:
836  SetMapperFlags(hdc, MAKELONG(mr->rdParm[0],mr->rdParm[1]));
837  break;
838 
839  case META_REALIZEPALETTE:
841  break;
842 
843  case META_ESCAPE:
844  switch (mr->rdParm[0]) {
845  case GETSCALINGFACTOR: /* get function ... would just NULL dereference */
846  case GETPHYSPAGESIZE:
847  case GETPRINTINGOFFSET:
848  return FALSE;
849  case SETABORTPROC:
850  FIXME("Filtering Escape(SETABORTPROC), possible virus?\n");
851  return FALSE;
852  }
853  Escape(hdc, mr->rdParm[0], mr->rdParm[1], (LPCSTR)&mr->rdParm[2], NULL);
854  break;
855 
856  case META_EXTTEXTOUT:
858  break;
859 
860  case META_STRETCHDIB:
861  {
862  LPBITMAPINFO info = (LPBITMAPINFO) &(mr->rdParm[11]);
863  LPSTR bits = (LPSTR)info + bitmap_info_size( info, mr->rdParm[2] );
864  StretchDIBits( hdc, (SHORT)mr->rdParm[10], (SHORT)mr->rdParm[9], (SHORT)mr->rdParm[8],
865  (SHORT)mr->rdParm[7], (SHORT)mr->rdParm[6], (SHORT)mr->rdParm[5],
866  (SHORT)mr->rdParm[4], (SHORT)mr->rdParm[3], bits, info,
867  mr->rdParm[2],MAKELONG(mr->rdParm[0],mr->rdParm[1]));
868  }
869  break;
870 
871  case META_DIBSTRETCHBLT:
872  {
873  LPBITMAPINFO info = (LPBITMAPINFO) &(mr->rdParm[10]);
875  StretchDIBits( hdc, (SHORT)mr->rdParm[9], (SHORT)mr->rdParm[8], (SHORT)mr->rdParm[7],
876  (SHORT)mr->rdParm[6], (SHORT)mr->rdParm[5], (SHORT)mr->rdParm[4],
877  (SHORT)mr->rdParm[3], (SHORT)mr->rdParm[2], bits, info,
878  DIB_RGB_COLORS,MAKELONG(mr->rdParm[0],mr->rdParm[1]));
879  }
880  break;
881 
882  case META_STRETCHBLT:
883  {
885  HBITMAP hbitmap = CreateBitmap(mr->rdParm[10], /*Width */
886  mr->rdParm[11], /*Height*/
887  mr->rdParm[13], /*Planes*/
888  mr->rdParm[14], /*BitsPixel*/
889  &mr->rdParm[15]); /*bits*/
891  StretchBlt(hdc, (SHORT)mr->rdParm[9], (SHORT)mr->rdParm[8],
892  (SHORT)mr->rdParm[7], (SHORT)mr->rdParm[6],
893  hdcSrc, (SHORT)mr->rdParm[5], (SHORT)mr->rdParm[4],
894  (SHORT)mr->rdParm[3], (SHORT)mr->rdParm[2],
895  MAKELONG(mr->rdParm[0],mr->rdParm[1]));
896  DeleteDC(hdcSrc);
897  }
898  break;
899 
900  case META_BITBLT:
901  {
903  HBITMAP hbitmap = CreateBitmap(mr->rdParm[7]/*Width */,
904  mr->rdParm[8]/*Height*/,
905  mr->rdParm[10]/*Planes*/,
906  mr->rdParm[11]/*BitsPixel*/,
907  &mr->rdParm[12]/*bits*/);
909  BitBlt(hdc,(SHORT)mr->rdParm[6],(SHORT)mr->rdParm[5],
910  (SHORT)mr->rdParm[4],(SHORT)mr->rdParm[3],
911  hdcSrc, (SHORT)mr->rdParm[2],(SHORT)mr->rdParm[1],
912  MAKELONG(0,mr->rdParm[0]));
913  DeleteDC(hdcSrc);
914  }
915  break;
916 
917  case META_CREATEREGION:
918  {
919  HRGN hrgn = CreateRectRgn(0,0,0,0);
920 
923  }
924  break;
925 
926  case META_FILLREGION:
927  FillRgn(hdc, *(ht->objectHandle + mr->rdParm[1]),
928  *(ht->objectHandle + mr->rdParm[0]));
929  break;
930 
931  case META_FRAMEREGION:
932  FrameRgn(hdc, *(ht->objectHandle + mr->rdParm[3]),
933  *(ht->objectHandle + mr->rdParm[2]),
934  (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0]);
935  break;
936 
937  case META_INVERTREGION:
938  InvertRgn(hdc, *(ht->objectHandle + mr->rdParm[0]));
939  break;
940 
941  case META_PAINTREGION:
942  PaintRgn(hdc, *(ht->objectHandle + mr->rdParm[0]));
943  break;
944 
946  {
947  HRGN hrgn = 0;
948 
949  if (mr->rdParm[0]) hrgn = *(ht->objectHandle + mr->rdParm[0]);
951  }
952  break;
953 
955  /* mr->rdParm[0] may be BS_PATTERN or BS_DIBPATTERN:
956  but there's no difference */
958  break;
959 
960  case META_DIBBITBLT:
961  /* In practice I've found that there are two layouts for
962  META_DIBBITBLT, one (the first here) is the usual one when a src
963  dc is actually passed to it, the second occurs when the src dc is
964  passed in as NULL to the creating BitBlt. As the second case has
965  no dib, a size check will suffice to distinguish.
966 
967  Caolan.McNamara@ul.ie */
968 
969  if (mr->rdSize > 12) {
970  LPBITMAPINFO info = (LPBITMAPINFO) &(mr->rdParm[8]);
972 
973  StretchDIBits(hdc, (SHORT)mr->rdParm[7], (SHORT)mr->rdParm[6], (SHORT)mr->rdParm[5],
974  (SHORT)mr->rdParm[4], (SHORT)mr->rdParm[3], (SHORT)mr->rdParm[2],
975  (SHORT)mr->rdParm[5], (SHORT)mr->rdParm[4], bits, info,
976  DIB_RGB_COLORS, MAKELONG(mr->rdParm[0], mr->rdParm[1]));
977  }
978  else /* equivalent to a PatBlt */
979  PatBlt(hdc, (SHORT)mr->rdParm[8], (SHORT)mr->rdParm[7],
980  (SHORT)mr->rdParm[6], (SHORT)mr->rdParm[5],
981  MAKELONG(mr->rdParm[0], mr->rdParm[1]));
982  break;
983 
986  break;
987 
989  SetTextJustification(hdc, (SHORT)mr->rdParm[1], (SHORT)mr->rdParm[0]);
990  break;
991 
992  case META_EXTFLOODFILL:
993  ExtFloodFill(hdc, (SHORT)mr->rdParm[4], (SHORT)mr->rdParm[3],
994  MAKELONG(mr->rdParm[1], mr->rdParm[2]),
995  mr->rdParm[0]);
996  break;
997 
998  case META_SETDIBTODEV:
999  {
1000  BITMAPINFO *info = (BITMAPINFO *) &(mr->rdParm[9]);
1001  char *bits = (char *)info + bitmap_info_size( info, mr->rdParm[0] );
1002  SetDIBitsToDevice(hdc, (SHORT)mr->rdParm[8], (SHORT)mr->rdParm[7],
1003  (SHORT)mr->rdParm[6], (SHORT)mr->rdParm[5],
1004  (SHORT)mr->rdParm[4], (SHORT)mr->rdParm[3],
1005  mr->rdParm[2], mr->rdParm[1], bits, info,
1006  mr->rdParm[0]);
1007  break;
1008  }
1009 
1010 #define META_UNIMP(x) case x: \
1011 FIXME("PlayMetaFileRecord:record type "#x" not implemented.\n"); \
1012 break;
1026 #undef META_UNIMP
1027 
1028  default:
1029  WARN("PlayMetaFileRecord: Unknown record type %x\n", mr->rdFunction);
1030  return FALSE;
1031  }
1032  return TRUE;
1033 }
BOOL WINAPI ScaleWindowExtEx(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _Out_opt_ LPSIZE)
DWORD WINAPI SetMapperFlags(_In_ HDC, _In_ DWORD)
#define META_SETPOLYFILLMODE
Definition: wingdi.h:215
#define META_RESTOREDC
Definition: wingdi.h:248
BOOL WINAPI OffsetWindowOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:900
#define META_SCALEVIEWPORTEXT
Definition: wingdi.h:227
int WINAPI StretchDIBits(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ const VOID *, _In_ const BITMAPINFO *, _In_ UINT, _In_ DWORD)
#define META_DRAWTEXT
Definition: wingdi.h:278
BOOL WINAPI SetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:655
#define BS_DIBPATTERN
Definition: wingdi.h:1091
#define META_CREATEBRUSHINDIRECT
Definition: wingdi.h:276
#define TRUE
Definition: types.h:120
#define LF_FACESIZE
Definition: dimm.idl:39
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
int WINAPI FillRgn(_In_ HDC, _In_ HRGN, _In_ HBRUSH)
Definition: painting.c:183
STRING Escape(const STRING &str)
Definition: fontsub.cpp:1030
#define META_ANIMATEPALETTE
Definition: wingdi.h:262
static struct object_header ** handles
Definition: handle.c:45
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
long y
Definition: polytest.cpp:48
#define META_CREATEBITMAP
Definition: wingdi.h:287
#define META_SETROP2
Definition: wingdi.h:213
BOOL WINAPI PaintRgn(_In_ HDC, _In_ HRGN)
Definition: painting.c:250
HPALETTE WINAPI GDISelectPalette(HDC hdc, HPALETTE hpal, WORD wBkg) DECLSPEC_HIDDEN
BOOL Polygon(CONST PPOINT UnsafePoints, int Count, int polyFillMode)
Definition: polytest.cpp:730
#define LOBYTE(W)
Definition: jmemdos.c:487
struct tagBITMAPINFO * LPBITMAPINFO
long x
Definition: polytest.cpp:48
UINT lbStyle
Definition: wingdi.h:1746
#define META_ABORTDOC
Definition: wingdi.h:283
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define META_SETSTRETCHBLTMODE
Definition: wingdi.h:216
Definition: mk_font.cpp:20
#define META_STRETCHDIB
Definition: wingdi.h:269
HFONT WINAPI CreateFontIndirectA(_In_ const LOGFONTA *)
#define META_OFFSETWINDOWORG
Definition: wingdi.h:224
#define pt(x, y)
Definition: drawing.c:79
#define GETPRINTINGOFFSET
Definition: wingdi.h:1005
#define META_SETTEXTCHAREXTRA
Definition: wingdi.h:217
ULONG_PTR lbHatch
Definition: wingdi.h:1748
#define WARN(fmt,...)
Definition: debug.h:111
static HDC
Definition: imagelist.c:92
#define META_ENDDOC
Definition: wingdi.h:284
BOOL WINAPI ScaleViewportExtEx(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _Out_opt_ LPSIZE)
#define HIBYTE(W)
Definition: jmemdos.c:486
#define META_SETVIEWPORTORG
Definition: wingdi.h:222
BOOL WINAPI OffsetViewportOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:849
int WINAPI IntersectClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
POINT lopnWidth
Definition: wingdi.h:1845
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
static BOOL MF_Play_MetaCreateRegion(METARECORD *mr, HRGN hrgn)
Definition: metafile.c:1333
WORD rdFunction
Definition: wingdi.h:2345
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
BOOL WINAPI Chord(_In_ HDC hdc, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom, _In_ INT xRadial1, _In_ INT yRadial1, _In_ INT xRadial2, _In_ INT yRadial2)
Definition: arc.c:119
BOOL WINAPI LineTo(_In_ HDC, _In_ int, _In_ int)
#define META_FLOODFILL
Definition: wingdi.h:234
#define META_SAVEDC
Definition: wingdi.h:239
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
static HDC hdcSrc
Definition: xlate.c:32
UINT WINAPI SetTextAlign(_In_ HDC, _In_ UINT)
Definition: text.c:853
#define META_INVERTREGION
Definition: wingdi.h:251
char * LPSTR
Definition: xmlstorage.h:182
#define META_REALIZEPALETTE
Definition: wingdi.h:261
static VOID NTAPI BitBlt(IN ULONG Left, IN ULONG Top, IN ULONG Width, IN ULONG Height, IN PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:410
#define META_STARTPAGE
Definition: wingdi.h:281
GLenum GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * bits
Definition: glext.h:10929
int32_t INT
Definition: typedefs.h:56
DWORD rdSize
Definition: wingdi.h:2344
#define META_PATBLT
Definition: wingdi.h:238
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
#define META_CREATEPALETTE
Definition: wingdi.h:272
BOOL WINAPI FloodFill(_In_ HDC, _In_ int, _In_ int, _In_ COLORREF)
#define META_SETVIEWPORTEXT
Definition: wingdi.h:223
int WINAPI SetTextCharacterExtra(_In_ HDC, _In_ int)
#define META_RECTANGLE
Definition: wingdi.h:236
#define META_LINETO
Definition: wingdi.h:228
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:975
#define META_CREATEBITMAPINDIRECT
Definition: wingdi.h:286
BOOL WINAPI PatBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
BOOL WINAPI MoveToEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1032
#define META_PAINTREGION
Definition: wingdi.h:252
#define META_CREATEREGION
Definition: wingdi.h:277
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define META_STARTDOC
Definition: wingdi.h:280
#define META_SETBKMODE
Definition: wingdi.h:211
#define GETPHYSPAGESIZE
Definition: wingdi.h:1004
#define META_CREATEPATTERNBRUSH
Definition: wingdi.h:273
#define META_SETMAPPERFLAGS
Definition: wingdi.h:257
BOOL WINAPI RoundRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int)
static POINT * convert_points(UINT count, const POINTS *pts)
Definition: metafile.c:118
#define META_OFFSETCLIPRGN
Definition: wingdi.h:241
int WINAPI SetMapMode(_In_ HDC, _In_ int)
BOOL WINAPI Arc(_In_ HDC hdc, _In_ INT xLeft, _In_ INT yTop, _In_ INT xRight, _In_ INT yBottom, _In_ INT xStartArc, _In_ INT yStartArc, _In_ INT xEndArc, _In_ INT yEndArc)
Definition: arc.c:5
int WINAPI SetROP2(_In_ HDC, _In_ int)
Definition: dc.c:1083
short SHORT
Definition: pedump.c:59
int WINAPI OffsetClipRgn(_In_ HDC, _In_ int, _In_ int)
#define FIXME(fmt,...)
Definition: debug.h:110
#define META_FRAMEREGION
Definition: wingdi.h:250
UINT lopnStyle
Definition: wingdi.h:1844
#define META_SETTEXTCOLOR
Definition: wingdi.h:218
COLORREF lopnColor
Definition: wingdi.h:1846
#define META_OFFSETVIEWPORTORG
Definition: wingdi.h:226
#define MAKELONG(a, b)
Definition: typedefs.h:248
smooth NULL
Definition: ftsmooth.c:416
#define META_SETPIXEL
Definition: wingdi.h:240
#define META_SETPALENTRIES
Definition: wingdi.h:263
static BOOL MF_Play_MetaExtTextOut(HDC hdc, METARECORD *mr)
Definition: metafile.c:1380
#define META_MOVETO
Definition: wingdi.h:229
#define META_BITBLT
Definition: wingdi.h:243
const char * LPCSTR
Definition: xmlstorage.h:183
#define META_DIBBITBLT
Definition: wingdi.h:266
#define META_DIBSTRETCHBLT
Definition: wingdi.h:267
#define META_SETWINDOWORG
Definition: wingdi.h:220
#define SETABORTPROC
Definition: wingdi.h:1001
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
FORCEINLINE VOID SetPixel(IN ULONG Left, IN ULONG Top, IN UCHAR Color)
Definition: vga.c:93
#define META_DIBCREATEPATTERNBRUSH
Definition: wingdi.h:268
HBRUSH WINAPI CreatePatternBrush(_In_ HBITMAP)
#define META_POLYGON
Definition: wingdi.h:245
#define TRACE(s)
Definition: solgame.cpp:4
BOOL WINAPI PolyPolygon(_In_ HDC hdc, _In_ const POINT *apt, _In_reads_(csz) const INT *asz, _In_ int csz)
#define GetProcessHeap()
Definition: compat.h:403
#define META_EXCLUDECLIPRECT
Definition: wingdi.h:230
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define META_ESCAPE
Definition: wingdi.h:247
BOOL WINAPI SetTextJustification(_In_ HDC, _In_ int, _In_ int)
BOOL WINAPI Pie(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int, _In_ int)
int WINAPI SetPolyFillMode(_In_ HDC, _In_ int)
Definition: dc.c:1143
#define META_SELECTPALETTE
Definition: wingdi.h:260
struct S1 s1
HPALETTE WINAPI CreatePalette(_In_reads_(_Inexpressible_(2 *sizeof(WORD)+plpal->palNumEntries *sizeof(PALETTEENTRY))) const LOGPALETTE *)
COLORREF lbColor
Definition: wingdi.h:1747
static int bitmap_info_size(const BITMAPINFO *info, WORD coloruse)
Definition: datacache.c:228
#define META_STRETCHBLT
Definition: wingdi.h:244
#define META_POLYLINE
Definition: wingdi.h:246
#define META_SCALEWINDOWEXT
Definition: wingdi.h:225
#define META_EXTTEXTOUT
Definition: wingdi.h:258
#define META_SETDIBTODEV
Definition: wingdi.h:259
#define META_FILLREGION
Definition: wingdi.h:249
#define META_TEXTOUT
Definition: wingdi.h:242
#define META_POLYPOLYGON
Definition: wingdi.h:264
HDC hdc
Definition: main.c:9
#define META_SETTEXTJUSTIFICATION
Definition: wingdi.h:219
static HRGN hrgn
Definition: win.c:55
#define META_SETRELABS
Definition: wingdi.h:214
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define META_PIE
Definition: wingdi.h:235
WORD rdParm[1]
Definition: wingdi.h:2346
HPEN WINAPI CreatePenIndirect(_In_ const LOGPEN *)
HBRUSH WINAPI CreateBrushIndirect(_In_ const LOGBRUSH *plb)
int WINAPI SetStretchBltMode(_In_ HDC, _In_ int)
Definition: dc.c:1324
#define META_SETTEXTALIGN
Definition: wingdi.h:255
#define ERR(fmt,...)
Definition: debug.h:109
#define META_DELETEOBJECT
Definition: wingdi.h:271
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:888
#define META_EXTFLOODFILL
Definition: wingdi.h:270
#define META_ROUNDRECT
Definition: wingdi.h:237
#define META_SETMAPMODE
Definition: wingdi.h:212
#define META_SELECTOBJECT
Definition: wingdi.h:254
int WINAPI SetDIBitsToDevice(_In_ HDC, _In_ int, _In_ int, _In_ DWORD, _In_ DWORD, _In_ int, _In_ int, _In_ UINT, _In_ UINT, _In_ CONST VOID *, _In_ CONST BITMAPINFO *, _In_ UINT)
BOOL WINAPI DeleteDC(_In_ HDC)
BOOL WINAPI Ellipse(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
static int MF_AddHandle(HANDLETABLE *ht, UINT htlen, HGDIOBJ hobj)
Definition: metafile.c:84
int WINAPI ExcludeClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define META_CREATEPENINDIRECT
Definition: wingdi.h:274
#define META_CREATEFONTINDIRECT
Definition: wingdi.h:275
#define META_ARC
Definition: wingdi.h:232
static const struct newhuff ht[]
Definition: huffman.h:296
#define META_ELLIPSE
Definition: wingdi.h:233
#define META_ENDPAGE
Definition: wingdi.h:282
unsigned int UINT
Definition: ndis.h:50
int WINAPI SaveDC(_In_ HDC)
BOOL WINAPI InvertRgn(_In_ HDC, _In_ HRGN)
Definition: painting.c:229
BOOL WINAPI TextOutA(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(c) LPCSTR lpString, _In_ int c)
UINT WINAPI GDIRealizePalette(HDC hdc) DECLSPEC_HIDDEN
#define BS_PATTERN
Definition: wingdi.h:1089
#define META_SELECTCLIPREGION
Definition: wingdi.h:253
BOOL WINAPI Polyline(_In_ HDC hdc, _In_reads_(cpt) const POINT *apt, _In_ int cpt)
#define META_SETBKCOLOR
Definition: wingdi.h:210
#define META_UNIMP(x)
BOOL WINAPI SetWindowOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:532
INT WINAPI SetRelAbs(HDC, INT)
Definition: dc.c:722
static HBITMAP hbitmap
static HBITMAP
Definition: button.c:44
BOOL WINAPI SetViewportExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
Definition: coord.c:465
#define META_INTERSECTCLIPRECT
Definition: wingdi.h:231
#define DIB_RGB_COLORS
Definition: wingdi.h:366
#define META_CHORD
Definition: wingdi.h:256
#define META_RESIZEPALETTE
Definition: wingdi.h:265
HBRUSH WINAPI CreateDIBPatternBrushPt(_In_ const VOID *pvPackedDIB, _In_ UINT uUsage)
#define META_SETWINDOWEXT
Definition: wingdi.h:221
BOOL WINAPI RestoreDC(_In_ HDC, _In_ int)
BOOL WINAPI FrameRgn(_In_ HDC, _In_ HRGN, _In_ HBRUSH, _In_ int, _In_ int)
#define META_CREATEBRUSH
Definition: wingdi.h:285
#define HeapFree(x, y, z)
Definition: compat.h:402
#define GETSCALINGFACTOR
Definition: wingdi.h:1006
#define META_RESETDC
Definition: wingdi.h:279
#define META_EOF
Definition: gdi_private.h:32
BOOL WINAPI ExtFloodFill(_In_ HDC, _In_ int, _In_ int, _In_ COLORREF, _In_ UINT)
HBITMAP WINAPI CreateBitmap(_In_ INT cx, _In_ INT cy, _In_ UINT cPlanes, _In_ UINT cBitsPerPel, _In_opt_ const VOID *pvBits)

Referenced by PlayMetaFile().

◆ set_window()

static BOOL set_window ( HDC  hdc,
HENHMETAFILE  emf,
HDC  ref_dc,
INT  map_mode 
)
static

Definition at line 1203 of file metafile.c.

1204 {
1206  INT horz_res, vert_res, horz_size, vert_size;
1207  POINT pt;
1208 
1209  if(!GetEnhMetaFileHeader(emf, sizeof(header), &header)) return FALSE;
1210 
1211  horz_res = GetDeviceCaps(ref_dc, HORZRES);
1212  vert_res = GetDeviceCaps(ref_dc, VERTRES);
1213  horz_size = GetDeviceCaps(ref_dc, HORZSIZE);
1214  vert_size = GetDeviceCaps(ref_dc, VERTSIZE);
1215 
1216  switch(map_mode)
1217  {
1218  case MM_TEXT:
1219  case MM_ISOTROPIC:
1220  case MM_ANISOTROPIC:
1221  pt.y = muldiv(header.rclFrame.top, vert_res, vert_size * 100);
1222  pt.x = muldiv(header.rclFrame.left, horz_res, horz_size * 100);
1223  break;
1224  case MM_LOMETRIC:
1225  pt.y = muldiv(-header.rclFrame.top, 1, 10) + 1;
1226  pt.x = muldiv( header.rclFrame.left, 1, 10);
1227  break;
1228  case MM_HIMETRIC:
1229  pt.y = -header.rclFrame.top + 1;
1230  pt.x = (header.rclFrame.left >= 0) ? header.rclFrame.left : header.rclFrame.left + 1; /* See the tests */
1231  break;
1232  case MM_LOENGLISH:
1233  pt.y = muldiv(-header.rclFrame.top, 10, 254) + 1;
1234  pt.x = muldiv( header.rclFrame.left, 10, 254);
1235  break;
1236  case MM_HIENGLISH:
1237  pt.y = muldiv(-header.rclFrame.top, 100, 254) + 1;
1238  pt.x = muldiv( header.rclFrame.left, 100, 254);
1239  break;
1240  case MM_TWIPS:
1241  pt.y = muldiv(-header.rclFrame.top, 72 * 20, 2540) + 1;
1242  pt.x = muldiv( header.rclFrame.left, 72 * 20, 2540);
1243  break;
1244  default:
1245  WARN("Unknown map mode %d\n", map_mode);
1246  return FALSE;
1247  }
1248  SetWindowOrgEx(hdc, pt.x, pt.y, NULL);
1249 
1250  pt.x = muldiv(header.rclFrame.right - header.rclFrame.left, horz_res, horz_size * 100);
1251  pt.y = muldiv(header.rclFrame.bottom - header.rclFrame.top, vert_res, vert_size * 100);
1252  SetWindowExtEx(hdc, pt.x, pt.y, NULL);
1253  return TRUE;
1254 }
#define MM_ISOTROPIC
Definition: wingdi.h:869
#define HORZRES
Definition: wingdi.h:715
#define TRUE
Definition: types.h:120
BOOL WINAPI SetWindowExtEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPSIZE)
#define pt(x, y)
Definition: drawing.c:79
#define WARN(fmt,...)
Definition: debug.h:111
int32_t INT
Definition: typedefs.h:56
smooth NULL
Definition: ftsmooth.c:416
#define MM_LOMETRIC
Definition: wingdi.h:871
#define MM_LOENGLISH
Definition: wingdi.h:870
UINT WINAPI GetEnhMetaFileHeader(_In_ HENHMETAFILE hemf, _In_ UINT nSize, _Out_writes_bytes_opt_(nSize) LPENHMETAHEADER lpEnhMetaHeader)
static INT muldiv(INT m1, INT m2, INT d)
Definition: metafile.c:1182
HDC hdc
Definition: main.c:9
#define MM_ANISOTROPIC
Definition: wingdi.h:866
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
#define MM_TWIPS
Definition: wingdi.h:873
#define HORZSIZE
Definition: wingdi.h:713
#define VERTSIZE
Definition: wingdi.h:714
#define VERTRES
Definition: wingdi.h:716
#define MM_HIMETRIC
Definition: wingdi.h:868
#define MM_TEXT
Definition: wingdi.h:872
BOOL WINAPI SetWindowOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:532
#define MM_HIENGLISH
Definition: wingdi.h:867
struct CFHEADER header
Definition: fdi.c:101

Referenced by GetWinMetaFileBits().

◆ SetMetaFileBitsEx()

HMETAFILE WINAPI SetMetaFileBitsEx ( UINT  size,
const BYTE lpData 
)

Definition at line 1049 of file metafile.c.

1050 {
1051  const METAHEADER *mh_in = (const METAHEADER *)lpData;
1052  METAHEADER *mh_out;
1053 
1054  if (size & 1) return 0;
1055 
1056  if (!size || mh_in->mtType != METAFILE_MEMORY || mh_in->mtVersion != MFVERSION ||
1057  mh_in->mtHeaderSize != sizeof(METAHEADER) / 2)
1058  {
1060  return 0;
1061  }
1062 
1063  mh_out = HeapAlloc( GetProcessHeap(), 0, size );
1064  if (!mh_out)
1065  {
1067  return 0;
1068  }
1069 
1070  memcpy(mh_out, mh_in, size);
1071  mh_out->mtSize = size / 2;
1072  return MF_Create_HMETAFILE(mh_out);
1073 }
DWORD mtSize
Definition: wingdi.h:2312
#define ERROR_NOT_ENOUGH_MEMORY
Definition: dderror.h:7
WORD mtType
Definition: wingdi.h:2309
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:403
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
WORD mtHeaderSize
Definition: wingdi.h:2310
#define SetLastError(x)
Definition: compat.h:417
WORD mtVersion
Definition: wingdi.h:2311
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define ERROR_INVALID_DATA
Definition: winerror.h:116
#define METAFILE_MEMORY
Definition: gdi32p.h:76
HMETAFILE MF_Create_HMETAFILE(METAHEADER *mh)
Definition: metafile.c:107
#define MFVERSION
Definition: gdi_private.h:38

Referenced by GdiCreateLocalMetaFilePict(), and test_SetMetaFileBits().

◆ WINE_DEFAULT_DEBUG_CHANNEL()

WINE_DEFAULT_DEBUG_CHANNEL ( metafile  )