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.

2585 lines
72 KiB

  1. /****************************************************************************
  2. * Handlers.c - Handlers for the Win32 metafile records
  3. *
  4. * DATE: 11-Dec-1991
  5. * Author: Jeffrey Newman (c-jeffn)
  6. *
  7. * Copyright (c) Microsoft Inc. 1991
  8. ****************************************************************************/
  9. #include "precomp.h"
  10. #pragma hdrstop
  11. // Max number of pointl's allowed on stack before explicit memory allocation.
  12. #define MAX_STACK_POINTL 128
  13. // Convert array of POINTSs to POINTLs.
  14. #define POINTS_TO_POINTL(pptl, ppts, cpt) \
  15. { \
  16. DWORD i; \
  17. for (i = 0; i < (cpt); i++) \
  18. { \
  19. (pptl)[i].x = (LONG) (ppts)[i].x; \
  20. (pptl)[i].y = (LONG) (ppts)[i].y; \
  21. } \
  22. }
  23. /**************************************************************************
  24. * Handler - NotImplemented
  25. *
  26. * The following 32-bit records have no equivalent 16-bit metafile records:
  27. * SETBRUSHORGEX
  28. *
  29. *************************************************************************/
  30. BOOL bHandleNotImplemented(PVOID pVoid, PLOCALDC pLocalDC)
  31. {
  32. PENHMETARECORD pemr ;
  33. INT iType ;
  34. NOTUSED(pLocalDC) ;
  35. pemr = (PENHMETARECORD) pVoid ;
  36. iType = pemr->iType ;
  37. if (iType != EMR_SETBRUSHORGEX
  38. && iType != EMR_SETCOLORADJUSTMENT
  39. && iType != EMR_SETMITERLIMIT
  40. && iType != EMR_SETICMMODE
  41. && iType != EMR_CREATECOLORSPACE
  42. && iType != EMR_SETCOLORSPACE
  43. && iType != EMR_DELETECOLORSPACE
  44. && iType != EMR_GLSRECORD
  45. && iType != EMR_GLSBOUNDEDRECORD
  46. && iType != EMR_PIXELFORMAT)
  47. {
  48. PUTS1("MF3216: bHandleNotImplemented - record not supported: %d\n", iType) ;
  49. }
  50. return(TRUE) ;
  51. }
  52. /**************************************************************************
  53. * Handler - GdiComment
  54. *************************************************************************/
  55. BOOL bHandleGdiComment(PVOID pVoid, PLOCALDC pLocalDC)
  56. {
  57. return(DoGdiComment(pLocalDC, (PEMR) pVoid));
  58. }
  59. /**************************************************************************
  60. * Handler - SetPaletteEntries
  61. *************************************************************************/
  62. BOOL bHandleSetPaletteEntries(PVOID pVoid, PLOCALDC pLocalDC)
  63. {
  64. BOOL b ;
  65. PEMRSETPALETTEENTRIES pMfSetPaletteEntries ;
  66. DWORD ihPal, iStart, cEntries ;
  67. PPALETTEENTRY pPalEntry ;
  68. pMfSetPaletteEntries = (PEMRSETPALETTEENTRIES) pVoid ;
  69. // Now do the translation.
  70. ihPal = pMfSetPaletteEntries->ihPal ;
  71. iStart = pMfSetPaletteEntries->iStart ;
  72. cEntries = pMfSetPaletteEntries->cEntries ;
  73. pPalEntry = pMfSetPaletteEntries->aPalEntries ;
  74. b = DoSetPaletteEntries(pLocalDC, ihPal, iStart, cEntries, pPalEntry) ;
  75. return (b) ;
  76. }
  77. /**************************************************************************
  78. * Handler - CreatePalette
  79. *************************************************************************/
  80. BOOL bHandleCreatePalette(PVOID pVoid, PLOCALDC pLocalDC)
  81. {
  82. BOOL b ;
  83. PEMRCREATEPALETTE pMfCreatePalette ;
  84. LPLOGPALETTE lpLogPal ;
  85. DWORD ihPal ;
  86. pMfCreatePalette = (PEMRCREATEPALETTE) pVoid ;
  87. // Now do the translation.
  88. ihPal = pMfCreatePalette->ihPal ;
  89. lpLogPal = &pMfCreatePalette->lgpl ;
  90. b = DoCreatePalette(pLocalDC, ihPal, lpLogPal) ;
  91. return (b) ;
  92. }
  93. /**************************************************************************
  94. * Handler - RealizePalette
  95. *************************************************************************/
  96. BOOL bHandleRealizePalette(PVOID pVoid, PLOCALDC pLocalDC)
  97. {
  98. BOOL b ;
  99. NOTUSED(pVoid);
  100. // Now do the translation.
  101. b = DoRealizePalette(pLocalDC) ;
  102. return (b) ;
  103. }
  104. /**************************************************************************
  105. * Handler - ResizePalette
  106. *************************************************************************/
  107. BOOL bHandleResizePalette(PVOID pVoid, PLOCALDC pLocalDC)
  108. {
  109. BOOL b ;
  110. PEMRRESIZEPALETTE pMfResizePalette ;
  111. DWORD ihPal, cEntries ;
  112. pMfResizePalette = (PEMRRESIZEPALETTE) pVoid ;
  113. // Now do the translation.
  114. ihPal = pMfResizePalette->ihPal ;
  115. cEntries = pMfResizePalette->cEntries ;
  116. b = DoResizePalette(pLocalDC, ihPal, cEntries) ;
  117. return (b) ;
  118. }
  119. /**************************************************************************
  120. * Handler - SelectPalette
  121. *************************************************************************/
  122. BOOL bHandleSelectPalette(PVOID pVoid, PLOCALDC pLocalDC)
  123. {
  124. BOOL b ;
  125. PEMRSELECTPALETTE pMfSelectPalette ;
  126. DWORD ihPal ;
  127. pMfSelectPalette = (PEMRSELECTPALETTE) pVoid ;
  128. // Now do the translation.
  129. ihPal = pMfSelectPalette->ihPal ;
  130. b = DoSelectPalette(pLocalDC, ihPal) ;
  131. return (b) ;
  132. }
  133. /**************************************************************************
  134. * Handler - OffsetClipRgn
  135. *************************************************************************/
  136. BOOL bHandleOffsetClipRgn(PVOID pVoid, PLOCALDC pLocalDC)
  137. {
  138. BOOL b ;
  139. PEMROFFSETCLIPRGN pMfOffsetClipRgn ;
  140. INT x, y ;
  141. pMfOffsetClipRgn = (PEMROFFSETCLIPRGN) pVoid ;
  142. // Now do the translation.
  143. x = pMfOffsetClipRgn->ptlOffset.x ;
  144. y = pMfOffsetClipRgn->ptlOffset.y ;
  145. b = DoOffsetClipRgn(pLocalDC, x, y) ;
  146. return (b) ;
  147. }
  148. /**************************************************************************
  149. * Handler - ExtSelectClipRgn
  150. *************************************************************************/
  151. BOOL bHandleExtSelectClipRgn(PVOID pVoid, PLOCALDC pLocalDC)
  152. {
  153. BOOL b ;
  154. PEMREXTSELECTCLIPRGN pMfExtSelectClipRgn ;
  155. INT cbRgnData, iMode ;
  156. LPRGNDATA pRgnData ;
  157. pMfExtSelectClipRgn = (PEMREXTSELECTCLIPRGN) pVoid ;
  158. // Now do the translation.
  159. cbRgnData = pMfExtSelectClipRgn->cbRgnData ;
  160. pRgnData = (LPRGNDATA) pMfExtSelectClipRgn->RgnData;
  161. iMode = pMfExtSelectClipRgn->iMode ;
  162. b = DoExtSelectClipRgn(pLocalDC, cbRgnData, pRgnData, iMode) ;
  163. return (b) ;
  164. }
  165. /**************************************************************************
  166. * Handler - SetMetaRgn
  167. *************************************************************************/
  168. BOOL bHandleSetMetaRgn(PVOID pVoid, PLOCALDC pLocalDC)
  169. {
  170. BOOL b ;
  171. NOTUSED(pVoid) ;
  172. b = DoSetMetaRgn(pLocalDC) ;
  173. return(b) ;
  174. }
  175. /**************************************************************************
  176. * Handler - PaintRgn
  177. *************************************************************************/
  178. BOOL bHandlePaintRgn(PVOID pVoid, PLOCALDC pLocalDC)
  179. {
  180. BOOL b ;
  181. PEMRPAINTRGN pMfPaintRgn ;
  182. INT cbRgnData;
  183. LPRGNDATA pRgnData ;
  184. pMfPaintRgn = (PEMRPAINTRGN) pVoid ;
  185. // Now do the translation.
  186. cbRgnData = pMfPaintRgn->cbRgnData ;
  187. pRgnData = (LPRGNDATA) pMfPaintRgn->RgnData;
  188. b = DoDrawRgn(pLocalDC, 0, 0, 0, cbRgnData, pRgnData, EMR_PAINTRGN);
  189. return (b) ;
  190. }
  191. /**************************************************************************
  192. * Handler - InvertRgn
  193. *************************************************************************/
  194. BOOL bHandleInvertRgn(PVOID pVoid, PLOCALDC pLocalDC)
  195. {
  196. BOOL b ;
  197. PEMRINVERTRGN pMfInvertRgn ;
  198. INT cbRgnData;
  199. LPRGNDATA pRgnData ;
  200. pMfInvertRgn = (PEMRINVERTRGN) pVoid ;
  201. // Now do the translation.
  202. cbRgnData = pMfInvertRgn->cbRgnData ;
  203. pRgnData = (LPRGNDATA) pMfInvertRgn->RgnData;
  204. b = DoDrawRgn(pLocalDC, 0, 0, 0, cbRgnData, pRgnData, EMR_INVERTRGN);
  205. return (b) ;
  206. }
  207. /**************************************************************************
  208. * Handler - FrameRgn
  209. *************************************************************************/
  210. BOOL bHandleFrameRgn(PVOID pVoid, PLOCALDC pLocalDC)
  211. {
  212. BOOL b ;
  213. PEMRFRAMERGN pMfFrameRgn ;
  214. INT ihBrush,
  215. cbRgnData,
  216. nWidth,
  217. nHeight ;
  218. LPRGNDATA pRgnData ;
  219. pMfFrameRgn = (PEMRFRAMERGN) pVoid ;
  220. // Now do the translation.
  221. ihBrush = pMfFrameRgn->ihBrush ;
  222. nWidth = pMfFrameRgn->szlStroke.cx ;
  223. nHeight = pMfFrameRgn->szlStroke.cy ;
  224. cbRgnData = pMfFrameRgn->cbRgnData ;
  225. pRgnData = (LPRGNDATA) pMfFrameRgn->RgnData;
  226. b = DoDrawRgn(pLocalDC, ihBrush, nWidth, nHeight, cbRgnData, pRgnData, EMR_FRAMERGN);
  227. return (b) ;
  228. }
  229. /**************************************************************************
  230. * Handler - FillRgn
  231. *************************************************************************/
  232. BOOL bHandleFillRgn(PVOID pVoid, PLOCALDC pLocalDC)
  233. {
  234. BOOL b ;
  235. PEMRFILLRGN pMfFillRgn ;
  236. INT ihBrush,
  237. cbRgnData;
  238. LPRGNDATA pRgnData ;
  239. // Set up the pointer the Doer uses to reference the
  240. // the Win32 drawing order. Also setup the drawing order specific
  241. // pointer.
  242. pMfFillRgn = (PEMRFILLRGN) pVoid ;
  243. // Now do the translation.
  244. ihBrush = pMfFillRgn->ihBrush ;
  245. cbRgnData = pMfFillRgn->cbRgnData ;
  246. pRgnData = (LPRGNDATA) pMfFillRgn->RgnData;
  247. b = DoDrawRgn(pLocalDC, ihBrush, 0, 0, cbRgnData, pRgnData, EMR_FILLRGN);
  248. return (b) ;
  249. }
  250. /**************************************************************************
  251. * Handler - IntersectClipRect
  252. *************************************************************************/
  253. BOOL bHandleIntersectClipRect(PVOID pVoid, PLOCALDC pLocalDC)
  254. {
  255. BOOL b ;
  256. PEMRINTERSECTCLIPRECT pMfIntersectClipRect ;
  257. INT xLeft, yTop, xRight, yBottom ;
  258. pMfIntersectClipRect = (PEMRINTERSECTCLIPRECT) pVoid ;
  259. // Now do the translation.
  260. xLeft = pMfIntersectClipRect->rclClip.left ;
  261. yTop = pMfIntersectClipRect->rclClip.top ;
  262. xRight = pMfIntersectClipRect->rclClip.right ;
  263. yBottom = pMfIntersectClipRect->rclClip.bottom ;
  264. b = DoClipRect(pLocalDC, xLeft, yTop, xRight, yBottom, EMR_INTERSECTCLIPRECT) ;
  265. return (b) ;
  266. }
  267. /**************************************************************************
  268. * Handler - ExcludeClipRect
  269. *************************************************************************/
  270. BOOL bHandleExcludeClipRect(PVOID pVoid, PLOCALDC pLocalDC)
  271. {
  272. BOOL b ;
  273. PEMREXCLUDECLIPRECT pMfExcludeClipRect ;
  274. INT xLeft, yTop, xRight, yBottom ;
  275. pMfExcludeClipRect = (PEMREXCLUDECLIPRECT) pVoid ;
  276. // Now do the translation.
  277. xLeft = pMfExcludeClipRect->rclClip.left ;
  278. yTop = pMfExcludeClipRect->rclClip.top ;
  279. xRight = pMfExcludeClipRect->rclClip.right ;
  280. yBottom = pMfExcludeClipRect->rclClip.bottom ;
  281. b = DoClipRect(pLocalDC, xLeft, yTop, xRight, yBottom, EMR_EXCLUDECLIPRECT) ;
  282. return (b) ;
  283. }
  284. /**************************************************************************
  285. * Handler - SetPixel
  286. *************************************************************************/
  287. BOOL bHandleSetPixel(PVOID pVoid, PLOCALDC pLocalDC)
  288. {
  289. BOOL b ;
  290. PEMRSETPIXELV pMfSetPixel ;
  291. INT x, y ;
  292. COLORREF crColor ;
  293. pMfSetPixel = (PEMRSETPIXELV) pVoid ;
  294. // Now do the translation.
  295. x = (INT) pMfSetPixel->ptlPixel.x ;
  296. y = (INT) pMfSetPixel->ptlPixel.y ;
  297. crColor = pMfSetPixel->crColor ;
  298. b = DoSetPixel(pLocalDC, x, y, crColor) ;
  299. return (b) ;
  300. }
  301. /**************************************************************************
  302. * Handler - ExtFloodFill
  303. *************************************************************************/
  304. BOOL bHandleExtFloodFill(PVOID pVoid, PLOCALDC pLocalDC)
  305. {
  306. BOOL b ;
  307. PEMREXTFLOODFILL pMfExtFloodFill ;
  308. INT x, y ;
  309. COLORREF crColor ;
  310. DWORD iMode ;
  311. pMfExtFloodFill = (PEMREXTFLOODFILL) pVoid ;
  312. // Now do the translation.
  313. x = (INT) pMfExtFloodFill->ptlStart.x ;
  314. y = (INT) pMfExtFloodFill->ptlStart.y ;
  315. crColor = pMfExtFloodFill->crColor ;
  316. iMode = pMfExtFloodFill->iMode ;
  317. b = DoExtFloodFill(pLocalDC, x, y, crColor, iMode) ;
  318. return (b) ;
  319. }
  320. /**************************************************************************
  321. * Handler - ModifyWorldTransform
  322. *************************************************************************/
  323. BOOL bHandleModifyWorldTransform(PVOID pVoid, PLOCALDC pLocalDC)
  324. {
  325. BOOL b ;
  326. PEMRMODIFYWORLDTRANSFORM pMfModifyWorldTransform ;
  327. PXFORM pxform ;
  328. DWORD iMode ;
  329. pMfModifyWorldTransform = (PEMRMODIFYWORLDTRANSFORM) pVoid ;
  330. // get a pointer to the xform matrix
  331. pxform = &pMfModifyWorldTransform->xform ;
  332. iMode = pMfModifyWorldTransform->iMode ;
  333. // Now do the translation.
  334. b = DoModifyWorldTransform(pLocalDC, pxform, iMode) ;
  335. return (b) ;
  336. }
  337. /**************************************************************************
  338. * Handler - SetWorldTransform
  339. *************************************************************************/
  340. BOOL bHandleSetWorldTransform(PVOID pVoid, PLOCALDC pLocalDC)
  341. {
  342. BOOL b ;
  343. PEMRSETWORLDTRANSFORM pMfSetWorldTransform ;
  344. PXFORM pxform ;
  345. pMfSetWorldTransform = (PEMRSETWORLDTRANSFORM) pVoid ;
  346. // get a pointer to the xform matrix
  347. pxform = &pMfSetWorldTransform->xform ;
  348. // Now do the translation.
  349. b = DoSetWorldTransform(pLocalDC, pxform) ;
  350. return (b) ;
  351. }
  352. /**************************************************************************
  353. * Handler - PolyBezierTo
  354. *************************************************************************/
  355. BOOL bHandlePolyBezierTo(PVOID pVoid, PLOCALDC pLocalDC)
  356. {
  357. BOOL b ;
  358. PEMRPOLYBEZIERTO pMfPolyBezierTo ;
  359. DWORD nCount ;
  360. PPOINTL pptl ;
  361. pMfPolyBezierTo = (PEMRPOLYBEZIERTO) pVoid ;
  362. // Copy the BezierTo count and the polyBezierTo verticies to
  363. // the record.
  364. nCount = pMfPolyBezierTo->cptl ;
  365. pptl = pMfPolyBezierTo->aptl ;
  366. // Now do the translation.
  367. b = DoPolyBezierTo(pLocalDC, (LPPOINT) pptl, nCount) ;
  368. return (b) ;
  369. }
  370. /**************************************************************************
  371. * Handler - PolyDraw
  372. *************************************************************************/
  373. BOOL bHandlePolyDraw(PVOID pVoid, PLOCALDC pLocalDC)
  374. {
  375. BOOL b ;
  376. PEMRPOLYDRAW pMfPolyDraw ;
  377. DWORD nCount ;
  378. PPOINTL pptl ;
  379. PBYTE pb ;
  380. pMfPolyDraw = (PEMRPOLYDRAW) pVoid ;
  381. // Copy the Draw count and the polyDraw verticies to
  382. // the record.
  383. nCount = pMfPolyDraw->cptl ;
  384. pptl = pMfPolyDraw->aptl ;
  385. pb = (PBYTE) &pMfPolyDraw->aptl[nCount];
  386. // Now do the translation.
  387. b = DoPolyDraw(pLocalDC, (LPPOINT) pptl, pb, nCount) ;
  388. return (b) ;
  389. }
  390. /**************************************************************************
  391. * Handler - PolyBezier
  392. *************************************************************************/
  393. BOOL bHandlePolyBezier(PVOID pVoid, PLOCALDC pLocalDC)
  394. {
  395. BOOL b ;
  396. PEMRPOLYBEZIER pMfPolyBezier ;
  397. DWORD nCount ;
  398. PPOINTL pptl ;
  399. pMfPolyBezier = (PEMRPOLYBEZIER) pVoid ;
  400. // Copy the Bezier count and the polyBezier verticies to
  401. // the record.
  402. nCount = pMfPolyBezier->cptl ;
  403. pptl = pMfPolyBezier->aptl ;
  404. // Now do the translation.
  405. b = DoPolyBezier(pLocalDC, (LPPOINT) pptl, nCount) ;
  406. return (b) ;
  407. }
  408. /**************************************************************************
  409. * Handler - Begin Path
  410. *************************************************************************/
  411. BOOL bHandleBeginPath(PVOID pVoid, PLOCALDC pLocalDC)
  412. {
  413. BOOL b ;
  414. NOTUSED(pVoid) ;
  415. b = DoBeginPath(pLocalDC) ;
  416. return (b) ;
  417. }
  418. /**************************************************************************
  419. * Handler - End Path
  420. *************************************************************************/
  421. BOOL bHandleEndPath(PVOID pVoid, PLOCALDC pLocalDC)
  422. {
  423. BOOL b ;
  424. NOTUSED(pVoid) ;
  425. b = DoEndPath(pLocalDC) ;
  426. return (b) ;
  427. }
  428. /**************************************************************************
  429. * Handler - Flatten Path
  430. *************************************************************************/
  431. BOOL bHandleFlattenPath(PVOID pVoid, PLOCALDC pLocalDC)
  432. {
  433. BOOL b ;
  434. NOTUSED(pVoid) ;
  435. b = DoFlattenPath(pLocalDC) ;
  436. return (b) ;
  437. }
  438. /**************************************************************************
  439. * Handler - CloseFigure
  440. *************************************************************************/
  441. BOOL bHandleCloseFigure(PVOID pVoid, PLOCALDC pLocalDC)
  442. {
  443. BOOL b ;
  444. NOTUSED(pVoid) ;
  445. b = DoCloseFigure(pLocalDC) ;
  446. return (b) ;
  447. }
  448. /**************************************************************************
  449. * Handler - Abort Path
  450. *************************************************************************/
  451. BOOL bHandleAbortPath(PVOID pVoid, PLOCALDC pLocalDC)
  452. {
  453. BOOL b ;
  454. NOTUSED(pVoid) ;
  455. b = DoAbortPath(pLocalDC) ;
  456. return (b) ;
  457. }
  458. /**************************************************************************
  459. * Handler - Stroke Path
  460. *************************************************************************/
  461. BOOL bHandleStrokePath(PVOID pVoid, PLOCALDC pLocalDC)
  462. {
  463. NOTUSED(pVoid) ;
  464. return(DoRenderPath(pLocalDC, EMR_STROKEPATH));
  465. }
  466. /**************************************************************************
  467. * Handler - Fill Path
  468. *************************************************************************/
  469. BOOL bHandleFillPath(PVOID pVoid, PLOCALDC pLocalDC)
  470. {
  471. NOTUSED(pVoid) ;
  472. return(DoRenderPath(pLocalDC, EMR_FILLPATH));
  473. }
  474. /**************************************************************************
  475. * Handler - Stroke and Fill Path
  476. *************************************************************************/
  477. BOOL bHandleStrokeAndFillPath(PVOID pVoid, PLOCALDC pLocalDC)
  478. {
  479. NOTUSED(pVoid) ;
  480. return(DoRenderPath(pLocalDC, EMR_STROKEANDFILLPATH));
  481. }
  482. /**************************************************************************
  483. * Handler - Widen Path
  484. *************************************************************************/
  485. BOOL bHandleWidenPath(PVOID pVoid, PLOCALDC pLocalDC)
  486. {
  487. BOOL b ;
  488. NOTUSED(pVoid) ;
  489. b = DoWidenPath(pLocalDC) ;
  490. return(b) ;
  491. }
  492. /**************************************************************************
  493. * Handler - Select Clip Path
  494. *************************************************************************/
  495. BOOL bHandleSelectClipPath(PVOID pVoid, PLOCALDC pLocalDC)
  496. {
  497. BOOL b ;
  498. PEMRSELECTCLIPPATH pMfSelectClipPath ;
  499. INT iMode ;
  500. pMfSelectClipPath = (PEMRSELECTCLIPPATH) pVoid ;
  501. iMode = (INT) pMfSelectClipPath->iMode ;
  502. b = DoSelectClipPath(pLocalDC, iMode) ;
  503. return(b) ;
  504. }
  505. /**************************************************************************
  506. * Handler - StretchDIBits
  507. *************************************************************************/
  508. BOOL bHandleStretchDIBits(PVOID pVoid, PLOCALDC pLocalDC)
  509. {
  510. PEMRSTRETCHDIBITS pMfStretchDIBits ;
  511. BOOL b ;
  512. LONG xDest ;
  513. LONG yDest ;
  514. LONG xSrc ;
  515. LONG ySrc ;
  516. LONG cxSrc ;
  517. LONG cySrc ;
  518. DWORD offBmiSrc ;
  519. DWORD cbBmiSrc ;
  520. DWORD offBitsSrc ;
  521. DWORD cbBitsSrc ;
  522. DWORD iUsageSrc ;
  523. DWORD dwRop ;
  524. LONG cxDest ;
  525. LONG cyDest ;
  526. LPBITMAPINFO lpBitmapInfo ;
  527. LPBYTE lpBits ;
  528. pMfStretchDIBits = (PEMRSTRETCHDIBITS) pVoid ;
  529. xDest = pMfStretchDIBits->xDest ;
  530. yDest = pMfStretchDIBits->yDest ;
  531. xSrc = pMfStretchDIBits->xSrc ;
  532. ySrc = pMfStretchDIBits->ySrc ;
  533. cxSrc = pMfStretchDIBits->cxSrc ;
  534. cySrc = pMfStretchDIBits->cySrc ;
  535. offBmiSrc = pMfStretchDIBits->offBmiSrc ;
  536. cbBmiSrc = pMfStretchDIBits->cbBmiSrc ;
  537. offBitsSrc = pMfStretchDIBits->offBitsSrc ;
  538. cbBitsSrc = pMfStretchDIBits->cbBitsSrc ;
  539. iUsageSrc = pMfStretchDIBits->iUsageSrc ;
  540. dwRop = pMfStretchDIBits->dwRop ;
  541. cxDest = pMfStretchDIBits->cxDest ;
  542. cyDest = pMfStretchDIBits->cyDest ;
  543. if (!IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  544. pMfStretchDIBits,
  545. offBmiSrc,
  546. cbBmiSrc) ||
  547. !IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  548. pMfStretchDIBits,
  549. offBitsSrc,
  550. cbBitsSrc))
  551. {
  552. EMFVALFAIL(("MF3216: bHandleStrectchDIBits failed\n"));
  553. return(FALSE);
  554. }
  555. lpBitmapInfo = (LPBITMAPINFO) ((PBYTE) pMfStretchDIBits + offBmiSrc) ;
  556. lpBits = (PBYTE) pMfStretchDIBits + offBitsSrc ;
  557. b = DoStretchDIBits(pLocalDC,
  558. xDest,
  559. yDest,
  560. cxDest,
  561. cyDest,
  562. dwRop,
  563. xSrc,
  564. ySrc,
  565. cxSrc,
  566. cySrc,
  567. iUsageSrc,
  568. lpBitmapInfo,
  569. cbBmiSrc,
  570. lpBits,
  571. cbBitsSrc ) ;
  572. return(b) ;
  573. }
  574. /**************************************************************************
  575. * Handler - SetDIBitsToDevice
  576. *************************************************************************/
  577. BOOL bHandleSetDIBitsToDevice(PVOID pVoid, PLOCALDC pLocalDC)
  578. {
  579. PEMRSETDIBITSTODEVICE pMfSetDIBitsToDevice ;
  580. BOOL b ;
  581. LONG xDest ;
  582. LONG yDest ;
  583. LONG xSrc ;
  584. LONG ySrc ;
  585. LONG cxSrc ;
  586. LONG cySrc ;
  587. DWORD offBmiSrc ;
  588. DWORD cbBmiSrc ;
  589. DWORD offBitsSrc ;
  590. DWORD cbBitsSrc ;
  591. DWORD iUsageSrc ;
  592. DWORD iStartScan ;
  593. DWORD cScans ;
  594. LPBITMAPINFO lpBitmapInfo ;
  595. LPBYTE lpBits ;
  596. pMfSetDIBitsToDevice = (PEMRSETDIBITSTODEVICE) pVoid ;
  597. xDest = pMfSetDIBitsToDevice->xDest ;
  598. yDest = pMfSetDIBitsToDevice->yDest ;
  599. xSrc = pMfSetDIBitsToDevice->xSrc ;
  600. ySrc = pMfSetDIBitsToDevice->ySrc ;
  601. cxSrc = pMfSetDIBitsToDevice->cxSrc ;
  602. cySrc = pMfSetDIBitsToDevice->cySrc ;
  603. offBmiSrc = pMfSetDIBitsToDevice->offBmiSrc ;
  604. cbBmiSrc = pMfSetDIBitsToDevice->cbBmiSrc ;
  605. offBitsSrc = pMfSetDIBitsToDevice->offBitsSrc ;
  606. cbBitsSrc = pMfSetDIBitsToDevice->cbBitsSrc ;
  607. iUsageSrc = pMfSetDIBitsToDevice->iUsageSrc ;
  608. iStartScan = pMfSetDIBitsToDevice->iStartScan ;
  609. cScans = pMfSetDIBitsToDevice->cScans ;
  610. if (!IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  611. pMfSetDIBitsToDevice,
  612. offBmiSrc,
  613. cbBmiSrc) ||
  614. !IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  615. pMfSetDIBitsToDevice,
  616. offBitsSrc,
  617. cbBitsSrc))
  618. {
  619. EMFVALFAIL(("MF3216: bHandleSetDIBitsToDevice failed\n"));
  620. return(FALSE);
  621. }
  622. lpBitmapInfo = (LPBITMAPINFO) ((PBYTE) pMfSetDIBitsToDevice + offBmiSrc) ;
  623. lpBits = (PBYTE) pMfSetDIBitsToDevice + offBitsSrc ;
  624. b = DoSetDIBitsToDevice(pLocalDC,
  625. xDest,
  626. yDest,
  627. xSrc,
  628. ySrc,
  629. cxSrc,
  630. cySrc,
  631. iUsageSrc,
  632. iStartScan,
  633. cScans,
  634. lpBitmapInfo,
  635. cbBmiSrc,
  636. lpBits,
  637. cbBitsSrc ) ;
  638. return(b) ;
  639. }
  640. /**************************************************************************
  641. * Handler - BitBlt
  642. *************************************************************************/
  643. BOOL bHandleBitBlt(PVOID pVoid, PLOCALDC pLocalDC)
  644. {
  645. BOOL b ;
  646. PEMRBITBLT pMfBitBlt ;
  647. LONG xDest ;
  648. LONG yDest ;
  649. LONG cxDest ;
  650. LONG cyDest ;
  651. DWORD dwRop ;
  652. LONG xSrc ;
  653. LONG ySrc ;
  654. PXFORM pxformSrc ;
  655. COLORREF crBkColorSrc ;
  656. DWORD iUsageSrc ;
  657. DWORD offBmiSrc ;
  658. DWORD cbBmiSrc ;
  659. DWORD offBitsSrc ;
  660. DWORD cbBitsSrc ;
  661. PBITMAPINFO pbmi ;
  662. LPBYTE lpBits ;
  663. pMfBitBlt = (PEMRBITBLT) pVoid ;
  664. xDest = pMfBitBlt->xDest ;
  665. yDest = pMfBitBlt->yDest ;
  666. cxDest = pMfBitBlt->cxDest ;
  667. cyDest = pMfBitBlt->cyDest ;
  668. dwRop = pMfBitBlt->dwRop ;
  669. xSrc = pMfBitBlt->xSrc ;
  670. ySrc = pMfBitBlt->ySrc ;
  671. pxformSrc =&(pMfBitBlt->xformSrc) ;
  672. crBkColorSrc = pMfBitBlt->crBkColorSrc ; // not used
  673. iUsageSrc = pMfBitBlt->iUsageSrc ;
  674. offBmiSrc = pMfBitBlt->offBmiSrc ;
  675. cbBmiSrc = pMfBitBlt->cbBmiSrc ;
  676. offBitsSrc = pMfBitBlt->offBitsSrc ;
  677. cbBitsSrc = pMfBitBlt->cbBitsSrc ;
  678. if (!IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  679. pMfBitBlt,
  680. offBmiSrc,
  681. cbBmiSrc) ||
  682. !IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  683. pMfBitBlt,
  684. offBitsSrc,
  685. cbBitsSrc))
  686. {
  687. EMFVALFAIL(("MF3216: bHandleBitBlt failed\n"));
  688. return(FALSE);
  689. }
  690. lpBits = (PBYTE) pMfBitBlt + offBitsSrc ;
  691. pbmi = (PBITMAPINFO) ((PBYTE) pMfBitBlt + offBmiSrc) ;
  692. b = DoStretchBlt(pLocalDC,
  693. xDest,
  694. yDest,
  695. cxDest,
  696. cyDest,
  697. dwRop,
  698. xSrc,
  699. ySrc,
  700. cxDest,
  701. cyDest,
  702. pxformSrc,
  703. iUsageSrc,
  704. pbmi,
  705. cbBmiSrc,
  706. lpBits,
  707. cbBitsSrc);
  708. return(b) ;
  709. }
  710. /**************************************************************************
  711. * Handler - StretchBlt
  712. *************************************************************************/
  713. BOOL bHandleStretchBlt(PVOID pVoid, PLOCALDC pLocalDC)
  714. {
  715. BOOL b ;
  716. PEMRSTRETCHBLT pMfStretchBlt ;
  717. LONG xDest ;
  718. LONG yDest ;
  719. LONG cxDest ;
  720. LONG cyDest ;
  721. DWORD dwRop ;
  722. LONG xSrc ;
  723. LONG ySrc ;
  724. LONG cxSrc ;
  725. LONG cySrc ;
  726. PXFORM pxformSrc ;
  727. COLORREF crBkColorSrc ;
  728. DWORD iUsageSrc ;
  729. DWORD offBmiSrc ;
  730. DWORD cbBmiSrc ;
  731. DWORD offBitsSrc ;
  732. DWORD cbBitsSrc ;
  733. PBITMAPINFO pbmi ;
  734. LPBYTE lpBits ;
  735. pMfStretchBlt = (PEMRSTRETCHBLT) pVoid ;
  736. xDest = pMfStretchBlt->xDest ;
  737. yDest = pMfStretchBlt->yDest ;
  738. cxDest = pMfStretchBlt->cxDest ;
  739. cyDest = pMfStretchBlt->cyDest ;
  740. dwRop = pMfStretchBlt->dwRop ;
  741. xSrc = pMfStretchBlt->xSrc ;
  742. ySrc = pMfStretchBlt->ySrc ;
  743. pxformSrc =&(pMfStretchBlt->xformSrc) ;
  744. crBkColorSrc = pMfStretchBlt->crBkColorSrc ; // not used
  745. iUsageSrc = pMfStretchBlt->iUsageSrc ;
  746. offBmiSrc = pMfStretchBlt->offBmiSrc ;
  747. cbBmiSrc = pMfStretchBlt->cbBmiSrc ;
  748. offBitsSrc = pMfStretchBlt->offBitsSrc ;
  749. cbBitsSrc = pMfStretchBlt->cbBitsSrc ;
  750. if (!IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  751. pMfStretchBlt,
  752. offBmiSrc,
  753. cbBmiSrc) ||
  754. !IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  755. pMfStretchBlt,
  756. offBitsSrc,
  757. cbBitsSrc))
  758. {
  759. EMFVALFAIL(("MF3216: bHandleStretchBlt failed\n"));
  760. return(FALSE);
  761. }
  762. lpBits = (PBYTE) pMfStretchBlt + offBitsSrc ;
  763. pbmi = (PBITMAPINFO) ((PBYTE) pMfStretchBlt + offBmiSrc) ;
  764. cxSrc = pMfStretchBlt->cxSrc ;
  765. cySrc = pMfStretchBlt->cySrc ;
  766. b = DoStretchBlt(pLocalDC,
  767. xDest,
  768. yDest,
  769. cxDest,
  770. cyDest,
  771. dwRop,
  772. xSrc,
  773. ySrc,
  774. cxSrc,
  775. cySrc,
  776. pxformSrc,
  777. iUsageSrc,
  778. pbmi,
  779. cbBmiSrc,
  780. lpBits,
  781. cbBitsSrc);
  782. return(b) ;
  783. }
  784. /**************************************************************************
  785. * Handler - MaskBlt
  786. *************************************************************************/
  787. BOOL bHandleMaskBlt(PVOID pVoid, PLOCALDC pLocalDC)
  788. {
  789. BOOL b ;
  790. PEMRMASKBLT pMfMaskBlt ;
  791. LONG xDest ;
  792. LONG yDest ;
  793. LONG cxDest ;
  794. LONG cyDest ;
  795. DWORD dwRop ;
  796. LONG xSrc ;
  797. LONG ySrc ;
  798. PXFORM pxformSrc ;
  799. COLORREF crBkColorSrc ;
  800. DWORD iUsageSrc ;
  801. DWORD offBmiSrc ;
  802. DWORD cbBmiSrc ;
  803. DWORD offBitsSrc ;
  804. DWORD cbBitsSrc ;
  805. PBITMAPINFO pbmi ;
  806. LPBYTE lpBits ;
  807. LONG xMask ;
  808. LONG yMask ;
  809. DWORD iUsageMask ;
  810. DWORD offBmiMask ;
  811. DWORD cbBmiMask ;
  812. DWORD offBitsMask ;
  813. DWORD cbBitsMask ;
  814. PBITMAPINFO pbmiMask ;
  815. LPBYTE lpMaskBits ;
  816. pMfMaskBlt = (PEMRMASKBLT) pVoid ;
  817. xDest = pMfMaskBlt->xDest ;
  818. yDest = pMfMaskBlt->yDest ;
  819. cxDest = pMfMaskBlt->cxDest ;
  820. cyDest = pMfMaskBlt->cyDest ;
  821. dwRop = pMfMaskBlt->dwRop ;
  822. xSrc = pMfMaskBlt->xSrc ;
  823. ySrc = pMfMaskBlt->ySrc ;
  824. pxformSrc =&(pMfMaskBlt->xformSrc) ;
  825. crBkColorSrc = pMfMaskBlt->crBkColorSrc ; // not used
  826. iUsageSrc = pMfMaskBlt->iUsageSrc ;
  827. offBmiSrc = pMfMaskBlt->offBmiSrc ;
  828. cbBmiSrc = pMfMaskBlt->cbBmiSrc ;
  829. offBitsSrc = pMfMaskBlt->offBitsSrc ;
  830. cbBitsSrc = pMfMaskBlt->cbBitsSrc ;
  831. if (!IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  832. pMfMaskBlt,
  833. offBmiSrc,
  834. cbBmiSrc) ||
  835. !IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  836. pMfMaskBlt,
  837. offBitsSrc,
  838. cbBitsSrc))
  839. {
  840. EMFVALFAIL(("MF3216: bHandleMaskBlt failed\n"));
  841. return(FALSE);
  842. }
  843. lpBits = (PBYTE) pMfMaskBlt + offBitsSrc ;
  844. pbmi = (PBITMAPINFO) ((PBYTE) pMfMaskBlt + offBmiSrc) ;
  845. xMask = pMfMaskBlt->xMask ;
  846. yMask = pMfMaskBlt->yMask ;
  847. iUsageMask = pMfMaskBlt->iUsageMask ;
  848. offBmiMask = pMfMaskBlt->offBmiMask ;
  849. cbBmiMask = pMfMaskBlt->cbBmiMask ;
  850. offBitsMask = pMfMaskBlt->offBitsMask ;
  851. cbBitsMask = pMfMaskBlt->cbBitsMask ;
  852. if (!IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  853. pMfMaskBlt,
  854. offBmiMask,
  855. cbBmiMask) ||
  856. !IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  857. pMfMaskBlt,
  858. offBitsMask,
  859. cbBitsMask))
  860. {
  861. EMFVALFAIL(("MF3216: bHandleMaskBlt failed\n"));
  862. return(FALSE);
  863. }
  864. lpMaskBits = (PBYTE) pMfMaskBlt + offBitsMask ;
  865. pbmiMask = (PBITMAPINFO) ((PBYTE) pMfMaskBlt + offBmiMask) ;
  866. b = DoMaskBlt(pLocalDC,
  867. xDest,
  868. yDest,
  869. cxDest,
  870. cyDest,
  871. dwRop,
  872. xSrc,
  873. ySrc,
  874. pxformSrc,
  875. iUsageSrc,
  876. pbmi,
  877. cbBmiSrc,
  878. lpBits,
  879. cbBitsSrc,
  880. xMask,
  881. yMask,
  882. iUsageMask,
  883. pbmiMask,
  884. cbBmiMask,
  885. lpMaskBits,
  886. cbBitsMask);
  887. return(b) ;
  888. }
  889. /**************************************************************************
  890. * Handler - PlgBlt
  891. *************************************************************************/
  892. BOOL bHandlePlgBlt(PVOID pVoid, PLOCALDC pLocalDC)
  893. {
  894. BOOL b ;
  895. PEMRPLGBLT pMfPlgBlt ;
  896. PPOINTL pptlDest ;
  897. LONG xSrc ;
  898. LONG ySrc ;
  899. LONG cxSrc ;
  900. LONG cySrc ;
  901. PXFORM pxformSrc ;
  902. COLORREF crBkColorSrc ;
  903. DWORD iUsageSrc ;
  904. DWORD offBmiSrc ;
  905. DWORD cbBmiSrc ;
  906. DWORD offBitsSrc ;
  907. DWORD cbBitsSrc ;
  908. PBITMAPINFO pbmi ;
  909. LPBYTE lpBits ;
  910. LONG xMask ;
  911. LONG yMask ;
  912. DWORD iUsageMask ;
  913. DWORD offBmiMask ;
  914. DWORD cbBmiMask ;
  915. DWORD offBitsMask ;
  916. DWORD cbBitsMask ;
  917. PBITMAPINFO pbmiMask ;
  918. LPBYTE lpMaskBits ;
  919. pMfPlgBlt = (PEMRPLGBLT) pVoid ;
  920. pptlDest = pMfPlgBlt->aptlDest ;
  921. xSrc = pMfPlgBlt->xSrc ;
  922. ySrc = pMfPlgBlt->ySrc ;
  923. cxSrc = pMfPlgBlt->cxSrc ;
  924. cySrc = pMfPlgBlt->cySrc ;
  925. pxformSrc =&(pMfPlgBlt->xformSrc) ;
  926. crBkColorSrc = pMfPlgBlt->crBkColorSrc ; // not used
  927. iUsageSrc = pMfPlgBlt->iUsageSrc ;
  928. offBmiSrc = pMfPlgBlt->offBmiSrc ;
  929. cbBmiSrc = pMfPlgBlt->cbBmiSrc ;
  930. offBitsSrc = pMfPlgBlt->offBitsSrc ;
  931. cbBitsSrc = pMfPlgBlt->cbBitsSrc ;
  932. if (!IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  933. pMfPlgBlt,
  934. offBmiSrc,
  935. cbBmiSrc) ||
  936. !IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  937. pMfPlgBlt,
  938. offBitsSrc,
  939. cbBitsSrc))
  940. {
  941. EMFVALFAIL(("MF3216: bHandlePlgBlt failed\n"));
  942. return(FALSE);
  943. }
  944. lpBits = (PBYTE) pMfPlgBlt + offBitsSrc ;
  945. pbmi = (PBITMAPINFO) ((PBYTE) pMfPlgBlt + offBmiSrc) ;
  946. xMask = pMfPlgBlt->xMask ;
  947. yMask = pMfPlgBlt->yMask ;
  948. iUsageMask = pMfPlgBlt->iUsageMask ;
  949. offBmiMask = pMfPlgBlt->offBmiMask ;
  950. cbBmiMask = pMfPlgBlt->cbBmiMask ;
  951. offBitsMask = pMfPlgBlt->offBitsMask ;
  952. cbBitsMask = pMfPlgBlt->cbBitsMask ;
  953. if (!IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  954. pMfPlgBlt,
  955. offBmiMask,
  956. cbBmiMask) ||
  957. !IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  958. pMfPlgBlt,
  959. offBitsMask,
  960. cbBitsMask))
  961. {
  962. EMFVALFAIL(("MF3216: bHandlePlgBlt failed\n"));
  963. return(FALSE);
  964. }
  965. lpMaskBits = (PBYTE) pMfPlgBlt + offBitsMask ;
  966. pbmiMask = (PBITMAPINFO) ((PBYTE) pMfPlgBlt + offBmiMask) ;
  967. b = DoPlgBlt(pLocalDC,
  968. pptlDest,
  969. xSrc,
  970. ySrc,
  971. cxSrc,
  972. cySrc,
  973. pxformSrc,
  974. iUsageSrc,
  975. pbmi,
  976. cbBmiSrc,
  977. lpBits,
  978. cbBitsSrc,
  979. xMask,
  980. yMask,
  981. iUsageMask,
  982. pbmiMask,
  983. cbBmiMask,
  984. lpMaskBits,
  985. cbBitsMask);
  986. return(b) ;
  987. }
  988. /**************************************************************************
  989. * Handler - Save DC
  990. *************************************************************************/
  991. BOOL bHandleSaveDC(PVOID pVoid, PLOCALDC pLocalDC)
  992. {
  993. BOOL b ;
  994. NOTUSED(pVoid) ;
  995. b = DoSaveDC(pLocalDC) ;
  996. return(b) ;
  997. }
  998. /**************************************************************************
  999. * Handler - Restore DC
  1000. *************************************************************************/
  1001. BOOL bHandleRestoreDC(PVOID pVoid, PLOCALDC pLocalDC)
  1002. {
  1003. BOOL b ;
  1004. PEMRRESTOREDC pMfRestoreDc ;
  1005. INT nSavedDC ;
  1006. pMfRestoreDc = (PEMRRESTOREDC) pVoid ;
  1007. nSavedDC = (INT) pMfRestoreDc->iRelative ;
  1008. b = DoRestoreDC(pLocalDC, nSavedDC) ;
  1009. return(b) ;
  1010. }
  1011. /**************************************************************************
  1012. * Handler - End of File
  1013. *************************************************************************/
  1014. BOOL bHandleEOF(PVOID pVoid, PLOCALDC pLocalDC)
  1015. {
  1016. NOTUSED(pVoid) ;
  1017. DoEOF(pLocalDC) ;
  1018. return (TRUE) ;
  1019. }
  1020. /**************************************************************************
  1021. * Handler - Header
  1022. *************************************************************************/
  1023. BOOL bHandleHeader(PVOID pVoid, PLOCALDC pLocalDC)
  1024. {
  1025. BOOL b ;
  1026. PENHMETAHEADER pemfheader ;
  1027. pemfheader = (PENHMETAHEADER) pVoid ;
  1028. b = DoHeader(pLocalDC, pemfheader) ;
  1029. return (b) ;
  1030. }
  1031. /**************************************************************************
  1032. * Handler - ScaleWindowExtEx
  1033. *************************************************************************/
  1034. BOOL bHandleScaleWindowExt(PVOID pVoid, PLOCALDC pLocalDC)
  1035. {
  1036. BOOL b ;
  1037. PEMRSCALEWINDOWEXTEX pMfScaleWindowExt ;
  1038. INT Xnum,
  1039. Xdenom,
  1040. Ynum,
  1041. Ydenom ;
  1042. pMfScaleWindowExt = (PEMRSCALEWINDOWEXTEX) pVoid ;
  1043. // Scale the MapMode Mode
  1044. Xnum = (INT) pMfScaleWindowExt->xNum ;
  1045. Xdenom = (INT) pMfScaleWindowExt->xDenom ;
  1046. Ynum = (INT) pMfScaleWindowExt->yNum ;
  1047. Ydenom = (INT) pMfScaleWindowExt->yDenom ;
  1048. // Do the translation.
  1049. b = DoScaleWindowExt(pLocalDC, Xnum, Xdenom, Ynum, Ydenom) ;
  1050. return (b) ;
  1051. }
  1052. /**************************************************************************
  1053. * Handler - ScaleViewportExtEx
  1054. *************************************************************************/
  1055. BOOL bHandleScaleViewportExt(PVOID pVoid, PLOCALDC pLocalDC)
  1056. {
  1057. BOOL b ;
  1058. PEMRSCALEVIEWPORTEXTEX pMfScaleViewportExt ;
  1059. INT Xnum,
  1060. Xdenom,
  1061. Ynum,
  1062. Ydenom ;
  1063. pMfScaleViewportExt = (PEMRSCALEVIEWPORTEXTEX) pVoid ;
  1064. // Scale the MapMode Mode
  1065. Xnum = (INT) pMfScaleViewportExt->xNum ;
  1066. Xdenom = (INT) pMfScaleViewportExt->xDenom ;
  1067. Ynum = (INT) pMfScaleViewportExt->yNum ;
  1068. Ydenom = (INT) pMfScaleViewportExt->yDenom ;
  1069. // Do the translation.
  1070. b = DoScaleViewportExt(pLocalDC, Xnum, Xdenom, Ynum, Ydenom) ;
  1071. return (b) ;
  1072. }
  1073. /**************************************************************************
  1074. * Handler - SetViewportExtEx
  1075. *************************************************************************/
  1076. BOOL bHandleSetViewportExt(PVOID pVoid, PLOCALDC pLocalDC)
  1077. {
  1078. BOOL b ;
  1079. PEMRSETVIEWPORTEXTEX pMfSetViewportExt ;
  1080. LONG x, y ;
  1081. pMfSetViewportExt = (PEMRSETVIEWPORTEXTEX) pVoid ;
  1082. // Set the MapMode Mode
  1083. x = pMfSetViewportExt->szlExtent.cx ;
  1084. y = pMfSetViewportExt->szlExtent.cy ;
  1085. // Do the translation.
  1086. b = DoSetViewportExt(pLocalDC, (INT) x, (INT) y) ;
  1087. return (b) ;
  1088. }
  1089. /**************************************************************************
  1090. * Handler - SetViewportOrgEx
  1091. *************************************************************************/
  1092. BOOL bHandleSetViewportOrg(PVOID pVoid, PLOCALDC pLocalDC)
  1093. {
  1094. BOOL b ;
  1095. PEMRSETVIEWPORTORGEX pMfSetViewportOrg ;
  1096. LONG x, y ;
  1097. pMfSetViewportOrg = (PEMRSETVIEWPORTORGEX) pVoid ;
  1098. // Set the MapMode Mode
  1099. x = pMfSetViewportOrg->ptlOrigin.x ;
  1100. y = pMfSetViewportOrg->ptlOrigin.y ;
  1101. // Do the translation.
  1102. b = DoSetViewportOrg(pLocalDC, (INT) x, (INT) y) ;
  1103. return (b) ;
  1104. }
  1105. /**************************************************************************
  1106. * Handler - SetWindowExtEx
  1107. *************************************************************************/
  1108. BOOL bHandleSetWindowExt(PVOID pVoid, PLOCALDC pLocalDC)
  1109. {
  1110. BOOL b ;
  1111. PEMRSETWINDOWEXTEX pMfSetWindowExt ;
  1112. LONG x, y ;
  1113. pMfSetWindowExt = (PEMRSETWINDOWEXTEX) pVoid ;
  1114. // Set the MapMode Mode
  1115. x = pMfSetWindowExt->szlExtent.cx ;
  1116. y = pMfSetWindowExt->szlExtent.cy ;
  1117. // Do the translation.
  1118. b = DoSetWindowExt(pLocalDC, (INT) x, (INT) y) ;
  1119. return (b) ;
  1120. }
  1121. /**************************************************************************
  1122. * Handler - SetWindowOrgEx
  1123. *************************************************************************/
  1124. BOOL bHandleSetWindowOrg(PVOID pVoid, PLOCALDC pLocalDC)
  1125. {
  1126. BOOL b ;
  1127. PEMRSETWINDOWORGEX pMfSetWindowOrg ;
  1128. LONG x, y ;
  1129. pMfSetWindowOrg = (PEMRSETWINDOWORGEX) pVoid ;
  1130. // Set the MapMode Mode
  1131. x = pMfSetWindowOrg->ptlOrigin.x ;
  1132. y = pMfSetWindowOrg->ptlOrigin.y ;
  1133. // Do the translation.
  1134. b = DoSetWindowOrg(pLocalDC, (INT) x, (INT) y) ;
  1135. return (b) ;
  1136. }
  1137. /**************************************************************************
  1138. * Handler - SetMapMode
  1139. *************************************************************************/
  1140. BOOL bHandleSetMapMode(PVOID pVoid, PLOCALDC pLocalDC)
  1141. {
  1142. BOOL b ;
  1143. DWORD iMapMode ;
  1144. PEMRSETMAPMODE pMfSetMapMode ;
  1145. pMfSetMapMode = (PEMRSETMAPMODE) pVoid ;
  1146. // Set the MapMode Mode
  1147. iMapMode = pMfSetMapMode->iMode ;
  1148. // Do the translation.
  1149. b = DoSetMapMode(pLocalDC, iMapMode) ;
  1150. return (b) ;
  1151. }
  1152. /**************************************************************************
  1153. * Handler - SetArcDirection
  1154. *************************************************************************/
  1155. BOOL bHandleSetArcDirection(PVOID pVoid, PLOCALDC pLocalDC)
  1156. {
  1157. PEMRSETARCDIRECTION pMfSetArcDirection ;
  1158. INT iArcDirection ;
  1159. BOOL b ;
  1160. pMfSetArcDirection = (PEMRSETARCDIRECTION) pVoid ;
  1161. iArcDirection = (INT) pMfSetArcDirection->iArcDirection ;
  1162. b = DoSetArcDirection(pLocalDC, iArcDirection) ;
  1163. return (b) ;
  1164. }
  1165. /**************************************************************************
  1166. * Handler - AngleArc
  1167. *************************************************************************/
  1168. BOOL bHandleAngleArc(PVOID pVoid, PLOCALDC pLocalDC)
  1169. {
  1170. BOOL b ;
  1171. PEMRANGLEARC pMfAngleArc ;
  1172. int x, y;
  1173. DWORD nRadius ;
  1174. FLOAT eStartAngle,
  1175. eSweepAngle ;
  1176. pMfAngleArc = (PEMRANGLEARC) pVoid ;
  1177. // Set the Arc center
  1178. x = (int) pMfAngleArc->ptlCenter.x ;
  1179. y = (int) pMfAngleArc->ptlCenter.y ;
  1180. // Get the radius of the Arc
  1181. nRadius = (INT) pMfAngleArc->nRadius ;
  1182. // Set the start & sweep angles
  1183. eStartAngle = pMfAngleArc->eStartAngle ;
  1184. eSweepAngle = pMfAngleArc->eSweepAngle ;
  1185. b = DoAngleArc(pLocalDC, x, y, nRadius, eStartAngle, eSweepAngle) ;
  1186. return (b) ;
  1187. }
  1188. /**************************************************************************
  1189. * Handler - ArcTo
  1190. *************************************************************************/
  1191. BOOL bHandleArcTo(PVOID pVoid, PLOCALDC pLocalDC)
  1192. {
  1193. BOOL b ;
  1194. PEMRARCTO pMfArcTo ;
  1195. INT x1, x2, x3, x4,
  1196. y1, y2, y3, y4 ;
  1197. pMfArcTo = (PEMRARCTO) pVoid ;
  1198. // Set up the ellipse box, this will be the same as the bounding
  1199. // rectangle.
  1200. x1 = (INT) pMfArcTo->rclBox.left ;
  1201. y1 = (INT) pMfArcTo->rclBox.top ;
  1202. x2 = (INT) pMfArcTo->rclBox.right ;
  1203. y2 = (INT) pMfArcTo->rclBox.bottom ;
  1204. // Set the start point.
  1205. x3 = (INT) pMfArcTo->ptlStart.x ;
  1206. y3 = (INT) pMfArcTo->ptlStart.y ;
  1207. // Set the end point.
  1208. x4 = (INT) pMfArcTo->ptlEnd.x ;
  1209. y4 = (INT) pMfArcTo->ptlEnd.y ;
  1210. b = DoArcTo(pLocalDC, x1, y1, x2, y2, x3, y3, x4, y4) ;
  1211. return (b) ;
  1212. }
  1213. /**************************************************************************
  1214. * Handler - Arc
  1215. *************************************************************************/
  1216. BOOL bHandleArc(PVOID pVoid, PLOCALDC pLocalDC)
  1217. {
  1218. BOOL b ;
  1219. PEMRARC pMfArc ;
  1220. INT x1, x2, x3, x4,
  1221. y1, y2, y3, y4 ;
  1222. pMfArc = (PEMRARC) pVoid ;
  1223. // Set up the ellipse box, this will be the same as the bounding
  1224. // rectangle.
  1225. x1 = (INT) pMfArc->rclBox.left ;
  1226. y1 = (INT) pMfArc->rclBox.top ;
  1227. x2 = (INT) pMfArc->rclBox.right ;
  1228. y2 = (INT) pMfArc->rclBox.bottom ;
  1229. // Set the start point.
  1230. x3 = (INT) pMfArc->ptlStart.x ;
  1231. y3 = (INT) pMfArc->ptlStart.y ;
  1232. // Set the end point.
  1233. x4 = (INT) pMfArc->ptlEnd.x ;
  1234. y4 = (INT) pMfArc->ptlEnd.y ;
  1235. b = DoArc(pLocalDC, x1, y1, x2, y2, x3, y3, x4, y4) ;
  1236. return (b) ;
  1237. }
  1238. /**************************************************************************
  1239. * Handler - Ellipse
  1240. *************************************************************************/
  1241. BOOL bHandleEllipse(PVOID pVoid, PLOCALDC pLocalDC)
  1242. {
  1243. BOOL b ;
  1244. INT x1, y1, x2, y2 ;
  1245. PEMRELLIPSE pMfEllipse ;
  1246. pMfEllipse = (PEMRELLIPSE) pVoid ;
  1247. // Set up the ellipse box, this will be the same as the bounding
  1248. // rectangle.
  1249. x1 = (INT) pMfEllipse->rclBox.left ;
  1250. y1 = (INT) pMfEllipse->rclBox.top ;
  1251. x2 = (INT) pMfEllipse->rclBox.right ;
  1252. y2 = (INT) pMfEllipse->rclBox.bottom ;
  1253. // Do the Ellipse translation.
  1254. b = DoEllipse(pLocalDC, x1, y1, x2, y2) ;
  1255. return (b) ;
  1256. }
  1257. /**************************************************************************
  1258. * Handler - SelectObject
  1259. *************************************************************************/
  1260. BOOL bHandleSelectObject(PVOID pVoid, PLOCALDC pLocalDC)
  1261. {
  1262. BOOL b ;
  1263. PEMRSELECTOBJECT pMfSelectObject ;
  1264. INT ihObject ;
  1265. pMfSelectObject = (PEMRSELECTOBJECT) pVoid ;
  1266. // Get the Object (it's really a Long)
  1267. ihObject = (INT) pMfSelectObject->ihObject ;
  1268. // Do the translation
  1269. b = DoSelectObject(pLocalDC, ihObject) ;
  1270. return (b) ;
  1271. }
  1272. /**************************************************************************
  1273. * Handler - DeleteObject
  1274. *************************************************************************/
  1275. BOOL bHandleDeleteObject(PVOID pVoid, PLOCALDC pLocalDC)
  1276. {
  1277. BOOL b ;
  1278. PEMRDELETEOBJECT pMfDeleteObject ;
  1279. INT ihObject ;
  1280. pMfDeleteObject = (PEMRDELETEOBJECT) pVoid ;
  1281. ihObject = (INT) pMfDeleteObject->ihObject ;
  1282. b = DoDeleteObject(pLocalDC, ihObject) ;
  1283. return(b) ;
  1284. }
  1285. /**************************************************************************
  1286. * Handler - CreateBrushIndirect
  1287. *************************************************************************/
  1288. BOOL bHandleCreateBrushIndirect(PVOID pVoid, PLOCALDC pLocalDC)
  1289. {
  1290. BOOL b ;
  1291. PEMRCREATEBRUSHINDIRECT pMfCreateBrushIndirect ;
  1292. LOGBRUSH LogBrush ;
  1293. INT ihBrush ;
  1294. pMfCreateBrushIndirect = (PEMRCREATEBRUSHINDIRECT) pVoid ;
  1295. // Get the Brush parameters.
  1296. LogBrush.lbStyle = pMfCreateBrushIndirect->lb.lbStyle;
  1297. LogBrush.lbColor = pMfCreateBrushIndirect->lb.lbColor;
  1298. LogBrush.lbHatch = (ULONG_PTR)pMfCreateBrushIndirect->lb.lbHatch;
  1299. ihBrush = pMfCreateBrushIndirect->ihBrush ;
  1300. // Do the translation.
  1301. b = DoCreateBrushIndirect(pLocalDC, ihBrush, &LogBrush) ;
  1302. return (b) ;
  1303. }
  1304. /**************************************************************************
  1305. * Handler - CreateMonoBrush
  1306. *************************************************************************/
  1307. BOOL bHandleCreateMonoBrush(PVOID pVoid, PLOCALDC pLocalDC)
  1308. {
  1309. BOOL b ;
  1310. PEMRCREATEMONOBRUSH pMfCreateMonoBrush ;
  1311. DWORD ihBrush ;
  1312. DWORD iUsage ;
  1313. DWORD offBmi ;
  1314. DWORD cbBmi ;
  1315. DWORD offBits ;
  1316. DWORD cbBits ;
  1317. PBITMAPINFO pBmi ;
  1318. PBYTE pBits ;
  1319. pMfCreateMonoBrush = (PEMRCREATEMONOBRUSH) pVoid ;
  1320. ihBrush = pMfCreateMonoBrush->ihBrush ;
  1321. iUsage = pMfCreateMonoBrush->iUsage ;
  1322. offBmi = pMfCreateMonoBrush->offBmi ;
  1323. cbBmi = pMfCreateMonoBrush->cbBmi ;
  1324. offBits = pMfCreateMonoBrush->offBits ;
  1325. cbBits = pMfCreateMonoBrush->cbBits ;
  1326. pBmi = (PBITMAPINFO) ((PBYTE) pVoid + offBmi) ;
  1327. pBits = (PBYTE) pVoid + offBits ;
  1328. b = DoCreateMonoBrush(pLocalDC, ihBrush,
  1329. pBmi, cbBmi,
  1330. pBits, cbBits,
  1331. iUsage) ;
  1332. return (b) ;
  1333. }
  1334. /**************************************************************************
  1335. * Handler - CreateDIBPatternBrush
  1336. *************************************************************************/
  1337. BOOL bHandleCreateDIBPatternBrush(PVOID pVoid, PLOCALDC pLocalDC)
  1338. {
  1339. BOOL b ;
  1340. PEMRCREATEDIBPATTERNBRUSHPT pMfCreateDIBPatternBrush ;
  1341. DWORD ihBrush ;
  1342. DWORD iUsage ;
  1343. DWORD offBmi ;
  1344. DWORD cbBmi ;
  1345. DWORD offBits ;
  1346. DWORD cbBits ;
  1347. PBITMAPINFO pBmi ;
  1348. PBYTE pBits ;
  1349. pMfCreateDIBPatternBrush = (PEMRCREATEDIBPATTERNBRUSHPT) pVoid ;
  1350. ihBrush = pMfCreateDIBPatternBrush->ihBrush ;
  1351. iUsage = pMfCreateDIBPatternBrush->iUsage ;
  1352. offBmi = pMfCreateDIBPatternBrush->offBmi ;
  1353. cbBmi = pMfCreateDIBPatternBrush->cbBmi ;
  1354. offBits = pMfCreateDIBPatternBrush->offBits ;
  1355. cbBits = pMfCreateDIBPatternBrush->cbBits ;
  1356. if (!IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  1357. pMfCreateDIBPatternBrush,
  1358. offBmi,
  1359. cbBmi) ||
  1360. !IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  1361. pMfCreateDIBPatternBrush,
  1362. offBits,
  1363. cbBits))
  1364. {
  1365. EMFVALFAIL(("MF3216: bHandleCreateDIBPatternBrush failed\n"));
  1366. return(FALSE);
  1367. }
  1368. pBmi = (PBITMAPINFO) ((PBYTE) pVoid + offBmi) ;
  1369. pBits = (PBYTE) pVoid + offBits ;
  1370. b = DoCreateDIBPatternBrush(pLocalDC, ihBrush,
  1371. pBmi, cbBmi,
  1372. pBits, cbBits,
  1373. iUsage) ;
  1374. return (b) ;
  1375. }
  1376. /**************************************************************************
  1377. * Handler - CreatePen
  1378. *************************************************************************/
  1379. BOOL bHandleCreatePen(PVOID pVoid, PLOCALDC pLocalDC)
  1380. {
  1381. PEMRCREATEPEN pMfCreatePen ;
  1382. INT ihPen ;
  1383. PLOGPEN pLogPen ;
  1384. BOOL b ;
  1385. pMfCreatePen = (PEMRCREATEPEN) pVoid ;
  1386. ihPen = pMfCreatePen->ihPen ;
  1387. pLogPen = &pMfCreatePen->lopn ;
  1388. b = DoCreatePen(pLocalDC, ihPen, pLogPen) ;
  1389. return(b) ;
  1390. }
  1391. /**************************************************************************
  1392. * Handler - ExtCreatePen
  1393. *************************************************************************/
  1394. BOOL bHandleExtCreatePen(PVOID pVoid, PLOCALDC pLocalDC)
  1395. {
  1396. BOOL b ;
  1397. PEMREXTCREATEPEN pMfExtCreatePen ;
  1398. PEXTLOGPEN pExtLogPen ;
  1399. INT ihPen ;
  1400. pMfExtCreatePen = (PEMREXTCREATEPEN) pVoid ;
  1401. pExtLogPen = &pMfExtCreatePen->elp ;
  1402. ihPen = pMfExtCreatePen->ihPen ;
  1403. b = DoExtCreatePen(pLocalDC, ihPen, pExtLogPen) ;
  1404. return (b) ;
  1405. }
  1406. /**************************************************************************
  1407. * Handler - MoveToEx
  1408. *************************************************************************/
  1409. BOOL bHandleMoveTo(PVOID pVoid, PLOCALDC pLocalDC)
  1410. {
  1411. BOOL b ;
  1412. PEMRMOVETOEX pMfMoveTo ;
  1413. INT x, y ;
  1414. pMfMoveTo = (PEMRMOVETOEX) pVoid ;
  1415. // Get the position.
  1416. x = (INT) pMfMoveTo->ptl.x ;
  1417. y = (INT) pMfMoveTo->ptl.y ;
  1418. // Do the translation.
  1419. b = DoMoveTo(pLocalDC, x, y) ;
  1420. return (b) ;
  1421. }
  1422. /**************************************************************************
  1423. * Handler - LineTo
  1424. *************************************************************************/
  1425. BOOL bHandleLineTo(PVOID pVoid, PLOCALDC pLocalDC)
  1426. {
  1427. BOOL b ;
  1428. PEMRLINETO pMfLineTo ;
  1429. INT x, y ;
  1430. pMfLineTo = (PEMRLINETO) pVoid ;
  1431. // Get the new point.
  1432. x = (INT) pMfLineTo->ptl.x ;
  1433. y = (INT) pMfLineTo->ptl.y ;
  1434. // Do the translation.
  1435. b = DoLineTo(pLocalDC, x, y) ;
  1436. return (b) ;
  1437. }
  1438. /**************************************************************************
  1439. * Handler - Chord
  1440. *************************************************************************/
  1441. BOOL bHandleChord(PVOID pVoid, PLOCALDC pLocalDC)
  1442. {
  1443. BOOL b ;
  1444. PEMRCHORD pMfChord ;
  1445. INT x1, x2, x3, x4,
  1446. y1, y2, y3, y4 ;
  1447. pMfChord = (PEMRCHORD) pVoid ;
  1448. // Set the rectangle
  1449. x1 = (INT) pMfChord->rclBox.left ;
  1450. y1 = (INT) pMfChord->rclBox.top ;
  1451. x2 = (INT) pMfChord->rclBox.right ;
  1452. y2 = (INT) pMfChord->rclBox.bottom ;
  1453. // Set the start point.
  1454. x3 = (INT) pMfChord->ptlStart.x ;
  1455. y3 = (INT) pMfChord->ptlStart.y ;
  1456. // Set the end point.
  1457. x4 = (INT) pMfChord->ptlEnd.x ;
  1458. y4 = (INT) pMfChord->ptlEnd.y ;
  1459. // Do the translation
  1460. b = DoChord(pLocalDC, x1, y1, x2, y2, x3, y3, x4, y4) ;
  1461. return (b) ;
  1462. }
  1463. /**************************************************************************
  1464. * Handler - Pie
  1465. *************************************************************************/
  1466. BOOL bHandlePie(PVOID pVoid, PLOCALDC pLocalDC)
  1467. {
  1468. BOOL b ;
  1469. PEMRPIE pMfPie ;
  1470. INT x1, x2, x3, x4,
  1471. y1, y2, y3, y4 ;
  1472. pMfPie = (PEMRPIE) pVoid ;
  1473. // Set up the ellipse box
  1474. x1 = (INT) pMfPie->rclBox.left ;
  1475. y1 = (INT) pMfPie->rclBox.top ;
  1476. x2 = (INT) pMfPie->rclBox.right ;
  1477. y2 = (INT) pMfPie->rclBox.bottom ;
  1478. // Set the start point.
  1479. x3 = (INT) pMfPie->ptlStart.x ;
  1480. y3 = (INT) pMfPie->ptlStart.y ;
  1481. // Set the end point.
  1482. x4 = (INT) pMfPie->ptlEnd.x ;
  1483. y4 = (INT) pMfPie->ptlEnd.y ;
  1484. // Do the Pie translation.
  1485. b = DoPie(pLocalDC, x1, y1, x2, y2, x3, y3, x4, y4) ;
  1486. return (b) ;
  1487. }
  1488. /**************************************************************************
  1489. * Handler - Polyline
  1490. *************************************************************************/
  1491. BOOL bHandlePolyline(PVOID pVoid, PLOCALDC pLocalDC)
  1492. {
  1493. BOOL b ;
  1494. PEMRPOLYLINE pMfPolyline ;
  1495. INT nCount ;
  1496. PPOINTL pptl ;
  1497. pMfPolyline = (PEMRPOLYLINE) pVoid ;
  1498. // Copy the line count and the polyline verticies to
  1499. // the record.
  1500. nCount = (INT) pMfPolyline->cptl ;
  1501. pptl = pMfPolyline->aptl ;
  1502. // Now do the translation.
  1503. b = DoPoly(pLocalDC, pptl, nCount, EMR_POLYLINE) ;
  1504. return (b) ;
  1505. }
  1506. /**************************************************************************
  1507. * Handler - PolylineTo
  1508. *************************************************************************/
  1509. BOOL bHandlePolylineTo (PVOID pVoid, PLOCALDC pLocalDC)
  1510. {
  1511. BOOL b ;
  1512. PEMRPOLYLINETO pMfPolylineTo ;
  1513. INT nCount ;
  1514. PPOINTL pptl ;
  1515. pMfPolylineTo = (PEMRPOLYLINETO) pVoid ;
  1516. // Copy the line count and the polyline verticies to
  1517. // the record.
  1518. nCount = (INT) pMfPolylineTo->cptl ;
  1519. pptl = pMfPolylineTo->aptl ;
  1520. // Now do the translation.
  1521. b = DoPolylineTo(pLocalDC, pptl, nCount) ;
  1522. return (b) ;
  1523. }
  1524. /**************************************************************************
  1525. * Handler - PolyBezier16,Polygon16,Polyline16,PolyBezierTo16,PolylineTo16
  1526. * PolyDraw16
  1527. *************************************************************************/
  1528. BOOL bHandlePoly16 (PVOID pVoid, PLOCALDC pLocalDC)
  1529. {
  1530. BOOL b = FALSE;
  1531. PEMRPOLYLINE16 pMfPoly16 ; // common structure for the poly16 records
  1532. PEMRPOLYDRAW16 pMfPolyDraw16 ;
  1533. POINTL aptl[MAX_STACK_POINTL];
  1534. PPOINTL pptl ;
  1535. INT nCount ;
  1536. PBYTE pb ;
  1537. // PolyDraw16 contains the structure of Poly16 followed by the byte array.
  1538. pMfPoly16 = (PEMRPOLYLINE16) pVoid ;
  1539. nCount = (INT) pMfPoly16->cpts ;
  1540. if (nCount <= MAX_STACK_POINTL)
  1541. pptl = aptl;
  1542. else if (!(pptl = (PPOINTL) LocalAlloc(LMEM_FIXED, nCount * sizeof(POINTL))))
  1543. return(b);
  1544. POINTS_TO_POINTL(pptl, pMfPoly16->apts, (DWORD) nCount);
  1545. // Now do the translation.
  1546. switch (pMfPoly16->emr.iType)
  1547. {
  1548. case EMR_POLYBEZIER16:
  1549. b = DoPolyBezier(pLocalDC, (LPPOINT) pptl, nCount) ;
  1550. break;
  1551. case EMR_POLYGON16:
  1552. b = DoPoly(pLocalDC, pptl, nCount, EMR_POLYGON) ;
  1553. break;
  1554. case EMR_POLYLINE16:
  1555. b = DoPoly(pLocalDC, pptl, nCount, EMR_POLYLINE) ;
  1556. break;
  1557. case EMR_POLYBEZIERTO16:
  1558. b = DoPolyBezierTo(pLocalDC, (LPPOINT) pptl, nCount) ;
  1559. break;
  1560. case EMR_POLYLINETO16:
  1561. b = DoPolylineTo(pLocalDC, pptl, nCount) ;
  1562. break;
  1563. case EMR_POLYDRAW16:
  1564. pMfPolyDraw16 = (PEMRPOLYDRAW16) pVoid ;
  1565. pb = (PBYTE) &pMfPolyDraw16->apts[nCount];
  1566. b = DoPolyDraw(pLocalDC, (LPPOINT) pptl, pb, nCount);
  1567. break;
  1568. default:
  1569. ASSERTGDI(FALSE, "Bad record type");
  1570. break;
  1571. }
  1572. if (nCount > MAX_STACK_POINTL)
  1573. if (LocalFree(pptl))
  1574. ASSERTGDI(FALSE, "bHandlePoly16: LocalFree failed");
  1575. return (b) ;
  1576. }
  1577. /**************************************************************************
  1578. * Handler - PolyPolyline
  1579. *************************************************************************/
  1580. BOOL bHandlePolyPolyline(PVOID pVoid, PLOCALDC pLocalDC)
  1581. {
  1582. BOOL b ;
  1583. PEMRPOLYPOLYLINE pMfPolyPolyline ;
  1584. PDWORD pPolyCount ;
  1585. PPOINTL pptl ;
  1586. INT nPolys ;
  1587. pMfPolyPolyline = (PEMRPOLYPOLYLINE) pVoid ;
  1588. // Copy the Polycount count, the polycount array
  1589. // and the polyline verticies to
  1590. // the record.
  1591. nPolys = (INT) pMfPolyPolyline->nPolys ;
  1592. pPolyCount = pMfPolyPolyline->aPolyCounts ;
  1593. pptl = (PPOINTL) &pMfPolyPolyline->aPolyCounts[nPolys] ;
  1594. // Now do the translation.
  1595. b = DoPolyPolyline(pLocalDC, pptl, pPolyCount, nPolys) ;
  1596. return (b) ;
  1597. }
  1598. /**************************************************************************
  1599. * Handler - PolyPolyline16,PolyPolygon16
  1600. *************************************************************************/
  1601. BOOL bHandlePolyPoly16 (PVOID pVoid, PLOCALDC pLocalDC)
  1602. {
  1603. BOOL b = FALSE;
  1604. PEMRPOLYPOLYLINE16 pMfPolyPoly16 ; // common structure for polypoly16 records
  1605. PDWORD pPolyCount ;
  1606. POINTL aptl[MAX_STACK_POINTL];
  1607. PPOINTL pptl ;
  1608. INT nCount;
  1609. DWORD cpts ;
  1610. pMfPolyPoly16 = (PEMRPOLYPOLYLINE16) pVoid ;
  1611. nCount = (INT) pMfPolyPoly16->nPolys ;
  1612. cpts = pMfPolyPoly16->cpts;
  1613. pPolyCount = pMfPolyPoly16->aPolyCounts ;
  1614. if (cpts <= MAX_STACK_POINTL)
  1615. pptl = aptl;
  1616. else if (!(pptl = (PPOINTL) LocalAlloc(LMEM_FIXED, cpts * sizeof(POINTL))))
  1617. return(b);
  1618. POINTS_TO_POINTL(pptl, (PPOINTS) &pMfPolyPoly16->aPolyCounts[nCount], cpts);
  1619. // Now do the translation.
  1620. switch (pMfPolyPoly16->emr.iType)
  1621. {
  1622. case EMR_POLYPOLYLINE16:
  1623. b = DoPolyPolyline(pLocalDC, pptl, pPolyCount, nCount) ;
  1624. break;
  1625. case EMR_POLYPOLYGON16:
  1626. b = DoPolyPolygon(pLocalDC, pptl, pPolyCount, cpts, nCount) ;
  1627. break;
  1628. default:
  1629. ASSERTGDI(FALSE, "Bad record type");
  1630. break;
  1631. }
  1632. if (cpts > MAX_STACK_POINTL)
  1633. if (LocalFree(pptl))
  1634. ASSERTGDI(FALSE, "bHandlePolyPoly16: LocalFree failed");
  1635. return (b) ;
  1636. }
  1637. /**************************************************************************
  1638. * Handler - Polygon
  1639. *************************************************************************/
  1640. BOOL bHandlePolygon (PVOID pVoid, PLOCALDC pLocalDC)
  1641. {
  1642. BOOL b ;
  1643. PEMRPOLYGON pMfPolygon ;
  1644. PPOINTL pptl ;
  1645. INT nCount ;
  1646. pMfPolygon = (PEMRPOLYGON) pVoid ;
  1647. // Copy the line count and the Polygon verticies to
  1648. // the record.
  1649. nCount = (INT) pMfPolygon->cptl ;
  1650. pptl = pMfPolygon->aptl ;
  1651. // Now do the translation.
  1652. b = DoPoly(pLocalDC, pptl, nCount, EMR_POLYGON) ;
  1653. return (b) ;
  1654. }
  1655. /**************************************************************************
  1656. * Handler - PolyPolygon
  1657. *************************************************************************/
  1658. BOOL bHandlePolyPolygon(PVOID pVoid, PLOCALDC pLocalDC)
  1659. {
  1660. BOOL b ;
  1661. PEMRPOLYPOLYGON pMfPolyPolygon ;
  1662. PDWORD pPolyCount ;
  1663. PPOINTL pptl ;
  1664. DWORD cptl ;
  1665. INT nPolys ;
  1666. pMfPolyPolygon = (PEMRPOLYPOLYGON) pVoid ;
  1667. // Copy the Polycount count, the polycount array
  1668. // and the polygon verticies to
  1669. // the record.
  1670. nPolys = (INT) pMfPolyPolygon->nPolys ;
  1671. pPolyCount = pMfPolyPolygon->aPolyCounts ;
  1672. pptl = (PPOINTL) &pMfPolyPolygon->aPolyCounts[nPolys] ;
  1673. cptl = pMfPolyPolygon->cptl ;
  1674. // Now do the translation.
  1675. b = DoPolyPolygon(pLocalDC, pptl, pPolyCount, cptl, nPolys) ;
  1676. return (b) ;
  1677. }
  1678. /**************************************************************************
  1679. * Handler - Rectangle
  1680. *************************************************************************/
  1681. BOOL bHandleRectangle(PVOID pVoid, PLOCALDC pLocalDC)
  1682. {
  1683. BOOL b ;
  1684. PEMRRECTANGLE pMfRectangle ;
  1685. INT x1, y1, x2, y2 ;
  1686. pMfRectangle = (PEMRRECTANGLE) pVoid ;
  1687. // Set up the Rectangle box, this will be the same as the bounding
  1688. // rectangle.
  1689. x1 = (INT) pMfRectangle->rclBox.left ;
  1690. y1 = (INT) pMfRectangle->rclBox.top ;
  1691. x2 = (INT) pMfRectangle->rclBox.right ;
  1692. y2 = (INT) pMfRectangle->rclBox.bottom ;
  1693. // Do the Rectangle translation.
  1694. b = DoRectangle(pLocalDC, x1, y1, x2, y2) ;
  1695. return (b) ;
  1696. }
  1697. /**************************************************************************
  1698. * Handler - RoundRect
  1699. *************************************************************************/
  1700. BOOL bHandleRoundRect (PVOID pVoid, PLOCALDC pLocalDC)
  1701. {
  1702. BOOL b ;
  1703. PEMRROUNDRECT pMfRoundRect ;
  1704. INT x1, y1, x2, y2, x3, y3 ;
  1705. pMfRoundRect = (PEMRROUNDRECT) pVoid ;
  1706. // Set up the RoundRect box, this will be the same as the bounding
  1707. // RoundRect.
  1708. x1 = (INT) pMfRoundRect->rclBox.left ;
  1709. y1 = (INT) pMfRoundRect->rclBox.top ;
  1710. x2 = (INT) pMfRoundRect->rclBox.right ;
  1711. y2 = (INT) pMfRoundRect->rclBox.bottom ;
  1712. x3 = (INT) pMfRoundRect->szlCorner.cx ;
  1713. y3 = (INT) pMfRoundRect->szlCorner.cy ;
  1714. // Do the RoundRect translation.
  1715. b = DoRoundRect(pLocalDC, x1, y1, x2, y2, x3, y3) ;
  1716. return (b) ;
  1717. }
  1718. /**************************************************************************
  1719. * Handler - ExtTextOut for both ANSI and UNICODE characters.
  1720. **************************************************************************/
  1721. BOOL bHandleExtTextOut(PVOID pVoid, PLOCALDC pLocalDC)
  1722. {
  1723. BOOL b ;
  1724. PEMREXTTEXTOUTA pMfExtTextOut ; // same for both ansi and unicode
  1725. INT x, y, nCount ;
  1726. DWORD flOptions ;
  1727. PRECTL pRectl ;
  1728. PLONG pDx ;
  1729. PWCH pwchar ;
  1730. DWORD iGraphicsMode;
  1731. pMfExtTextOut = (PEMREXTTEXTOUTA) pVoid ;
  1732. ASSERTGDI(pMfExtTextOut->emr.iType == EMR_EXTTEXTOUTA
  1733. || pMfExtTextOut->emr.iType == EMR_EXTTEXTOUTW,
  1734. "MF3216: bHandleExtTextOut: bad record type");
  1735. if (!IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  1736. pMfExtTextOut,
  1737. pMfExtTextOut->emrtext.offString,
  1738. 0) ||
  1739. !IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  1740. pMfExtTextOut,
  1741. pMfExtTextOut->emrtext.offDx,
  1742. 0))
  1743. {
  1744. EMFVALFAIL(("MF3216: bHandleExtTextOut failed\n"));
  1745. return(FALSE);
  1746. }
  1747. // Copy over the start position for the string.
  1748. x = (INT) pMfExtTextOut->emrtext.ptlReference.x ;
  1749. y = (INT) pMfExtTextOut->emrtext.ptlReference.y ;
  1750. // Now copy over the Options flag, character count,
  1751. // the clip/opaque rectangle, and the Ansi/Unicode string.
  1752. flOptions = pMfExtTextOut->emrtext.fOptions ;
  1753. nCount = (INT) pMfExtTextOut->emrtext.nChars ;
  1754. pRectl = &pMfExtTextOut->emrtext.rcl ;
  1755. pwchar = (PWCH) ((PBYTE) pMfExtTextOut + pMfExtTextOut->emrtext.offString);
  1756. iGraphicsMode = pMfExtTextOut->iGraphicsMode;
  1757. // Set up the spacing vector
  1758. pDx = (PLONG) ((PBYTE) pMfExtTextOut + pMfExtTextOut->emrtext.offDx);
  1759. // Now do the conversion.
  1760. b = DoExtTextOut(pLocalDC, x, y, flOptions,
  1761. pRectl, pwchar, nCount, pDx, iGraphicsMode,
  1762. pMfExtTextOut->emr.iType);
  1763. return (b) ;
  1764. }
  1765. /**************************************************************************
  1766. * Handler - PolyTextOut for both ANSI and UNICODE characters.
  1767. **************************************************************************/
  1768. BOOL bHandlePolyTextOut(PVOID pVoid, PLOCALDC pLocalDC)
  1769. {
  1770. PEMRPOLYTEXTOUTA pMfPolyTextOut; // same for both ansi and unicode
  1771. PWCH pwchar;
  1772. LONG i;
  1773. DWORD iType;
  1774. LONG cStrings;
  1775. PEMRTEXT pemrtext;
  1776. PLONG pDx ;
  1777. DWORD iGraphicsMode;
  1778. pMfPolyTextOut = (PEMRPOLYTEXTOUTA) pVoid ;
  1779. ASSERTGDI(pMfPolyTextOut->emr.iType == EMR_POLYTEXTOUTA
  1780. || pMfPolyTextOut->emr.iType == EMR_POLYTEXTOUTW,
  1781. "MF3216: bHandlePolyTextOut: bad record type");
  1782. iType = pMfPolyTextOut->emr.iType == EMR_POLYTEXTOUTA
  1783. ? EMR_EXTTEXTOUTA
  1784. : EMR_EXTTEXTOUTW;
  1785. cStrings = pMfPolyTextOut->cStrings;
  1786. iGraphicsMode = pMfPolyTextOut->iGraphicsMode;
  1787. // Convert to ExtTextOut
  1788. for (i = 0; i < cStrings; i++)
  1789. {
  1790. pemrtext = &pMfPolyTextOut->aemrtext[i];
  1791. if (!IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  1792. pMfPolyTextOut,
  1793. pemrtext->offString,
  1794. 0) ||
  1795. !IsValidEnhMetaRecordOffExt(pLocalDC->pht,
  1796. pMfPolyTextOut,
  1797. pemrtext->offDx,
  1798. 0))
  1799. {
  1800. EMFVALFAIL(("MF3216: bHandlePolyTextOut failed\n"));
  1801. return(FALSE);
  1802. }
  1803. pwchar = (PWCH) ((PBYTE) pMfPolyTextOut + pemrtext->offString);
  1804. pDx = (PLONG) ((PBYTE) pMfPolyTextOut + pemrtext->offDx);
  1805. if (!DoExtTextOut(pLocalDC, pemrtext->ptlReference.x, pemrtext->ptlReference.y,
  1806. pemrtext->fOptions, &pemrtext->rcl,
  1807. pwchar, pemrtext->nChars, pDx, iGraphicsMode, iType))
  1808. return(FALSE);
  1809. }
  1810. return(TRUE);
  1811. }
  1812. /**************************************************************************
  1813. * Handler - ExtCreateFont
  1814. *************************************************************************/
  1815. BOOL bHandleExtCreateFont(PVOID pVoid, PLOCALDC pLocalDC)
  1816. {
  1817. BOOL b;
  1818. PEMREXTCREATEFONTINDIRECTW pMfExtCreateFontW;
  1819. PLOGFONTW plfw;
  1820. INT ihFont;
  1821. pMfExtCreateFontW = (PEMREXTCREATEFONTINDIRECTW) pVoid ;
  1822. // Get the font parameters.
  1823. ihFont = (INT) pMfExtCreateFontW->ihFont ;
  1824. plfw = &pMfExtCreateFontW->elfw.elfLogFont;
  1825. // Do the translation.
  1826. b = DoExtCreateFont(pLocalDC, ihFont, plfw);
  1827. return (b) ;
  1828. }
  1829. /**************************************************************************
  1830. * Handler - SetBkColor
  1831. *************************************************************************/
  1832. BOOL bHandleSetBkColor(PVOID pVoid, PLOCALDC pLocalDC)
  1833. {
  1834. BOOL b ;
  1835. PEMRSETBKCOLOR pMfSetBkColor ;
  1836. pMfSetBkColor = (PEMRSETBKCOLOR) pVoid ;
  1837. // Do the translation.
  1838. b = DoSetBkColor(pLocalDC, pMfSetBkColor->crColor) ;
  1839. return (b) ;
  1840. }
  1841. /**************************************************************************
  1842. * Handler - SetBkMode
  1843. *************************************************************************/
  1844. BOOL bHandleSetBkMode(PVOID pVoid, PLOCALDC pLocalDC)
  1845. {
  1846. BOOL b ;
  1847. DWORD iBkMode ;
  1848. PEMRSETBKMODE pMfSetBkMode ;
  1849. pMfSetBkMode = (PEMRSETBKMODE) pVoid ;
  1850. // Set the Background Mode variable
  1851. iBkMode = pMfSetBkMode->iMode ;
  1852. // Do the translation.
  1853. b = DoSetBkMode(pLocalDC, iBkMode) ;
  1854. return (b) ;
  1855. }
  1856. /**************************************************************************
  1857. * Handler - SetMapperFlags
  1858. *************************************************************************/
  1859. BOOL bHandleSetMapperFlags(PVOID pVoid, PLOCALDC pLocalDC)
  1860. {
  1861. BOOL b ;
  1862. DWORD f ;
  1863. PEMRSETMAPPERFLAGS pMfSetMapperFlags ;
  1864. pMfSetMapperFlags = (PEMRSETMAPPERFLAGS) pVoid ;
  1865. f = pMfSetMapperFlags->dwFlags ;
  1866. // Do the translation.
  1867. b = DoSetMapperFlags(pLocalDC, f) ;
  1868. return (b) ;
  1869. }
  1870. /**************************************************************************
  1871. * Handler - SetPolyFillMode
  1872. *************************************************************************/
  1873. BOOL bHandleSetPolyFillMode(PVOID pVoid, PLOCALDC pLocalDC)
  1874. {
  1875. BOOL b ;
  1876. INT iPolyFillMode ;
  1877. PEMRSETPOLYFILLMODE pMfSetPolyFillMode ;
  1878. pMfSetPolyFillMode = (PEMRSETPOLYFILLMODE) pVoid ;
  1879. // Set the PolyFill Mode
  1880. iPolyFillMode = (INT) pMfSetPolyFillMode->iMode ;
  1881. // Do the translation.
  1882. b = DoSetPolyFillMode(pLocalDC, iPolyFillMode) ;
  1883. return (b) ;
  1884. }
  1885. /**************************************************************************
  1886. * Handler - SetRop2
  1887. *************************************************************************/
  1888. BOOL bHandleSetRop2(PVOID pVoid, PLOCALDC pLocalDC)
  1889. {
  1890. BOOL b ;
  1891. DWORD iDrawMode ;
  1892. PEMRSETROP2 pMfSetROP2 ;
  1893. pMfSetROP2 = (PEMRSETROP2) pVoid ;
  1894. // Set the Draw Mode
  1895. iDrawMode = pMfSetROP2->iMode ;
  1896. // Do the translation.
  1897. b = DoSetRop2(pLocalDC, iDrawMode) ;
  1898. return (b) ;
  1899. }
  1900. /**************************************************************************
  1901. * Handler - SetStretchBltMode
  1902. *************************************************************************/
  1903. BOOL bHandleSetStretchBltMode(PVOID pVoid, PLOCALDC pLocalDC)
  1904. {
  1905. BOOL b ;
  1906. DWORD iStretchMode ;
  1907. PEMRSETSTRETCHBLTMODE pMfSetStretchBltMode ;
  1908. pMfSetStretchBltMode = (PEMRSETSTRETCHBLTMODE) pVoid ;
  1909. // Set the StretchBlt Mode
  1910. iStretchMode = pMfSetStretchBltMode->iMode ;
  1911. // Do the translation.
  1912. b = DoSetStretchBltMode(pLocalDC, iStretchMode) ;
  1913. return (b) ;
  1914. }
  1915. /**************************************************************************
  1916. * Handler - SetTextAlign
  1917. *************************************************************************/
  1918. BOOL bHandleSetTextAlign(PVOID pVoid, PLOCALDC pLocalDC)
  1919. {
  1920. BOOL b ;
  1921. DWORD fMode ;
  1922. PEMRSETTEXTALIGN pMfSetTextAlign ;
  1923. pMfSetTextAlign = (PEMRSETTEXTALIGN) pVoid ;
  1924. // Set the TextAlign Mode
  1925. fMode = pMfSetTextAlign->iMode ;
  1926. // Do the translation.
  1927. b = DoSetTextAlign(pLocalDC, fMode) ;
  1928. return (b) ;
  1929. }
  1930. /**************************************************************************
  1931. * Handler - SetTextColor
  1932. *************************************************************************/
  1933. BOOL bHandleSetTextColor(PVOID pVoid, PLOCALDC pLocalDC)
  1934. {
  1935. BOOL b ;
  1936. PEMRSETTEXTCOLOR pMfSetTextColor ;
  1937. pMfSetTextColor = (PEMRSETTEXTCOLOR) pVoid ;
  1938. // Do the translation.
  1939. b = DoSetTextColor(pLocalDC, pMfSetTextColor->crColor) ;
  1940. return (b) ;
  1941. }