ReactOS  0.4.14-dev-297-g23e575c
enhmfile.c
Go to the documentation of this file.
1 #include <precomp.h>
2 
3 #define NDEBUG
4 #include <debug.h>
5 
6 /*
7  * @unimplemented
8  */
9 DWORD
10 WINAPI
12  DWORD a0,
13  DWORD a1
14 )
15 {
18  return 0;
19 
20 }
21 
22 /*
23  * @unimplemented
24  */
25 DWORD
26 WINAPI
28  DWORD a0,
29  DWORD a1,
30  DWORD a2,
31  DWORD a3
32 )
33 {
36  return 0;
37 
38 }
39 
40 /*
41  * @implemented
42  */
43 HANDLE
44 WINAPI
45 GdiConvertEnhMetaFile(HENHMETAFILE hemf)
46 {
47  HANDLE hmo = NULL;
48  BYTE * Buffer = NULL;
49  UINT nSize;
50 
51  nSize = GetEnhMetaFileBits( hemf, 0, NULL );
52  if (nSize == 0)
53  goto Exit;
54 
55  // allocate buffer
57  if (Buffer == NULL)
58  goto Exit;
59 
61  if (nSize == 0)
62  goto Exit;
63 
65 
66 Exit:
67  // clean up
68  if (Buffer)
70  return hmo;
71 }
72 
73 /*
74  * @implemented
75  */
76 HENHMETAFILE
77 WINAPI
79 {
80  HENHMETAFILE hEMF;
81  BYTE * Buffer = NULL;
82  UINT nSize;
83  DWORD iType, mm, xExt, yExt;
84 
86  if (nSize == 0)
87  goto Exit;
88 
89  // allocate buffer
91  if (Buffer == NULL)
92  goto Exit;
93 
94  // store to buffer
95  nSize = NtGdiGetServerMetaFileBits( hmo, nSize, Buffer, &iType, &mm, &xExt, &yExt);
96  if (nSize == 0)
97  goto Exit;
98 
99  if ( iType == GDITAG_TYPE_MFP ) // handle conversion to EMF
100  {
102 
103  Info.hMF = NULL;
104  Info.mm = mm;
105  Info.xExt = xExt;
106  Info.yExt = yExt;
107 
108  hEMF = SetWinMetaFileBits( nSize, Buffer, NULL, &Info ); // Translate from old style to new style.
109  if (hEMF == NULL)
110  goto Exit;
111  }
112  else
113  {
115  if (hEMF == NULL)
116  goto Exit;
117  }
118 
119 Exit:
120  // clean up
121  if (Buffer)
122  LocalFree(Buffer);
123  return hEMF;
124 }
125 
126 /*
127  * @implemented
128  */
129 BOOL
130 WINAPI
132  _In_ HDC hdc,
133  _In_ UINT cbSize,
134  _In_ const BYTE *lpData)
135 {
137  return TRUE;
138 
139  HANDLE_METADC(BOOL, GdiComment, FALSE, hdc, cbSize, lpData);
140 
141  return TRUE;
142 }
143 
144 /*
145  * @implemented
146  */
147 UINT
148 WINAPI
150  HENHMETAFILE hemf,
151  UINT cbBuffer,
153 )
154 {
155  ENHMETAHEADER pemh;
156 
157  if(GetEnhMetaFileHeader(hemf, sizeof(ENHMETAHEADER), &pemh))
158  {
159  if(pemh.bOpenGL)
160  {
161  if(pemh.cbPixelFormat)
162  {
163  memcpy((void*)ppfd, UlongToPtr(pemh.offPixelFormat), cbBuffer );
164  return(pemh.cbPixelFormat);
165  }
166  }
167  }
168  return(0);
169 }
#define TRUE
Definition: types.h:120
static const struct update_accum a3
Definition: msg.c:600
_In_ ULONG iType
Definition: winddi.h:3748
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2031
BOOL WINAPI GdiComment(_In_ HDC hdc, _In_ UINT cbSize, _In_ const BYTE *lpData)
Definition: enhmfile.c:131
static HDC
Definition: imagelist.c:92
HENHMETAFILE WINAPI SetEnhMetaFileBits(_In_ UINT nSize, _In_reads_bytes_(nSize) const BYTE *pb)
_In_ LONG _In_ ULONG _Out_opt_ PIXELFORMATDESCRIPTOR * ppfd
Definition: winddi.h:3488
__kernel_entry W32KAPI ULONG APIENTRY NtGdiGetServerMetaFileBits(_In_ HANDLE hmo, _In_ ULONG cjData, _Out_writes_bytes_opt_(cjData) LPBYTE pjData, _Out_ PDWORD piType, _Out_ PDWORD pmm, _Out_ PDWORD pxExt, _Out_ PDWORD pyExt)
DWORD WINAPI IsValidEnhMetaRecord(DWORD a0, DWORD a1)
Definition: enhmfile.c:11
#define HANDLE_METADC(_RetType, _Func, dwError, hdc,...)
Definition: gdi32p.h:616
struct TraceInfo Info
HENHMETAFILE WINAPI SetWinMetaFileBits(_In_ UINT nSize, _In_reads_bytes_(nSize) const BYTE *lpMeta16Data, _In_opt_ HDC hdcRef, _In_opt_ const METAFILEPICT *lpMFP)
UINT WINAPI GetEnhMetaFilePixelFormat(HENHMETAFILE hemf, UINT cbBuffer, PIXELFORMATDESCRIPTOR *ppfd)
Definition: enhmfile.c:149
UINT WINAPI GetEnhMetaFileBits(_In_ HENHMETAFILE hEMF, _In_ UINT nSize, _Out_writes_bytes_opt_(nSize) LPBYTE lpData)
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
Definition: bufpool.h:45
#define UlongToPtr(u)
Definition: config.h:106
#define GDI_HANDLE_GET_TYPE(h)
Definition: gdi.h:31
#define GDITAG_TYPE_MFP
Definition: ntgdityp.h:246
static const struct update_accum a2
Definition: msg.c:586
static void Exit(void)
Definition: sock.c:1331
#define WINAPI
Definition: msvc.h:8
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:409
UINT WINAPI GetEnhMetaFileHeader(_In_ HENHMETAFILE hemf, _In_ UINT nSize, _Out_writes_bytes_opt_(nSize) LPENHMETAHEADER lpEnhMetaHeader)
HDC hdc
Definition: main.c:9
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
unsigned char BYTE
Definition: mem.h:68
#define GDITAG_TYPE_EMF
Definition: ntgdityp.h:245
#define _In_
Definition: no_sal2.h:204
DWORD WINAPI IsValidEnhMetaRecordOffExt(DWORD a0, DWORD a1, DWORD a2, DWORD a3)
Definition: enhmfile.c:27
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
unsigned int UINT
Definition: ndis.h:50
HENHMETAFILE WINAPI GdiCreateLocalEnhMetaFile(HANDLE hmo)
Definition: enhmfile.c:78
HANDLE WINAPI GdiConvertEnhMetaFile(HENHMETAFILE hemf)
Definition: enhmfile.c:45
#define LPTR
Definition: winbase.h:362
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:92
#define UNIMPLEMENTED
Definition: debug.h:114
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
static const struct update_accum a1
Definition: msg.c:578
__kernel_entry W32KAPI HANDLE APIENTRY NtGdiCreateServerMetaFile(_In_ DWORD iType, _In_ ULONG cjData, _In_reads_bytes_(cjData) LPBYTE pjData, _In_ DWORD mm, _In_ DWORD xExt, _In_ DWORD yExt)