ReactOS  0.4.15-dev-4594-g505ac65
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 BOOL
10 WINAPI
12  PVOID pv0,
13  PVOID pv1)
14 {
17  return FALSE;
18 }
19 
20 /*
21  * @unimplemented
22  */
23 BOOL
24 WINAPI
26  PVOID pv0,
27  PVOID pv1,
29  DWORD dwExtends )
30 {
33  return FALSE;
34 }
35 
36 /*
37  * @implemented
38  */
39 HANDLE
40 WINAPI
41 GdiConvertEnhMetaFile(HENHMETAFILE hemf)
42 {
43  HANDLE hmo = NULL;
44  BYTE * Buffer = NULL;
45  UINT nSize;
46 
47  nSize = GetEnhMetaFileBits( hemf, 0, NULL );
48  if (nSize == 0)
49  goto Exit;
50 
51  // allocate buffer
53  if (Buffer == NULL)
54  goto Exit;
55 
57  if (nSize == 0)
58  goto Exit;
59 
61 
62 Exit:
63  // clean up
64  if (Buffer)
66  return hmo;
67 }
68 
69 /*
70  * @implemented
71  */
72 HENHMETAFILE
73 WINAPI
75 {
76  HENHMETAFILE hEMF;
77  BYTE * Buffer = NULL;
78  UINT nSize;
79  DWORD iType, mm, xExt, yExt;
80 
82  if (nSize == 0)
83  goto Exit;
84 
85  // allocate buffer
87  if (Buffer == NULL)
88  goto Exit;
89 
90  // store to buffer
91  nSize = NtGdiGetServerMetaFileBits( hmo, nSize, Buffer, &iType, &mm, &xExt, &yExt);
92  if (nSize == 0)
93  goto Exit;
94 
95  if ( iType == GDITAG_TYPE_MFP ) // handle conversion to EMF
96  {
98 
99  Info.hMF = NULL;
100  Info.mm = mm;
101  Info.xExt = xExt;
102  Info.yExt = yExt;
103 
104  hEMF = SetWinMetaFileBits( nSize, Buffer, NULL, &Info ); // Translate from old style to new style.
105  if (hEMF == NULL)
106  goto Exit;
107  }
108  else
109  {
111  if (hEMF == NULL)
112  goto Exit;
113  }
114 
115 Exit:
116  // clean up
117  if (Buffer)
118  LocalFree(Buffer);
119  return hEMF;
120 }
121 
122 /*
123  * @implemented
124  */
125 BOOL
126 WINAPI
128  _In_ HDC hdc,
129  _In_ UINT cbSize,
130  _In_ const BYTE *lpData)
131 {
133  return TRUE;
134 
135  return EMFDC_GdiComment( hdc, cbSize, lpData );
136 }
137 
138 /*
139  * @implemented
140  */
141 UINT
142 WINAPI
144  HENHMETAFILE hemf,
145  UINT cbBuffer,
147 {
148  ENHMETAHEADER pemh;
149 
150  if(GetEnhMetaFileHeader(hemf, sizeof(ENHMETAHEADER), &pemh))
151  {
152  if(pemh.bOpenGL)
153  {
154  if(pemh.cbPixelFormat)
155  {
156  memcpy((void*)ppfd, UlongToPtr(pemh.offPixelFormat), cbBuffer );
157  return(pemh.cbPixelFormat);
158  }
159  }
160  }
161  return(0);
162 }
#define TRUE
Definition: types.h:120
_In_ ULONG iType
Definition: winddi.h:3748
*nSize LPSTR _Inout_ LPDWORD nSize
Definition: winbase.h:2058
BOOL WINAPI GdiComment(_In_ HDC hdc, _In_ UINT cbSize, _In_ const BYTE *lpData)
Definition: enhmfile.c:127
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)
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:143
_In_ DWORD _In_ DWORD dwOffset
Definition: ntgdi.h:2032
_Must_inspect_result_ _In_ WDFCHILDLIST _In_ PWDF_CHILD_LIST_ITERATOR _Out_ WDFDEVICE _Inout_opt_ PWDF_CHILD_RETRIEVE_INFO Info
Definition: wdfchildlist.h:683
UINT WINAPI GetEnhMetaFileBits(_In_ HENHMETAFILE hEMF, _In_ UINT nSize, _Out_writes_bytes_opt_(nSize) LPBYTE lpData)
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define _In_
Definition: ms_sal.h:308
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:247
static void Exit(void)
Definition: sock.c:1331
#define WINAPI
Definition: msvc.h:6
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SetLastError(x)
Definition: compat.h:611
UINT WINAPI GetEnhMetaFileHeader(_In_ HENHMETAFILE hemf, _In_ UINT nSize, _Out_writes_bytes_opt_(nSize) LPENHMETAHEADER lpEnhMetaHeader)
HDC hdc
Definition: main.c:9
BOOL WINAPI EMFDC_GdiComment(HDC hdc, UINT bytes, const BYTE *buffer)
Definition: emfdc.c:2326
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
BOOL WINAPI IsValidEnhMetaRecordOffExt(PVOID pv0, PVOID pv1, DWORD dwOffset, DWORD dwExtends)
Definition: enhmfile.c:25
#define GDITAG_TYPE_EMF
Definition: ntgdityp.h:246
unsigned char BYTE
Definition: xxhash.c:193
HLOCAL NTAPI LocalFree(HLOCAL hMem)
Definition: heapmem.c:1577
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
HENHMETAFILE WINAPI GdiCreateLocalEnhMetaFile(HANDLE hmo)
Definition: enhmfile.c:74
HANDLE WINAPI GdiConvertEnhMetaFile(HENHMETAFILE hemf)
Definition: enhmfile.c:41
#define LPTR
Definition: winbase.h:378
BOOL WINAPI IsValidEnhMetaRecord(PVOID pv0, PVOID pv1)
Definition: enhmfile.c:11
#define ERROR_CALL_NOT_IMPLEMENTED
Definition: compat.h:102
#define UNIMPLEMENTED
Definition: debug.h:115
HLOCAL NTAPI LocalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:1373
__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)