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.

867 lines
22 KiB

  1. /****************************************************************************
  2. *
  3. * Win16 Metafile emitter routines
  4. *
  5. * Date: 7/19/91
  6. * Author: Jeffrey Newman (c-jeffn)
  7. *
  8. ***************************************************************************/
  9. #include "precomp.h"
  10. #pragma hdrstop
  11. WORD GetSizeOfColorTable (LPBITMAPINFOHEADER lpDIBInfo);
  12. /****************************************************************************
  13. * bW16Emit0 - This is the base routine to emit a Win16 drawing order
  14. * with 0 parameters.
  15. ***************************************************************************/
  16. BOOL bW16Emit0
  17. (
  18. PLOCALDC pLocalDC,
  19. WORD RecordID
  20. )
  21. {
  22. BOOL b;
  23. METARECORD0 mr;
  24. mr.rdSize = sizeof(mr) / sizeof(WORD);
  25. mr.rdFunction = RecordID;
  26. b = bEmit(pLocalDC, &mr, sizeof(mr));
  27. // Update the global max record size.
  28. vUpdateMaxRecord(pLocalDC, (PMETARECORD) &mr);
  29. return(b);
  30. }
  31. /****************************************************************************
  32. * bW16Emit1 - This is the base routine to emit a Win16 drawing order
  33. * with 1 parameter.
  34. ***************************************************************************/
  35. BOOL bW16Emit1
  36. (
  37. PLOCALDC pLocalDC,
  38. WORD RecordID,
  39. WORD x1
  40. )
  41. {
  42. BOOL b;
  43. METARECORD1 mr;
  44. mr.rdSize = sizeof(mr) / sizeof(WORD);
  45. mr.rdFunction = RecordID;
  46. mr.rdParm[0] = x1;
  47. b = bEmit(pLocalDC, &mr, sizeof(mr));
  48. // Update the global max record size.
  49. vUpdateMaxRecord(pLocalDC, (PMETARECORD) &mr);
  50. return(b);
  51. }
  52. /****************************************************************************
  53. * bW16Emit2 - This is the base routine to emit a Win16 drawing order
  54. * with 2 parameters.
  55. ***************************************************************************/
  56. BOOL bW16Emit2
  57. (
  58. PLOCALDC pLocalDC,
  59. WORD RecordID,
  60. WORD x1,
  61. WORD x2
  62. )
  63. {
  64. BOOL b;
  65. METARECORD2 mr;
  66. mr.rdSize = sizeof(mr) / sizeof(WORD);
  67. mr.rdFunction = RecordID;
  68. mr.rdParm[0] = x2;
  69. mr.rdParm[1] = x1;
  70. b = bEmit(pLocalDC, &mr, sizeof(mr));
  71. // Update the global max record size.
  72. vUpdateMaxRecord(pLocalDC, (PMETARECORD) &mr);
  73. return(b);
  74. }
  75. /****************************************************************************
  76. * bW16Emit4 - This is the base routine to emit a Win16 drawing order
  77. * with 4 parameters.
  78. ***************************************************************************/
  79. BOOL bW16Emit4
  80. (
  81. PLOCALDC pLocalDC,
  82. WORD RecordID,
  83. WORD x1,
  84. WORD x2,
  85. WORD x3,
  86. WORD x4
  87. )
  88. {
  89. BOOL b;
  90. METARECORD4 mr;
  91. mr.rdSize = sizeof(mr) / sizeof(WORD);
  92. mr.rdFunction = RecordID;
  93. mr.rdParm[0] = x4;
  94. mr.rdParm[1] = x3;
  95. mr.rdParm[2] = x2;
  96. mr.rdParm[3] = x1;
  97. b = bEmit(pLocalDC, &mr, sizeof(mr));
  98. // Update the global max record size.
  99. vUpdateMaxRecord(pLocalDC, (PMETARECORD) &mr);
  100. return(b);
  101. }
  102. /****************************************************************************
  103. * bW16Emit5 - This is the base routine to emit a Win16 drawing order
  104. * with 5 parameters.
  105. ***************************************************************************/
  106. BOOL bW16Emit5
  107. (
  108. PLOCALDC pLocalDC,
  109. WORD RecordID,
  110. WORD x1,
  111. WORD x2,
  112. WORD x3,
  113. WORD x4,
  114. WORD x5
  115. )
  116. {
  117. BOOL b;
  118. METARECORD5 mr;
  119. mr.rdSize = sizeof(mr) / sizeof(WORD);
  120. mr.rdFunction = RecordID;
  121. mr.rdParm[0] = x5;
  122. mr.rdParm[1] = x4;
  123. mr.rdParm[2] = x3;
  124. mr.rdParm[3] = x2;
  125. mr.rdParm[4] = x1;
  126. b = bEmit(pLocalDC, &mr, sizeof(mr));
  127. // Update the global max record size.
  128. vUpdateMaxRecord(pLocalDC, (PMETARECORD) &mr);
  129. return(b);
  130. }
  131. /****************************************************************************
  132. * bW16Emit6 - This is the base routine to emit a Win16 drawing order
  133. * with 6 parameters.
  134. ***************************************************************************/
  135. BOOL bW16Emit6
  136. (
  137. PLOCALDC pLocalDC,
  138. WORD RecordID,
  139. WORD x1,
  140. WORD x2,
  141. WORD x3,
  142. WORD x4,
  143. WORD x5,
  144. WORD x6
  145. )
  146. {
  147. BOOL b;
  148. METARECORD6 mr;
  149. mr.rdSize = sizeof(mr) / sizeof(WORD);
  150. mr.rdFunction = RecordID;
  151. mr.rdParm[0] = x6;
  152. mr.rdParm[1] = x5;
  153. mr.rdParm[2] = x4;
  154. mr.rdParm[3] = x3;
  155. mr.rdParm[4] = x2;
  156. mr.rdParm[5] = x1;
  157. b = bEmit(pLocalDC, &mr, sizeof(mr));
  158. // Update the global max record size.
  159. vUpdateMaxRecord(pLocalDC, (PMETARECORD) &mr);
  160. return(b);
  161. }
  162. /****************************************************************************
  163. * bW16Emit8 - This is the base routine to emit a Win16 drawing order
  164. * with 8 parameters.
  165. ***************************************************************************/
  166. BOOL bW16Emit8
  167. (
  168. PLOCALDC pLocalDC,
  169. WORD RecordID,
  170. WORD x1,
  171. WORD x2,
  172. WORD x3,
  173. WORD x4,
  174. WORD x5,
  175. WORD x6,
  176. WORD x7,
  177. WORD x8
  178. )
  179. {
  180. BOOL b;
  181. METARECORD8 mr;
  182. mr.rdSize = sizeof(mr) / sizeof(WORD);
  183. mr.rdFunction = RecordID;
  184. mr.rdParm[0] = x8;
  185. mr.rdParm[1] = x7;
  186. mr.rdParm[2] = x6;
  187. mr.rdParm[3] = x5;
  188. mr.rdParm[4] = x4;
  189. mr.rdParm[5] = x3;
  190. mr.rdParm[6] = x2;
  191. mr.rdParm[7] = x1;
  192. b = bEmit(pLocalDC, &mr, sizeof(mr));
  193. // Update the global max record size.
  194. vUpdateMaxRecord(pLocalDC, (PMETARECORD) &mr);
  195. return(b);
  196. }
  197. /****************************************************************************
  198. * bW16Emit9 - This is the base routine to emit a Win16 drawing order
  199. * with 9 parameters.
  200. ***************************************************************************/
  201. BOOL bW16Emit9
  202. (
  203. PLOCALDC pLocalDC,
  204. WORD RecordID,
  205. WORD x1,
  206. WORD x2,
  207. WORD x3,
  208. WORD x4,
  209. WORD x5,
  210. WORD x6,
  211. WORD x7,
  212. WORD x8,
  213. WORD x9
  214. )
  215. {
  216. BOOL b;
  217. METARECORD9 mr;
  218. mr.rdSize = sizeof(mr) / sizeof(WORD);
  219. mr.rdFunction = RecordID;
  220. mr.rdParm[0] = x9;
  221. mr.rdParm[1] = x8;
  222. mr.rdParm[2] = x7;
  223. mr.rdParm[3] = x6;
  224. mr.rdParm[4] = x5;
  225. mr.rdParm[5] = x4;
  226. mr.rdParm[6] = x3;
  227. mr.rdParm[7] = x2;
  228. mr.rdParm[8] = x1;
  229. b = bEmit(pLocalDC, &mr, sizeof(mr));
  230. // Update the global max record size.
  231. vUpdateMaxRecord(pLocalDC, (PMETARECORD) &mr);
  232. return(b);
  233. }
  234. /****************************************************************************
  235. * CreateFontIndirect - Win16 Metafile Emitter
  236. ***************************************************************************/
  237. BOOL bEmitWin16CreateFontIndirect
  238. (
  239. PLOCALDC pLocalDC,
  240. LPWIN16LOGFONT lpWin16LogFont
  241. )
  242. {
  243. BOOL b;
  244. METARECORD_CREATEFONTINDIRECT mr;
  245. mr.rdSize = sizeof(mr) / sizeof(WORD);
  246. mr.rdFunction = META_CREATEFONTINDIRECT;
  247. mr.lf16 = *lpWin16LogFont;
  248. b = bEmit(pLocalDC, &mr, sizeof(mr));
  249. // Update the global max record size.
  250. vUpdateMaxRecord(pLocalDC, (PMETARECORD) &mr);
  251. return(b);
  252. }
  253. /****************************************************************************
  254. * Polyline/Polygon - Win16 Metafile Emitter
  255. ***************************************************************************/
  256. BOOL bEmitWin16Poly
  257. (
  258. PLOCALDC pLocalDC,
  259. LPPOINTS ppt,
  260. SHORT cpt,
  261. WORD metaType
  262. )
  263. {
  264. BOOL b ;
  265. WORD nSize ;
  266. METARECORD_POLY mr;
  267. // Caculate the size of the points array
  268. nSize = (WORD) (cpt * sizeof(POINTS));
  269. // Build up the header of the Win16 poly record
  270. mr.rdSize = (sizeof(mr) + nSize) / sizeof(WORD);
  271. mr.rdFunction = metaType;
  272. mr.cpt = cpt;
  273. // Emit the Header, then if it succeds emit the points.
  274. b = bEmit(pLocalDC, &mr, sizeof(mr));
  275. if (b)
  276. {
  277. b = bEmit(pLocalDC, ppt, nSize);
  278. }
  279. // Update the global max record size.
  280. vUpdateMaxRecord(pLocalDC, (PMETARECORD) &mr);
  281. return(b);
  282. }
  283. /****************************************************************************
  284. * PolyPolygon - Win16 Metafile Emitter
  285. ***************************************************************************/
  286. BOOL bEmitWin16PolyPolygon
  287. (
  288. PLOCALDC pLocalDC,
  289. PPOINTS ppt,
  290. PWORD pcpt,
  291. WORD cpt,
  292. WORD ccpt
  293. )
  294. {
  295. BOOL b ;
  296. WORD nSize ;
  297. METARECORD_POLYPOLYGON mr;
  298. nSize = cpt * sizeof(POINTS);
  299. nSize += ccpt * sizeof(WORD);
  300. nSize += sizeof(mr);
  301. // Build up the header of the Win16 polyline record
  302. mr.rdSize = nSize / sizeof(WORD);
  303. mr.rdFunction = META_POLYPOLYGON;
  304. mr.ccpt = ccpt;
  305. // Emit the Header, then if it succeds emit the Point counts,
  306. // then if it succeds emit the points.
  307. b = bEmit(pLocalDC, &mr, sizeof(mr));
  308. if (b)
  309. {
  310. b = bEmit(pLocalDC, pcpt, ccpt * sizeof(WORD));
  311. if (b)
  312. {
  313. b = bEmit(pLocalDC, ppt, cpt * sizeof(POINTS));
  314. }
  315. }
  316. // Update the global max record size.
  317. vUpdateMaxRecord(pLocalDC, (PMETARECORD) &mr);
  318. return(b);
  319. }
  320. /****************************************************************************
  321. * StretchBlt - Win16 Metafile Emitter
  322. ***************************************************************************/
  323. BOOL bEmitWin16StretchBlt
  324. (
  325. PLOCALDC pLocalDC,
  326. SHORT x,
  327. SHORT y,
  328. SHORT cx,
  329. SHORT cy,
  330. SHORT xSrc,
  331. SHORT ySrc,
  332. SHORT cxSrc,
  333. SHORT cySrc,
  334. DWORD rop,
  335. PBITMAPINFO lpbmi,
  336. DWORD cbbmi,
  337. PBYTE lpBits,
  338. DWORD cbBits
  339. )
  340. {
  341. BOOL b ;
  342. DWORD nSize ;
  343. METARECORD_DIBSTRETCHBLT mr;
  344. DWORD clrUsed;
  345. WORD clrTableSize;
  346. WORD newClrTableSize;
  347. PBITMAPINFO lpnewbmi;
  348. DWORD newcbbmi;
  349. // Need to make real sure the plane count is 1,
  350. // otherwise this is not a DIB.
  351. if (lpbmi->bmiHeader.biPlanes != 1)
  352. {
  353. RIPS("MF3216: bEmitWin16StretchBlt, Invalid biPlanes in DIB\n") ;
  354. return (FALSE) ;
  355. }
  356. lpnewbmi = NULL;
  357. newcbbmi = 0;
  358. // Some programs don't work well with ClrUsed so always fill the palette
  359. clrTableSize = GetSizeOfColorTable((LPBITMAPINFOHEADER)lpbmi);
  360. clrUsed = lpbmi->bmiHeader.biClrUsed;
  361. lpbmi->bmiHeader.biClrUsed = 0;
  362. newClrTableSize = GetSizeOfColorTable((LPBITMAPINFOHEADER)lpbmi);
  363. if (newClrTableSize != clrTableSize)
  364. {
  365. // It can happen that we are passed a color table bigger then we
  366. // expect. So only copy the size of the new colortable
  367. newcbbmi = lpbmi->bmiHeader.biSize + newClrTableSize;
  368. lpnewbmi = (PBITMAPINFO) LocalAlloc(LMEM_FIXED, newcbbmi);
  369. if (lpnewbmi != NULL)
  370. {
  371. // Copy the old header and fill the rest of the palette with 0
  372. memcpy((void*) lpnewbmi, (void*)lpbmi, min(cbbmi, newcbbmi));
  373. if (newcbbmi > cbbmi)
  374. {
  375. memset((void*) (((char*)lpnewbmi) + cbbmi), 0, newcbbmi - cbbmi);
  376. }
  377. lpbmi = lpnewbmi;
  378. cbbmi = newcbbmi;
  379. }
  380. }
  381. // Create the static portion of the
  382. // Win 3.0 StretchBlt metafile record.
  383. nSize = sizeof(mr) + cbbmi + cbBits;
  384. mr.rdSize = nSize / sizeof(WORD);
  385. mr.rdFunction = META_DIBSTRETCHBLT;
  386. mr.rop = rop;
  387. mr.cySrc = cySrc;
  388. mr.cxSrc = cxSrc;
  389. mr.ySrc = ySrc;
  390. mr.xSrc = xSrc;
  391. mr.cy = cy;
  392. mr.cx = cx;
  393. mr.y = y;
  394. mr.x = x;
  395. b = bEmit(pLocalDC, &mr, sizeof(mr));
  396. if (b)
  397. {
  398. // Emit the bitmap info
  399. b = bEmit(pLocalDC, lpbmi, cbbmi);
  400. if (b)
  401. {
  402. // Emit the actual bits, if any.
  403. b = bEmit(pLocalDC, lpBits, cbBits);
  404. }
  405. }
  406. // Update the global max record size.
  407. vUpdateMaxRecord(pLocalDC, (PMETARECORD) &mr);
  408. if (lpnewbmi != NULL)
  409. {
  410. LocalFree((HLOCAL) lpnewbmi);
  411. }
  412. return(b);
  413. }
  414. /****************************************************************************
  415. * ExtTextOut - Win16 Metafile Emitter
  416. ***************************************************************************/
  417. BOOL bEmitWin16ExtTextOut
  418. (
  419. PLOCALDC pLocalDC,
  420. SHORT x,
  421. SHORT y,
  422. WORD fwOpts,
  423. PRECTS prcts,
  424. PSTR ach,
  425. SHORT nCount,
  426. PWORD lpDx
  427. )
  428. {
  429. BOOL b ;
  430. DWORD i, nBaseRecord ;
  431. WORD awRecord[11] ;
  432. // Calculate the size of the record
  433. i = ((WORD) nCount + 1) / 2 * 2; // i = size of string in bytes
  434. if (lpDx)
  435. i += (WORD) nCount * sizeof(WORD); // add in size of Dx vector
  436. i += sizeof(awRecord); // add in size of basic record
  437. if (!(fwOpts & (ETO_OPAQUE | ETO_CLIPPED)))
  438. i -= sizeof(RECTS); // adjust for a rectangle being present
  439. i /= sizeof(WORD) ; // change to word count
  440. // Set the record size, type,
  441. // x & y position, character count, and options.
  442. awRecord[0] = LOWORD(i) ;
  443. awRecord[1] = HIWORD(i) ;
  444. awRecord[2] = META_EXTTEXTOUT ;
  445. awRecord[3] = y ;
  446. awRecord[4] = x ;
  447. awRecord[5] = nCount ;
  448. awRecord[6] = fwOpts ;
  449. // Only if there is a opaque / clipping rectangle present
  450. // do we copy it over, other wise it is nonexistent.
  451. // We need to adjust the size of the Record emitted based upon
  452. // the existence of the opaque / clipping rectangle.
  453. nBaseRecord = 7 * sizeof(WORD) ;
  454. if (fwOpts & (ETO_OPAQUE | ETO_CLIPPED))
  455. {
  456. awRecord[7] = prcts->left ;
  457. awRecord[8] = prcts->top ;
  458. awRecord[9] = prcts->right ;
  459. awRecord[10] = prcts->bottom ;
  460. nBaseRecord += 4 * sizeof(WORD) ;
  461. }
  462. // Emit the record.
  463. b = bEmit(pLocalDC, awRecord, nBaseRecord) ;
  464. if (b)
  465. {
  466. // Emit the character string.
  467. i = ((WORD) nCount + 1) / 2 * 2 ;
  468. b = bEmit(pLocalDC, ach, i) ;
  469. if (b)
  470. {
  471. if (lpDx)
  472. {
  473. // Emit the intercharacter spacing array
  474. i = (WORD) (nCount * sizeof(WORD)) ;
  475. b = bEmit(pLocalDC, lpDx, i) ;
  476. }
  477. }
  478. }
  479. // Update the global max record size.
  480. vUpdateMaxRecord(pLocalDC, (PMETARECORD) awRecord) ;
  481. return(b) ;
  482. }
  483. /****************************************************************************
  484. * Create Region - Win16 Metafile Emitter
  485. ***************************************************************************/
  486. BOOL bEmitWin16CreateRegion
  487. (
  488. PLOCALDC pLocalDC,
  489. DWORD cbRgn,
  490. PVOID pRgn
  491. )
  492. {
  493. BOOL b;
  494. METARECORD0 mr;
  495. mr.rdSize = (sizeof(mr) + cbRgn) / sizeof(WORD);
  496. mr.rdFunction = META_CREATEREGION;
  497. // Emit the header.
  498. b = bEmit(pLocalDC, &mr, sizeof(mr));
  499. // Emit the region data.
  500. b = bEmit(pLocalDC, pRgn, cbRgn);
  501. // Update the global max record size.
  502. vUpdateMaxRecord(pLocalDC, (PMETARECORD) &mr);
  503. return(b);
  504. }
  505. /****************************************************************************
  506. * SetPaletteEntries - Win16 Metafile Emitter
  507. ***************************************************************************/
  508. BOOL bEmitWin16SetPaletteEntries
  509. (
  510. PLOCALDC pLocalDC,
  511. DWORD iStart,
  512. DWORD cEntries,
  513. LPPALETTEENTRY pPalEntries
  514. )
  515. {
  516. BOOL b ;
  517. DWORD cbPalEntries ;
  518. METARECORD_SETPALENTRIES mr;
  519. cbPalEntries = cEntries * sizeof(PALETTEENTRY);
  520. mr.rdSize = (sizeof(mr) + cbPalEntries) / sizeof(WORD);
  521. mr.rdFunction = META_SETPALENTRIES;
  522. mr.iStart = (WORD) iStart;
  523. mr.cEntries = (WORD) cEntries;
  524. // Emit the header.
  525. b = bEmit(pLocalDC, &mr, sizeof(mr));
  526. // Emit the actual palette entries.
  527. b = bEmit(pLocalDC, pPalEntries, cbPalEntries) ;
  528. // Update the global max record size.
  529. vUpdateMaxRecord(pLocalDC, (PMETARECORD) &mr);
  530. return(b);
  531. }
  532. /****************************************************************************
  533. * CreatePalette - Win16 Metafile Emitter
  534. ***************************************************************************/
  535. BOOL bEmitWin16CreatePalette
  536. (
  537. PLOCALDC pLocalDC,
  538. LPLOGPALETTE lpLogPal
  539. )
  540. {
  541. BOOL b;
  542. DWORD cbLogPal;
  543. METARECORD0 mr;
  544. cbLogPal = sizeof(LOGPALETTE) - sizeof(PALETTEENTRY)
  545. + lpLogPal->palNumEntries * sizeof(PALETTEENTRY) ;
  546. mr.rdSize = (sizeof(mr) + cbLogPal) / sizeof(WORD);
  547. mr.rdFunction = META_CREATEPALETTE;
  548. // Emit the header.
  549. b = bEmit(pLocalDC, &mr, sizeof(mr));
  550. // Emit the actual logpalette.
  551. b = bEmit(pLocalDC, lpLogPal, cbLogPal);
  552. // Update the global max record size.
  553. vUpdateMaxRecord(pLocalDC, (PMETARECORD) &mr);
  554. return (b) ;
  555. }
  556. /****************************************************************************
  557. * CreateBrushIndirect - Win16 Metafile Emitter
  558. ***************************************************************************/
  559. BOOL bEmitWin16CreateBrushIndirect
  560. (
  561. PLOCALDC pLocalDC,
  562. LPWIN16LOGBRUSH lpLogBrush16
  563. )
  564. {
  565. BOOL b;
  566. METARECORD_CREATEBRUSHINDIRECT mr;
  567. mr.rdSize = sizeof(mr) / sizeof(WORD);
  568. mr.rdFunction = META_CREATEBRUSHINDIRECT;
  569. mr.lb16 = *lpLogBrush16;
  570. b = bEmit(pLocalDC, &mr, sizeof(mr));
  571. // Update the global max record size.
  572. vUpdateMaxRecord(pLocalDC, (PMETARECORD) &mr);
  573. return(b);
  574. }
  575. /****************************************************************************
  576. * CreateDIPatternBrush - Win16 Metafile Emitter
  577. ***************************************************************************/
  578. BOOL bEmitWin16CreateDIBPatternBrush
  579. (
  580. PLOCALDC pLocalDC,
  581. PBITMAPINFO pBitmapInfo,
  582. DWORD cbBitmapInfo,
  583. PBYTE pBits,
  584. DWORD cbBits,
  585. WORD iUsage,
  586. WORD iType
  587. )
  588. {
  589. BOOL b ;
  590. METARECORD_DIBCREATEPATTERNBRUSH mr;
  591. mr.rdSize = (sizeof(mr) + cbBitmapInfo + cbBits + 1) / sizeof(WORD);
  592. mr.rdFunction = META_DIBCREATEPATTERNBRUSH;
  593. mr.iType = iType;
  594. mr.iUsage = iUsage;
  595. // On NT, the packed DIB is dword aligned. But on win3x, it is word aligned.
  596. // Therefore, we emit the bitmap info followed by the bitmap bits in two
  597. // separate stages.
  598. ASSERTGDI(cbBitmapInfo % 2 == 0,
  599. "MF3216: bEmitWin16CreateDIBPatternBrush, bad bitmap info size");
  600. // Emit the static portion of the record.
  601. b = bEmit(pLocalDC, &mr, sizeof(mr));
  602. if (b == FALSE)
  603. goto error_exit ;
  604. // Emit the bitmap info.
  605. b = bEmit(pLocalDC, pBitmapInfo, cbBitmapInfo) ;
  606. if (b == FALSE)
  607. goto error_exit ;
  608. // Emit the bitmap bits.
  609. b = bEmit(pLocalDC, pBits, (cbBits + 1) / sizeof(WORD) * sizeof(WORD)) ;
  610. // Update the global max record size.
  611. vUpdateMaxRecord(pLocalDC, (PMETARECORD) &mr);
  612. error_exit:
  613. return(b);
  614. }
  615. /****************************************************************************
  616. * CreatePen - Win16 Metafile Emitter
  617. ***************************************************************************/
  618. BOOL bEmitWin16CreatePen
  619. (
  620. PLOCALDC pLocalDC,
  621. WORD iPenStyle,
  622. PPOINTS pptsWidth,
  623. COLORREF crColor
  624. )
  625. {
  626. BOOL b;
  627. METARECORD_CREATEPENINDIRECT mr;
  628. mr.rdSize = sizeof(mr) / sizeof(WORD);
  629. mr.rdFunction = META_CREATEPENINDIRECT;
  630. mr.lopn16.lopnStyle = iPenStyle;
  631. mr.lopn16.lopnWidth = *pptsWidth;
  632. mr.lopn16.lopnColor = crColor;
  633. b = bEmit(pLocalDC, &mr, sizeof(mr));
  634. // Update the global max record size.
  635. vUpdateMaxRecord(pLocalDC, (PMETARECORD) &mr);
  636. return(b);
  637. }
  638. //#if 0
  639. /****************************************************************************
  640. * Escape - Win16 Metafile Emitter
  641. ***************************************************************************/
  642. BOOL bEmitWin16Escape
  643. (
  644. PLOCALDC pLocalDC,
  645. SHORT wEscape,
  646. SHORT wCount,
  647. LPSTR lpInData,
  648. LPSTR lpOutData
  649. )
  650. {
  651. BOOL b ;
  652. METARECORD_ESCAPE mr;
  653. NOTUSED(lpOutData) ;
  654. // Init the type & length field of the metafile record.
  655. // Then emit the header of the escape record to the Win16 metafile.
  656. mr.rdSize = (sizeof(mr) + (WORD) wCount) / sizeof(WORD);
  657. mr.rdFunction = META_ESCAPE;
  658. mr.wEscape = wEscape;
  659. mr.wCount = (WORD) wCount;
  660. b = bEmit(pLocalDC, &mr, sizeof(mr));
  661. if (b)
  662. {
  663. // Emit the actual data.
  664. b = bEmit(pLocalDC, lpInData, (DWORD) (WORD) wCount) ;
  665. }
  666. // Update the global max record size.
  667. vUpdateMaxRecord(pLocalDC, (PMETARECORD) &mr);
  668. return(b);
  669. }
  670. //#endif // 0
  671. /****************************************************************************
  672. * Escape - Win16 Metafile Emitter for enhanced metafile comment
  673. ***************************************************************************/
  674. BOOL bEmitWin16EscapeEnhMetaFile
  675. (
  676. PLOCALDC pLocalDC,
  677. PMETARECORD_ESCAPE pmfe,
  678. LPBYTE lpEmfData
  679. )
  680. {
  681. BOOL b ;
  682. PMETA_ESCAPE_ENHANCED_METAFILE pmfeEnhMF = (PMETA_ESCAPE_ENHANCED_METAFILE) pmfe;
  683. // Emit the header of the escape record to the Win16 metafile.
  684. b = bEmit(pLocalDC, (PVOID) pmfeEnhMF, sizeof(META_ESCAPE_ENHANCED_METAFILE));
  685. if (b)
  686. {
  687. // Emit the enhanced metafile data.
  688. b = bEmit(pLocalDC, lpEmfData, pmfeEnhMF->cbCurrent);
  689. }
  690. // Update the global max record size.
  691. vUpdateMaxRecord(pLocalDC, (PMETARECORD) pmfeEnhMF);
  692. return(b);
  693. }