Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

319 lines
13 KiB

  1. /******************************Module*Header*******************************\
  2. * Module Name: mf16.h *
  3. *
  4. * Definitions needed for 3.x Metafile functions *
  5. *
  6. * Created: 01-Jul-1991 *
  7. * Author: John Colleran (johnc) *
  8. *
  9. * Copyright (c) 1991-1999 Microsoft Corporation
  10. \**************************************************************************/
  11. // Windows 3.x structures
  12. #pragma pack(2)
  13. #define SIZEOF_METARECORDHEADER (sizeof(DWORD)+sizeof(WORD))
  14. typedef struct _RECT16 {
  15. SHORT left;
  16. SHORT top;
  17. SHORT right;
  18. SHORT bottom;
  19. } RECT16;
  20. typedef RECT16 UNALIGNED *PRECT16;
  21. typedef struct _BITMAP16 {
  22. SHORT bmType;
  23. SHORT bmWidth;
  24. SHORT bmHeight;
  25. SHORT bmWidthBytes;
  26. BYTE bmPlanes;
  27. BYTE bmBitsPixel;
  28. LPBYTE bmBits;
  29. } BITMAP16;
  30. typedef BITMAP16 UNALIGNED *PBITMAP16;
  31. typedef struct _LOGBRUSH16 {
  32. WORD lbStyle;
  33. COLORREF lbColor;
  34. SHORT lbHatch;
  35. } LOGBRUSH16;
  36. typedef LOGBRUSH16 UNALIGNED *PLOGBRUSH16;
  37. typedef struct tagLOGFONT16
  38. {
  39. SHORT lfHeight;
  40. SHORT lfWidth;
  41. SHORT lfEscapement;
  42. SHORT lfOrientation;
  43. SHORT lfWeight;
  44. BYTE lfItalic;
  45. BYTE lfUnderline;
  46. BYTE lfStrikeOut;
  47. BYTE lfCharSet;
  48. BYTE lfOutPrecision;
  49. BYTE lfClipPrecision;
  50. BYTE lfQuality;
  51. BYTE lfPitchAndFamily;
  52. BYTE lfFaceName[LF_FACESIZE];
  53. } LOGFONT16;
  54. typedef LOGFONT16 UNALIGNED *PLOGFONT16;
  55. typedef struct _LOGPEN16 {
  56. WORD lopnStyle;
  57. POINTS lopnWidth;
  58. COLORREF lopnColor;
  59. } LOGPEN16;
  60. typedef LOGPEN16 UNALIGNED *PLOGPEN16;
  61. #pragma pack()
  62. // Macros for converting 32 bit objects to 16 bit equivalents
  63. #define INT32FROMINT16(lp32, lp16, c) \
  64. { \
  65. UINT ii; \
  66. \
  67. for(ii=0; ii<(c); ii++) \
  68. ((LPINT)(lp32))[ii] = ((PSHORT)(lp16))[ii]; \
  69. }
  70. #define BITMAP32FROMBITMAP16(lpBitmap, lpBitmap16) \
  71. { \
  72. (lpBitmap)->bmType = (LONG)(lpBitmap16)->bmType; \
  73. (lpBitmap)->bmWidth = (LONG)(lpBitmap16)->bmWidth; \
  74. (lpBitmap)->bmHeight = (LONG)(lpBitmap16)->bmHeight; \
  75. (lpBitmap)->bmWidthBytes = (LONG)(lpBitmap16)->bmWidthBytes;\
  76. (lpBitmap)->bmPlanes = (WORD)(lpBitmap16)->bmPlanes; \
  77. (lpBitmap)->bmBitsPixel = (WORD)(lpBitmap16)->bmBitsPixel; \
  78. (lpBitmap)->bmBits = (lpBitmap16)->bmBits; \
  79. }
  80. #define LOGBRUSH32FROMLOGBRUSH16(lpLogBrush, lpLogBrush16) \
  81. { \
  82. (lpLogBrush)->lbStyle = (UINT) (lpLogBrush16)->lbStyle; \
  83. (lpLogBrush)->lbColor = (lpLogBrush16)->lbColor; \
  84. (lpLogBrush)->lbHatch = (LONG) (lpLogBrush16)->lbHatch; \
  85. }
  86. #define LOGFONT32FROMLOGFONT16(lpLogFont, lpLogFont16) \
  87. { \
  88. ASSERTGDI((sizeof(LOGFONTA) == (sizeof(LOGFONT16)+sizeof(WORD)*5)), \
  89. "MF16.h: LOGFONT(32) and LOGFONT(16) changed!"); \
  90. (lpLogFont)->lfHeight = (LONG) (lpLogFont16)->lfHeight; \
  91. (lpLogFont)->lfWidth = (LONG) (lpLogFont16)->lfWidth; \
  92. (lpLogFont)->lfEscapement = (LONG) (lpLogFont16)->lfEscapement; \
  93. (lpLogFont)->lfOrientation = (LONG) (lpLogFont16)->lfOrientation; \
  94. (lpLogFont)->lfWeight = (LONG) (lpLogFont16)->lfWeight; \
  95. /* [ntbug #129231 - Access97 occurs an application error.] \
  96. Access 97 does not padded rest of facename arrary if the length of \
  97. face name is less than LF_FACESIZE. Win9x only access until null, \
  98. so that they are safe, we also did same. */ \
  99. (lpLogFont)->lfItalic = (lpLogFont16)->lfItalic; \
  100. (lpLogFont)->lfUnderline = (lpLogFont16)->lfUnderline; \
  101. (lpLogFont)->lfStrikeOut = (lpLogFont16)->lfStrikeOut; \
  102. (lpLogFont)->lfCharSet = (lpLogFont16)->lfCharSet; \
  103. (lpLogFont)->lfOutPrecision = (lpLogFont16)->lfOutPrecision; \
  104. (lpLogFont)->lfClipPrecision = (lpLogFont16)->lfClipPrecision; \
  105. (lpLogFont)->lfQuality = (lpLogFont16)->lfQuality; \
  106. (lpLogFont)->lfPitchAndFamily = (lpLogFont16)->lfPitchAndFamily; \
  107. strncpy((lpLogFont)->lfFaceName,(lpLogFont16)->lfFaceName,LF_FACESIZE);\
  108. }
  109. #define LOGPEN32FROMLOGPEN16(pLogPen, pLogPen16) \
  110. { \
  111. (pLogPen)->lopnStyle = (pLogPen16)->lopnStyle; \
  112. (pLogPen)->lopnWidth.x = (pLogPen16)->lopnWidth.x; \
  113. (pLogPen)->lopnWidth.y = (pLogPen16)->lopnWidth.y; \
  114. (pLogPen)->lopnColor = (pLogPen16)->lopnColor; \
  115. }
  116. // Macros for convert 16 bit objects to 32 bit equivalents
  117. #define BITMAP16FROMBITMAP32(pBitmap16,pBitmap) \
  118. { \
  119. (pBitmap16)->bmType = (SHORT)(pBitmap)->bmType; \
  120. (pBitmap16)->bmWidth = (SHORT)(pBitmap)->bmWidth; \
  121. (pBitmap16)->bmHeight = (SHORT)(pBitmap)->bmHeight; \
  122. (pBitmap16)->bmWidthBytes= (SHORT)(pBitmap)->bmWidthBytes; \
  123. (pBitmap16)->bmPlanes = (BYTE)(pBitmap)->bmPlanes; \
  124. (pBitmap16)->bmBitsPixel = (BYTE)(pBitmap)->bmBitsPixel; \
  125. (pBitmap16)->bmBits = (pBitmap)->bmBits; \
  126. }
  127. #define LOGBRUSH16FROMLOGBRUSH32(pLogBrush16,pLogBrush) \
  128. { \
  129. (pLogBrush16)->lbStyle = (WORD)(pLogBrush)->lbStyle; \
  130. ASSERTGDI((pLogBrush16)->lbStyle == BS_SOLID \
  131. || (pLogBrush16)->lbStyle == BS_HATCHED \
  132. || (pLogBrush16)->lbStyle == BS_HOLLOW, \
  133. "LOGBRUSH16FROMLOGBRUSH32: unexpected lbStyle"); \
  134. (pLogBrush16)->lbColor = (pLogBrush)->lbColor; \
  135. (pLogBrush16)->lbHatch = (SHORT)(pLogBrush)->lbHatch; \
  136. }
  137. #define LOGPEN16FROMLOGPEN32(pLogPen16,pLogPen) \
  138. { \
  139. (pLogPen16)->lopnStyle = (WORD)(pLogPen)->lopnStyle; \
  140. (pLogPen16)->lopnWidth.x = (SHORT)(pLogPen)->lopnWidth.x; \
  141. (pLogPen16)->lopnWidth.y = (SHORT)(pLogPen)->lopnWidth.y; \
  142. (pLogPen16)->lopnColor = (pLogPen)->lopnColor; \
  143. }
  144. #define LOGFONT16FROMLOGFONT32(pLogFont16,pLogFont) \
  145. { \
  146. ASSERTGDI((sizeof(LOGFONTA) == (sizeof(LOGFONT16)+sizeof(WORD)*5)), \
  147. "MF16.h: LOGFONT(32) and LOGFONT(16) changed!"); \
  148. (pLogFont16)->lfHeight = (SHORT)(pLogFont)->lfHeight; \
  149. (pLogFont16)->lfWidth = (SHORT)(pLogFont)->lfWidth; \
  150. (pLogFont16)->lfEscapement = (SHORT)(pLogFont)->lfEscapement; \
  151. (pLogFont16)->lfOrientation = (SHORT)(pLogFont)->lfOrientation; \
  152. (pLogFont16)->lfWeight = (SHORT)(pLogFont)->lfWeight; \
  153. RtlCopyMemory((PVOID)&(pLogFont16)->lfItalic, \
  154. (CONST VOID *)&(pLogFont)->lfItalic, \
  155. sizeof(LOGFONTA)-sizeof(LONG)*5); \
  156. }
  157. /*** MetaFile Internal Constants and Macros ***/
  158. #define METAVERSION300 0x0300
  159. #define METAVERSION100 0x0100
  160. // Metafile constants not in Windows.h
  161. #define MEMORYMETAFILE 1
  162. #define DISKMETAFILE 2
  163. #define METAFILEFAILURE 1 // Flags denoting metafile is aborted
  164. #define MF16_BUFSIZE_INIT (16*1024) // Metafile memory buffer size
  165. #define MF16_BUFSIZE_INC (16*1024) // Metafile buffer increment size
  166. #define ID_METADC16 0x444D // "MD"
  167. #define MF16_IDENTIFIER 0x3631464D // "MF16"
  168. #define MF3216_INCLUDE_WIN32MF 0x0001
  169. // Constants for MFCOMMENT Escape
  170. #define MFCOMMENT_IDENTIFIER 0x43464D57
  171. #define MFCOMMENT_ENHANCED_METAFILE 1
  172. // pmf16AllocMF16 flags
  173. #define ALLOCMF16_TRANSFER_BUFFER 0x1
  174. // METAFILE16 flags
  175. #define MF16_DISKFILE 0x0001 // Disk or memory metafile.
  176. // *** MetaFile Internal TypeDefs ***
  177. typedef struct _METAFILE16 {
  178. DWORD ident;
  179. METAHEADER metaHeader;
  180. HANDLE hFile;
  181. HANDLE hFileMap;
  182. HANDLE hMem;
  183. DWORD iMem;
  184. HANDLE hMetaFileRecord;
  185. DWORD fl;
  186. WCHAR wszFullPathName[MAX_PATH+1];
  187. } METAFILE16,* PMETAFILE16;
  188. #define MIN_OBJ_TYPE OBJ_PEN
  189. #define MAX_OBJ_TYPE OBJ_ENHMETAFILE
  190. typedef struct _MFRECORDER16 {
  191. HANDLE hMem; // handle to the data (or buffer)
  192. HANDLE hFile; // handle to the disk file
  193. DWORD cbBuffer; // current size of hMem
  194. DWORD ibBuffer; // current position in buffer
  195. METAHEADER metaHeader;
  196. WORD recFlags;
  197. HANDLE hObjectTable;
  198. HANDLE recCurObjects[MAX_OBJ_TYPE];// Current Selected Object
  199. UINT iPalVer; // index of palette metafile synced to
  200. WCHAR wszFullPathName[MAX_PATH+1];
  201. } MFRECORDER16, * PMFRECORDER16;
  202. typedef struct _OBJECTTABLE {
  203. HANDLE CurHandle;
  204. BOOL fPreDeleted;
  205. } OBJECTTABLE, * POBJECTTABLE;
  206. #pragma pack(2)
  207. typedef struct _SCAN {
  208. WORD scnPntCnt; // Scan point count
  209. WORD scnPntTop; // Top of scan
  210. WORD scnPntBottom; // Bottom of scan
  211. WORD scnPntsX[2]; // Start of points in scan
  212. WORD scnPtCntToo; // Point count-- to allow UP travel
  213. } SCAN;
  214. typedef SCAN UNALIGNED *PSCAN;
  215. typedef struct _WIN3REGION {
  216. WORD nextInChain; // Not used should be zero
  217. WORD ObjType; // Must always be 6 (Windows OBJ_RGN)
  218. DWORD ObjCount; // Not used
  219. WORD cbRegion; // size of following region struct
  220. WORD cScans;
  221. WORD maxScan;
  222. RECT16 rcBounding;
  223. SCAN aScans[1];
  224. } WIN3REGION;
  225. typedef WIN3REGION UNALIGNED *PWIN3REGION;
  226. typedef struct _META_ESCAPE_ENHANCED_METAFILE {
  227. DWORD rdSize; // Size of the record in words
  228. WORD rdFunction; // META_ESCAPE
  229. WORD wEscape; // MFCOMMENT
  230. WORD wCount; // Size of the following data + emf in bytes
  231. DWORD ident; // MFCOMMENT_IDENTIFIER
  232. DWORD iComment; // MFCOMMENT_ENHANCED_METAFILE
  233. DWORD nVersion; // Enhanced metafile version 0x10000
  234. WORD wChecksum; // Checksum - used by 1st record only
  235. DWORD fFlags; // Compression etc - used by 1st record only
  236. DWORD nCommentRecords; // Number of records making up the emf
  237. DWORD cbCurrent; // Size of emf data in this record in bytes
  238. DWORD cbRemainder; // Size of remainder in following records
  239. DWORD cbEnhMetaFile; // Size of enhanced metafile in bytes
  240. // The enhanced metafile data follows here
  241. } META_ESCAPE_ENHANCED_METAFILE;
  242. typedef META_ESCAPE_ENHANCED_METAFILE UNALIGNED *PMETA_ESCAPE_ENHANCED_METAFILE;
  243. #pragma pack()
  244. // Macro to check that it is a meta_escape embedded enhanced metafile record.
  245. #define IS_META_ESCAPE_ENHANCED_METAFILE(pmfeEnhMF) \
  246. ((pmfeEnhMF)->rdFunction == META_ESCAPE \
  247. && (pmfeEnhMF)->rdSize > sizeof(META_ESCAPE_ENHANCED_METAFILE) / 2 \
  248. && (pmfeEnhMF)->wEscape == MFCOMMENT \
  249. && (pmfeEnhMF)->ident == MFCOMMENT_IDENTIFIER \
  250. && (pmfeEnhMF)->iComment == MFCOMMENT_ENHANCED_METAFILE)
  251. // Internal Function Declarations
  252. PMETARECORD GetEvent(PMETAFILE16 pmf,PMETARECORD pmr);
  253. DWORD GetObject16AndType(HANDLE hObj, LPVOID lpObjectBuf);
  254. BOOL IsValidMetaHeader16(PMETAHEADER pMetaHeader);
  255. WORD RecordObject(HDC hdc, HANDLE hObject);
  256. BOOL RecordParms(HDC hDC, DWORD magic, DWORD cw, CONST WORD *lpParm);
  257. UINT ConvertEmfToWmf(PVOID pht, PBYTE pMeta32, UINT cbMeta16, PBYTE pMeta16, INT mm, HDC hdc, UINT f);
  258. PMETAFILE16 pmf16AllocMF16(DWORD fl, DWORD cb, CONST UNALIGNED DWORD *pb, LPCWSTR pwszFilename);
  259. VOID vFreeMF16(PMETAFILE16 pmf16);
  260. BOOL bMetaGetDIBInfo(HDC hdc, HBITMAP hbm,
  261. PBITMAPINFOHEADER pBmih, PDWORD pcbBmi, PDWORD pcbBits,
  262. DWORD iUsage, LONG cScans, BOOL bMeta16);
  263. BOOL APIENTRY IsValidEnhMetaRecord(PVOID pht, PVOID pmr);
  264. BOOL APIENTRY IsValidEnhMetaRecordOffExt(PVOID pht, PVOID pmr, DWORD Off, DWORD Ext);
  265. #define hmf16Create(pmf16) hCreateClientObjLink((PVOID)pmf16,LO_METAFILE16_TYPE)
  266. #define bDeleteHmf16(hmf) bDeleteClientObjLink((HANDLE)hmf)
  267. #define GET_PMF16(hmf) ((PMETAFILE16)pvClientObjGet((HANDLE)hmf,LO_METAFILE16_TYPE))