1 #include <precomp.h> 2 3 #define NDEBUG 4 #include <debug.h> 5 6 /* 7 * @unimplemented 8 */ 9 DWORD 10 WINAPI 11 IsValidEnhMetaRecord( 12 DWORD a0, 13 DWORD a1 14 ) 15 { 16 UNIMPLEMENTED; 17 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 18 return 0; 19 20 } 21 22 /* 23 * @unimplemented 24 */ 25 DWORD 26 WINAPI 27 IsValidEnhMetaRecordOffExt( 28 DWORD a0, 29 DWORD a1, 30 DWORD a2, 31 DWORD a3 32 ) 33 { 34 UNIMPLEMENTED; 35 SetLastError(ERROR_CALL_NOT_IMPLEMENTED); 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 56 Buffer = (BYTE *)LocalAlloc(LPTR, nSize); 57 if (Buffer == NULL) 58 goto Exit; 59 60 nSize = GetEnhMetaFileBits( hemf, nSize, Buffer ); 61 if (nSize == 0) 62 goto Exit; 63 64 hmo = NtGdiCreateServerMetaFile( GDITAG_TYPE_EMF, nSize, Buffer, 0, 0, 0 ); 65 66 Exit: 67 // clean up 68 if (Buffer) 69 LocalFree(Buffer); 70 return hmo; 71 } 72 73 /* 74 * @implemented 75 */ 76 HENHMETAFILE 77 WINAPI 78 GdiCreateLocalEnhMetaFile(HANDLE hmo) 79 { 80 HENHMETAFILE hEMF; 81 BYTE * Buffer = NULL; 82 UINT nSize; 83 DWORD iType, mm, xExt, yExt; 84 85 nSize = NtGdiGetServerMetaFileBits( hmo, 0, NULL, NULL, NULL, NULL, NULL); 86 if (nSize == 0) 87 goto Exit; 88 89 // allocate buffer 90 Buffer = (BYTE *)LocalAlloc(LPTR, nSize); 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 { 101 METAFILEPICT Info; 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 { 114 hEMF = SetEnhMetaFileBits(nSize, Buffer); 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 131 GdiComment( 132 _In_ HDC hdc, 133 _In_ UINT cbSize, 134 _In_ const BYTE *lpData) 135 { 136 if (GDI_HANDLE_GET_TYPE(hdc) != GDILoObjType_LO_ALTDC_TYPE) 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 149 GetEnhMetaFilePixelFormat( 150 HENHMETAFILE hemf, 151 UINT cbBuffer, 152 PIXELFORMATDESCRIPTOR *ppfd 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 } 170