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.

5965 lines
164 KiB

  1. /*************************************************************************\
  2. * Module Name: mfrec.cxx
  3. *
  4. * This file contains the member functions for the metafile record
  5. * classes defined in mfrec.hxx.
  6. *
  7. * Created: 12-June-1991 13:46:00
  8. * Author: Hock San Lee [hockl]
  9. *
  10. * Copyright (c) 1991-1999 Microsoft Corporation
  11. \*************************************************************************/
  12. #define NO_STRICT
  13. extern "C" {
  14. #if defined(_GDIPLUS_)
  15. #include <gpprefix.h>
  16. #endif
  17. #include <nt.h>
  18. #include <ntrtl.h>
  19. #include <nturtl.h>
  20. #include <stddef.h>
  21. #include <windows.h> // GDI function declarations.
  22. #include <winerror.h>
  23. #include "firewall.h"
  24. #define __CPLUSPLUS
  25. #include <winspool.h>
  26. #include <w32gdip.h>
  27. #include "ntgdistr.h"
  28. #include "winddi.h"
  29. #include "hmgshare.h"
  30. #include "icm.h"
  31. #include "local.h" // Local object support.
  32. #include "gdiicm.h"
  33. #include "metadef.h" // Metafile record type constants.
  34. #include "metarec.h" // Metafile recording functions.
  35. #include "mf16.h"
  36. #include "ntgdi.h"
  37. #include "nlsconv.h" // Ansi - Unicode conversions.
  38. }
  39. #include "rectl.hxx"
  40. #include "mfdc.hxx" // Metafile DC class declarations.
  41. #include "mfrec.hxx" // Metafile record class declarations.
  42. #ifdef LANGPACK
  43. LONG gdwDisableMetafileRec=0 ;
  44. #endif
  45. // Max number of pointl's allowed on stack before explicit memory allocation.
  46. #define MAX_STACK_POINTL 128
  47. #define STOCK_IMHE(imhe) \
  48. ( \
  49. ((imhe) & ENHMETA_STOCK_OBJECT) && \
  50. (((imhe) & ~ENHMETA_STOCK_OBJECT) <= PRIV_STOCK_LAST) \
  51. )
  52. #define VALID_IMHE(imhe,cht) \
  53. ( \
  54. (((UINT) (imhe)) < ((UINT) (cht))) && \
  55. ((imhe) != 0) \
  56. )
  57. // FNBMRPLAY afnbMRPlay[EMR_MAX-EMR_MIN+1]
  58. typedef BOOL (MR::*MRPFN)(HDC, PHANDLETABLE, UINT);
  59. //BOOL (MR::*afnbMRPlay[EMR_MAX-EMR_MIN+1])(HDC, PHANDLETABLE, UINT) = {
  60. MRPFN afnbMRPlay[EMR_MAX-EMR_MIN+1] = {
  61. (MRPFN)&MRMETAFILE::bPlay,
  62. (MRPFN)&MRPOLYBEZIER::bPlay,
  63. (MRPFN)&MRPOLYGON::bPlay,
  64. (MRPFN)&MRPOLYLINE::bPlay,
  65. (MRPFN)&MRPOLYBEZIERTO::bPlay,
  66. (MRPFN)&MRPOLYLINETO::bPlay,
  67. (MRPFN)&MRPOLYPOLYLINE::bPlay,
  68. (MRPFN)&MRPOLYPOLYGON::bPlay,
  69. (MRPFN)&MRSETWINDOWEXTEX::bPlay,
  70. (MRPFN)&MRSETWINDOWORGEX::bPlay, // EMR_SETWINDOWORGEX 10
  71. (MRPFN)&MRSETVIEWPORTEXTEX::bPlay,
  72. (MRPFN)&MRSETVIEWPORTORGEX::bPlay,
  73. (MRPFN)&MRSETBRUSHORGEX::bPlay,
  74. (MRPFN)&MREOF::bPlay,
  75. (MRPFN)&MRSETPIXELV::bPlay,
  76. (MRPFN)&MRSETMAPPERFLAGS::bPlay,
  77. (MRPFN)&MRSETMAPMODE::bPlay,
  78. (MRPFN)&MRSETBKMODE::bPlay,
  79. (MRPFN)&MRSETPOLYFILLMODE::bPlay,
  80. (MRPFN)&MRSETROP2::bPlay, // EMR_SETROP2 20
  81. (MRPFN)&MRSETSTRETCHBLTMODE::bPlay,
  82. (MRPFN)&MRSETTEXTALIGN::bPlay,
  83. (MRPFN)&MRSETCOLORADJUSTMENT::bPlay,
  84. (MRPFN)&MRSETTEXTCOLOR::bPlay,
  85. (MRPFN)&MRSETBKCOLOR::bPlay,
  86. (MRPFN)&MROFFSETCLIPRGN::bPlay,
  87. (MRPFN)&MRMOVETOEX::bPlay,
  88. (MRPFN)&MRSETMETARGN::bPlay,
  89. (MRPFN)&MREXCLUDECLIPRECT::bPlay,
  90. (MRPFN)&MRINTERSECTCLIPRECT::bPlay, // EMR_INTERSECTCLIPRECT 30
  91. (MRPFN)&MRSCALEVIEWPORTEXTEX::bPlay,
  92. (MRPFN)&MRSCALEWINDOWEXTEX::bPlay,
  93. (MRPFN)&MRSAVEDC::bPlay,
  94. (MRPFN)&MRRESTOREDC::bPlay,
  95. (MRPFN)&MRSETWORLDTRANSFORM::bPlay,
  96. (MRPFN)&MRMODIFYWORLDTRANSFORM::bPlay,
  97. (MRPFN)&MRSELECTOBJECT::bPlay,
  98. (MRPFN)&MRCREATEPEN::bPlay,
  99. (MRPFN)&MRCREATEBRUSHINDIRECT::bPlay,
  100. (MRPFN)&MRDELETEOBJECT::bPlay, // EMR_DELETEOBJECT 40
  101. (MRPFN)&MRANGLEARC::bPlay,
  102. (MRPFN)&MRELLIPSE::bPlay,
  103. (MRPFN)&MRRECTANGLE::bPlay,
  104. (MRPFN)&MRROUNDRECT::bPlay,
  105. (MRPFN)&MRARC::bPlay,
  106. (MRPFN)&MRCHORD::bPlay,
  107. (MRPFN)&MRPIE::bPlay,
  108. (MRPFN)&MRSELECTPALETTE::bPlay,
  109. (MRPFN)&MRCREATEPALETTE::bPlay,
  110. (MRPFN)&MRSETPALETTEENTRIES::bPlay, // EMR_SETPALETTEENTRIES 50
  111. (MRPFN)&MRRESIZEPALETTE::bPlay,
  112. (MRPFN)&MRREALIZEPALETTE::bPlay,
  113. (MRPFN)&MREXTFLOODFILL::bPlay,
  114. (MRPFN)&MRLINETO::bPlay,
  115. (MRPFN)&MRARCTO::bPlay,
  116. (MRPFN)&MRPOLYDRAW::bPlay,
  117. (MRPFN)&MRSETARCDIRECTION::bPlay,
  118. (MRPFN)&MRSETMITERLIMIT::bPlay,
  119. (MRPFN)&MRBEGINPATH::bPlay,
  120. (MRPFN)&MRENDPATH::bPlay, // EMR_ENDPATH 60
  121. (MRPFN)&MRCLOSEFIGURE::bPlay,
  122. (MRPFN)&MRFILLPATH::bPlay,
  123. (MRPFN)&MRSTROKEANDFILLPATH::bPlay,
  124. (MRPFN)&MRSTROKEPATH::bPlay,
  125. (MRPFN)&MRFLATTENPATH::bPlay,
  126. (MRPFN)&MRWIDENPATH::bPlay,
  127. (MRPFN)&MRSELECTCLIPPATH::bPlay,
  128. (MRPFN)&MRABORTPATH::bPlay,
  129. (MRPFN)&MR::bPlay, // not used
  130. (MRPFN)&MRGDICOMMENT::bPlay, // EMR_GDICOMMENT 70
  131. (MRPFN)&MRFILLRGN::bPlay,
  132. (MRPFN)&MRFRAMERGN::bPlay,
  133. (MRPFN)&MRINVERTRGN::bPlay,
  134. (MRPFN)&MRPAINTRGN::bPlay,
  135. (MRPFN)&MREXTSELECTCLIPRGN::bPlay,
  136. (MRPFN)&MRBITBLT::bPlay,
  137. (MRPFN)&MRSTRETCHBLT::bPlay,
  138. (MRPFN)&MRMASKBLT::bPlay,
  139. (MRPFN)&MRPLGBLT::bPlay,
  140. (MRPFN)&MRSETDIBITSTODEVICE::bPlay, // EMR_SETDIBITSTODEVICE 80
  141. (MRPFN)&MRSTRETCHDIBITS::bPlay,
  142. (MRPFN)&MREXTCREATEFONTINDIRECTW::bPlay,
  143. (MRPFN)&MREXTTEXTOUT::bPlay, // EMR_EXTTEXTOUTA
  144. (MRPFN)&MREXTTEXTOUT::bPlay, // EMR_EXTTEXTOUTW
  145. (MRPFN)&MRBP16::bPlay, // EMR_POLYBEZIER16
  146. (MRPFN)&MRBP16::bPlay, // EMR_POLYGON16
  147. (MRPFN)&MRBP16::bPlay, // EMR_POLYLINE16
  148. (MRPFN)&MRBP16::bPlay, // EMR_POLYBEZIERTO16
  149. (MRPFN)&MRBP16::bPlay, // EMR_POLYLINETO16
  150. (MRPFN)&MRBPP16::bPlay, // EMR_POLYPOLYLINE16 90
  151. (MRPFN)&MRBPP16::bPlay, // EMR_POLYPOLYGON16
  152. (MRPFN)&MRPOLYDRAW16::bPlay,
  153. (MRPFN)&MRCREATEMONOBRUSH::bPlay,
  154. (MRPFN)&MRCREATEDIBPATTERNBRUSHPT::bPlay,
  155. (MRPFN)&MREXTCREATEPEN::bPlay,
  156. (MRPFN)&MRPOLYTEXTOUT::bPlay, // EMR_POLYTEXTOUTA
  157. (MRPFN)&MRPOLYTEXTOUT::bPlay, // EMR_POLYTEXTOUTW
  158. (MRPFN)&MRSETICMMODE::bPlay,
  159. (MRPFN)&MRCREATECOLORSPACE::bPlay, // EMR_CREATECOLORSPACE (ansi)
  160. (MRPFN)&MRSETCOLORSPACE::bPlay, // EMR_SETCOLORSPACE 100
  161. (MRPFN)&MRDELETECOLORSPACE::bPlay,
  162. (MRPFN)&MRGLSRECORD::bPlay, // EMR_GLSRECORD
  163. (MRPFN)&MRGLSBOUNDEDRECORD::bPlay, // EMR_GLSBOUNDEDRECORD
  164. (MRPFN)&MRPIXELFORMAT::bPlay, // EMR_PIXELFORMAT
  165. (MRPFN)&MRESCAPE::bPlay, // EMR_DRAWESCAPE
  166. (MRPFN)&MRESCAPE::bPlay, // EMR_EXTESCAPE
  167. (MRPFN)&MRSTARTDOC::bPlay,
  168. (MRPFN)&MRSMALLTEXTOUT::bPlay,
  169. (MRPFN)&MRFORCEUFIMAPPING::bPlay,
  170. (MRPFN)&MRNAMEDESCAPE::bPlay, // EMR_NAMEDESCAPE 110
  171. (MRPFN)&MRCOLORCORRECTPALETTE::bPlay,
  172. (MRPFN)&MRSETICMPROFILE::bPlay, // EMR_SETICMPROFILEA
  173. (MRPFN)&MRSETICMPROFILE::bPlay, // EMR_SETICMPROFILEW
  174. (MRPFN)&MRALPHABLEND::bPlay,
  175. (MRPFN)&MRSETLAYOUT::bPlay, // EMR_SETLAYOUT
  176. (MRPFN)&MRTRANSPARENTBLT::bPlay,
  177. (MRPFN)&MR::bPlay, // not used
  178. (MRPFN)&MRGRADIENTFILL::bPlay,
  179. (MRPFN)&MRSETLINKEDUFIS::bPlay,
  180. (MRPFN)&MRSETTEXTJUSTIFICATION::bPlay, // 120
  181. (MRPFN)&MRCOLORMATCHTOTARGET::bPlay, // EMF_COLORMATCHTOTARGET
  182. (MRPFN)&MRCREATECOLORSPACEW::bPlay, // EMR_CREATECOLORSPACEW (unicode)
  183. };
  184. // FNBMRCHECK afnbMRCheck[EMR_MAX-EMR_MIN+1]
  185. typedef BOOL (MR::*MRCHKPFN)(PHANDLETABLE);
  186. //BOOL (MR::*afnbMRCheck[EMR_MAX-EMR_MIN+1])(PHANDLETABLE) = {
  187. MRCHKPFN afnbMRCheck[EMR_MAX-EMR_MIN+1] = {
  188. (MRCHKPFN)&MRMETAFILE::bCheckRecord,
  189. (MRCHKPFN)&MRPOLYBEZIER::bCheckRecord,
  190. (MRCHKPFN)&MRPOLYGON::bCheckRecord,
  191. (MRCHKPFN)&MRPOLYLINE::bCheckRecord,
  192. (MRCHKPFN)&MRPOLYBEZIERTO::bCheckRecord,
  193. (MRCHKPFN)&MRPOLYLINETO::bCheckRecord,
  194. (MRCHKPFN)&MRPOLYPOLYLINE::bCheckRecord,
  195. (MRCHKPFN)&MRPOLYPOLYGON::bCheckRecord,
  196. (MRCHKPFN)&MRSETWINDOWEXTEX::bCheckRecord,
  197. (MRCHKPFN)&MRSETWINDOWORGEX::bCheckRecord, // EMR_SETWINDOWORGEX 10
  198. (MRCHKPFN)&MRSETVIEWPORTEXTEX::bCheckRecord,
  199. (MRCHKPFN)&MRSETVIEWPORTORGEX::bCheckRecord,
  200. (MRCHKPFN)&MRSETBRUSHORGEX::bCheckRecord,
  201. (MRCHKPFN)&MREOF::bCheckRecord,
  202. (MRCHKPFN)&MRSETPIXELV::bCheckRecord,
  203. (MRCHKPFN)&MRSETMAPPERFLAGS::bCheckRecord,
  204. (MRCHKPFN)&MRSETMAPMODE::bCheckRecord,
  205. (MRCHKPFN)&MRSETBKMODE::bCheckRecord,
  206. (MRCHKPFN)&MRSETPOLYFILLMODE::bCheckRecord,
  207. (MRCHKPFN)&MRSETROP2::bCheckRecord, // EMR_SETROP2 20
  208. (MRCHKPFN)&MRSETSTRETCHBLTMODE::bCheckRecord,
  209. (MRCHKPFN)&MRSETTEXTALIGN::bCheckRecord,
  210. (MRCHKPFN)&MRSETCOLORADJUSTMENT::bCheckRecord,
  211. (MRCHKPFN)&MRSETTEXTCOLOR::bCheckRecord,
  212. (MRCHKPFN)&MRSETBKCOLOR::bCheckRecord,
  213. (MRCHKPFN)&MROFFSETCLIPRGN::bCheckRecord,
  214. (MRCHKPFN)&MRMOVETOEX::bCheckRecord,
  215. (MRCHKPFN)&MRSETMETARGN::bCheckRecord,
  216. (MRCHKPFN)&MREXCLUDECLIPRECT::bCheckRecord,
  217. (MRCHKPFN)&MRINTERSECTCLIPRECT::bCheckRecord, // EMR_INTERSECTCLIPRECT 30
  218. (MRCHKPFN)&MRSCALEVIEWPORTEXTEX::bCheckRecord,
  219. (MRCHKPFN)&MRSCALEWINDOWEXTEX::bCheckRecord,
  220. (MRCHKPFN)&MRSAVEDC::bCheckRecord,
  221. (MRCHKPFN)&MRRESTOREDC::bCheckRecord,
  222. (MRCHKPFN)&MRSETWORLDTRANSFORM::bCheckRecord,
  223. (MRCHKPFN)&MRMODIFYWORLDTRANSFORM::bCheckRecord,
  224. (MRCHKPFN)&MRSELECTOBJECT::bCheckRecord,
  225. (MRCHKPFN)&MRCREATEPEN::bCheckRecord,
  226. (MRCHKPFN)&MRCREATEBRUSHINDIRECT::bCheckRecord,
  227. (MRCHKPFN)&MRDELETEOBJECT::bCheckRecord, // EMR_DELETEOBJECT 40
  228. (MRCHKPFN)&MRANGLEARC::bCheckRecord,
  229. (MRCHKPFN)&MRELLIPSE::bCheckRecord,
  230. (MRCHKPFN)&MRRECTANGLE::bCheckRecord,
  231. (MRCHKPFN)&MRROUNDRECT::bCheckRecord,
  232. (MRCHKPFN)&MRARC::bCheckRecord,
  233. (MRCHKPFN)&MRCHORD::bCheckRecord,
  234. (MRCHKPFN)&MRPIE::bCheckRecord,
  235. (MRCHKPFN)&MRSELECTPALETTE::bCheckRecord,
  236. (MRCHKPFN)&MRCREATEPALETTE::bCheckRecord,
  237. (MRCHKPFN)&MRSETPALETTEENTRIES::bCheckRecord, // EMR_SETPALETTEENTRIES 50
  238. (MRCHKPFN)&MRRESIZEPALETTE::bCheckRecord,
  239. (MRCHKPFN)&MRREALIZEPALETTE::bCheckRecord,
  240. (MRCHKPFN)&MREXTFLOODFILL::bCheckRecord,
  241. (MRCHKPFN)&MRLINETO::bCheckRecord,
  242. (MRCHKPFN)&MRARCTO::bCheckRecord,
  243. (MRCHKPFN)&MRPOLYDRAW::bCheckRecord,
  244. (MRCHKPFN)&MRSETARCDIRECTION::bCheckRecord,
  245. (MRCHKPFN)&MRSETMITERLIMIT::bCheckRecord,
  246. (MRCHKPFN)&MRBEGINPATH::bCheckRecord,
  247. (MRCHKPFN)&MRENDPATH::bCheckRecord, // EMR_ENDPATH 60
  248. (MRCHKPFN)&MRCLOSEFIGURE::bCheckRecord,
  249. (MRCHKPFN)&MRFILLPATH::bCheckRecord,
  250. (MRCHKPFN)&MRSTROKEANDFILLPATH::bCheckRecord,
  251. (MRCHKPFN)&MRSTROKEPATH::bCheckRecord,
  252. (MRCHKPFN)&MRFLATTENPATH::bCheckRecord,
  253. (MRCHKPFN)&MRWIDENPATH::bCheckRecord,
  254. (MRCHKPFN)&MRSELECTCLIPPATH::bCheckRecord,
  255. (MRCHKPFN)&MRABORTPATH::bCheckRecord,
  256. (MRCHKPFN)&MR::bCheckRecord, // not used
  257. (MRCHKPFN)&MRGDICOMMENT::bCheckRecord, // EMR_GDICOMMENT 70
  258. (MRCHKPFN)&MRFILLRGN::bCheckRecord,
  259. (MRCHKPFN)&MRFRAMERGN::bCheckRecord,
  260. (MRCHKPFN)&MRINVERTRGN::bCheckRecord,
  261. (MRCHKPFN)&MRPAINTRGN::bCheckRecord,
  262. (MRCHKPFN)&MREXTSELECTCLIPRGN::bCheckRecord,
  263. (MRCHKPFN)&MRBITBLT::bCheckRecord,
  264. (MRCHKPFN)&MRSTRETCHBLT::bCheckRecord,
  265. (MRCHKPFN)&MRMASKBLT::bCheckRecord,
  266. (MRCHKPFN)&MRPLGBLT::bCheckRecord,
  267. (MRCHKPFN)&MRSETDIBITSTODEVICE::bCheckRecord, // EMR_SETDIBITSTODEVICE 80
  268. (MRCHKPFN)&MRSTRETCHDIBITS::bCheckRecord,
  269. (MRCHKPFN)&MREXTCREATEFONTINDIRECTW::bCheckRecord,
  270. (MRCHKPFN)&MREXTTEXTOUT::bCheckRecord, // EMR_EXTTEXTOUTA
  271. (MRCHKPFN)&MREXTTEXTOUT::bCheckRecord, // EMR_EXTTEXTOUTW
  272. (MRCHKPFN)&MRBP16::bCheckRecord, // EMR_POLYBEZIER16
  273. (MRCHKPFN)&MRBP16::bCheckRecord, // EMR_POLYGON16
  274. (MRCHKPFN)&MRBP16::bCheckRecord, // EMR_POLYLINE16
  275. (MRCHKPFN)&MRBP16::bCheckRecord, // EMR_POLYBEZIERTO16
  276. (MRCHKPFN)&MRBP16::bCheckRecord, // EMR_POLYLINETO16
  277. (MRCHKPFN)&MRBPP16::bCheckRecord, // EMR_POLYPOLYLINE16 90
  278. (MRCHKPFN)&MRBPP16::bCheckRecord, // EMR_POLYPOLYGON16
  279. (MRCHKPFN)&MRPOLYDRAW16::bCheckRecord,
  280. (MRCHKPFN)&MRCREATEMONOBRUSH::bCheckRecord,
  281. (MRCHKPFN)&MRCREATEDIBPATTERNBRUSHPT::bCheckRecord,
  282. (MRCHKPFN)&MREXTCREATEPEN::bCheckRecord,
  283. (MRCHKPFN)&MRPOLYTEXTOUT::bCheckRecord, // EMR_POLYTEXTOUTA
  284. (MRCHKPFN)&MRPOLYTEXTOUT::bCheckRecord, // EMR_POLYTEXTOUTW
  285. (MRCHKPFN)&MRSETICMMODE::bCheckRecord,
  286. (MRCHKPFN)&MRCREATECOLORSPACE::bCheckRecord, // EMR_CREATECOLORSPACE (ansi)
  287. (MRCHKPFN)&MRSETCOLORSPACE::bCheckRecord, // EMR_SETCOLORSPACE 100
  288. (MRCHKPFN)&MRDELETECOLORSPACE::bCheckRecord,
  289. (MRCHKPFN)&MRGLSRECORD::bCheckRecord, // EMR_GLSRECORD
  290. (MRCHKPFN)&MRGLSBOUNDEDRECORD::bCheckRecord, // EMR_GLSBOUNDEDRECORD
  291. (MRCHKPFN)&MRPIXELFORMAT::bCheckRecord, // EMR_PIXELFORMAT
  292. (MRCHKPFN)&MRESCAPE::bCheckRecord, // EMR_DRAWESCAPE
  293. (MRCHKPFN)&MRESCAPE::bCheckRecord, // EMR_EXTESCAPE
  294. (MRCHKPFN)&MRSTARTDOC::bCheckRecord,
  295. (MRCHKPFN)&MRSMALLTEXTOUT::bCheckRecord,
  296. (MRCHKPFN)&MRFORCEUFIMAPPING::bCheckRecord,
  297. (MRCHKPFN)&MRNAMEDESCAPE::bCheckRecord, // EMR_NAMEDESCAPE 110
  298. (MRCHKPFN)&MRCOLORCORRECTPALETTE::bCheckRecord,
  299. (MRCHKPFN)&MRSETICMPROFILE::bCheckRecord, // EMR_SETICMPROFILEA
  300. (MRCHKPFN)&MRSETICMPROFILE::bCheckRecord, // EMR_SETICMPROFILEW
  301. (MRCHKPFN)&MRALPHABLEND::bCheckRecord,
  302. (MRCHKPFN)&MRSETLAYOUT::bCheckRecord, // EMR_SETLAYOUT
  303. (MRCHKPFN)&MRTRANSPARENTBLT::bCheckRecord,
  304. (MRCHKPFN)&MR::bCheckRecord, // not used
  305. (MRCHKPFN)&MRGRADIENTFILL::bCheckRecord,
  306. (MRCHKPFN)&MRSETLINKEDUFIS::bCheckRecord,
  307. (MRCHKPFN)&MRSETTEXTJUSTIFICATION::bCheckRecord, // 120
  308. (MRCHKPFN)&MRCOLORMATCHTOTARGET::bCheckRecord, // EMF_COLORMATCHTOTARGET
  309. (MRCHKPFN)&MRCREATECOLORSPACEW::bCheckRecord, // EMR_CREATECOLORSPACEW (unicode)
  310. };
  311. /******************************Public*Routine******************************\
  312. * CreateMonoDib
  313. *
  314. * This is the same as CreateBitmap except that the bits are assumed
  315. * to be DWORD aligned and that the scans start from the bottom of the bitmap.
  316. *
  317. * This routine is temporary until CreateDIBitmap supports monochrome bitmaps!
  318. *
  319. * History:
  320. * Sun Jun 14 12:22:11 1992 -by- Hock San Lee [hockl]
  321. * Wrote it.
  322. \**************************************************************************/
  323. extern "C" HBITMAP CreateMonoDib
  324. (
  325. LPBITMAPINFO pbmi,
  326. CONST BYTE * pjBits,
  327. UINT iUsage
  328. )
  329. {
  330. HBITMAP hbm;
  331. ASSERTGDI(pbmi->bmiHeader.biPlanes == 1, "CreateMonoDib: bad biPlanes value");
  332. ASSERTGDI(pbmi->bmiHeader.biBitCount == 1, "CreateMonoDib: bad biBitCount value");
  333. hbm = CreateBitmap((int) pbmi->bmiHeader.biWidth,
  334. (int) pbmi->bmiHeader.biHeight,
  335. (UINT) 1,
  336. (UINT) 1,
  337. (CONST VOID *) NULL);
  338. if (!hbm)
  339. return(hbm);
  340. SetDIBits((HDC) 0, hbm, 0, (UINT) pbmi->bmiHeader.biHeight,
  341. (CONST VOID *) pjBits, pbmi, iUsage);
  342. return(hbm);
  343. }
  344. /******************************Public*Routine******************************\
  345. * CreateCompatibleDCAdvanced
  346. *
  347. * Create a compatible DC in the advanced graphics mode. The advanced
  348. * graphics mode is required to modify the world transform.
  349. *
  350. * History:
  351. * Wed Nov 4 14:21:00 1992 -by- Hock San Lee [hockl]
  352. * Wrote it.
  353. \**************************************************************************/
  354. extern "C" HDC CreateCompatibleDCAdvanced(HDC hdc)
  355. {
  356. HDC hdcRet;
  357. hdcRet = CreateCompatibleDC(hdc);
  358. SetGraphicsMode(hdcRet, GM_ADVANCED);
  359. return(hdcRet);
  360. }
  361. /******************************Public*Routine******************************\
  362. * GetBrushBits
  363. *
  364. * This function is really a hack. In the current implementation,
  365. * gdisrv keeps the original brush color table for both DIB_PAL_COLORS
  366. * and DIB_RGB_COLORS usages. The size of the table is
  367. * sizeof(RGBQUAD) * nEntries in both cases. In order to get the
  368. * bits and bitmap info using GetDIBits, it requires that the usage
  369. * be DIB_RGB_COLORS in the case of DIB_PAL_COLORS to prevent
  370. * color translation. But it actually returns the original palette
  371. * indices stored in the brush color table.
  372. *
  373. * History:
  374. * Mon Feb 1 10:22:23 1993 -by- Hock San Lee [hockl]
  375. * Wrote it.
  376. \******************************Public*Routine******************************/
  377. extern "C" int GetBrushBits
  378. (
  379. HDC hdc,
  380. HBITMAP hbm,
  381. UINT iUsage,
  382. DWORD cbBmi,
  383. LPVOID pBits,
  384. LPBITMAPINFO pBmi
  385. )
  386. {
  387. if (iUsage == DIB_PAL_COLORS)
  388. {
  389. LPBITMAPINFO pBmiTmp;
  390. int iRet;
  391. DWORD cEntries;
  392. ASSERTGDI((cbBmi - sizeof(BMIH)) % 2 == 0, "GetBrushBits: Bad cbBmi\n");
  393. cEntries = (cbBmi - sizeof(BMIH)) / sizeof(WORD);
  394. // Allocate bitmap info to accommodate RGBQUADs.
  395. if (!(pBmiTmp = (PBMI) LocalAlloc(LMEM_FIXED,
  396. (UINT) (cEntries * sizeof(RGBQUAD) + sizeof(BMIH)))))
  397. return(0);
  398. *(PBMIH) pBmiTmp = *(PBMIH) pBmi;
  399. // Get bitmap info and bits.
  400. iRet = GetDIBits(hdc, hbm,
  401. 0, (UINT) pBmi->bmiHeader.biHeight,
  402. pBits, pBmiTmp, DIB_RGB_COLORS);
  403. // Get the bitmap info header and palette indexes.
  404. RtlCopyMemory((PBYTE) pBmi, (PBYTE) pBmiTmp, cbBmi);
  405. // Free the temporary bitmap info.
  406. if (LocalFree(pBmiTmp))
  407. {
  408. ASSERTGDI(FALSE, "GetBrushBits: LocalFree failed\n");
  409. }
  410. return(iRet);
  411. }
  412. else
  413. {
  414. // Get bitmap info and bits.
  415. return(GetDIBits(hdc, hbm,
  416. 0, (UINT) pBmi->bmiHeader.biHeight,
  417. pBits, pBmi, iUsage));
  418. }
  419. }
  420. /******************************Public*Routine******************************\
  421. * VOID MRBP::vInit(iType1, cptl1, aptl1, pmdc)
  422. *
  423. * Initializers -- Initialize the metafile Poly(To) record.
  424. *
  425. * History:
  426. * Thu Jul 18 11:19:20 1991 -by- Hock San Lee [hockl]
  427. * Wrote it.
  428. \**************************************************************************/
  429. VOID MRBP::vInit(DWORD iType1, DWORD cptl1, CONST POINTL *aptl1, PMDC pmdc)
  430. {
  431. PUTS("MRBP::vInit\n");
  432. MRB::vInit(iType1, pmdc);
  433. cptl = cptl1;
  434. RtlCopyMemory((PBYTE) aptl, (PBYTE) aptl1, cptl1 * sizeof(POINTL));
  435. }
  436. /******************************Public*Routine******************************\
  437. * VOID MRBP16::vInit(iType1, cptl1, aptl1, pmdc)
  438. *
  439. * Initializers -- Initialize the metafile Poly(To)16 record.
  440. *
  441. * History:
  442. * Sat Mar 07 15:06:16 1992 -by- Hock San Lee [hockl]
  443. * Wrote it.
  444. \**************************************************************************/
  445. VOID MRBP16::vInit(DWORD iType1, DWORD cptl1, CONST POINTL *aptl1, PMDC pmdc)
  446. {
  447. PUTS("MRBP16::vInit\n");
  448. MRB::vInit(iType1, pmdc);
  449. cpts = cptl1;
  450. POINTL_TO_POINTS(apts, aptl1, cptl1);
  451. }
  452. /******************************Public*Routine******************************\
  453. * VOID MRBPP::vInit(iType1, cPoly1, cptl1, ac1, aptl1, pmdc)
  454. *
  455. * Initializers -- Initialize the metafile PolyPoly record.
  456. *
  457. * History:
  458. * Thu Jul 18 11:19:20 1991 -by- Hock San Lee [hockl]
  459. * Wrote it.
  460. \**************************************************************************/
  461. VOID MRBPP::vInit
  462. (
  463. DWORD iType1,
  464. DWORD cPoly1,
  465. DWORD cptl1,
  466. CONST DWORD *ac1,
  467. CONST POINTL *aptl1,
  468. PMDC pmdc
  469. )
  470. {
  471. PUTS("MRBPP::vInit\n");
  472. MRB::vInit(iType1, pmdc);
  473. cPoly = cPoly1;
  474. cptl = cptl1;
  475. RtlCopyMemory((PBYTE) &ac, (PBYTE) ac1, cPoly1 * sizeof(DWORD));
  476. RtlCopyMemory((PBYTE) &ac[cPoly1], (PBYTE) aptl1, cptl1 * sizeof(POINTL));
  477. }
  478. /******************************Public*Routine******************************\
  479. * VOID MRBPP16::vInit(iType1, cPoly1, cptl, ac1, aptl1, pmdc)
  480. *
  481. * Initializers -- Initialize the metafile PolyPoly16 record.
  482. *
  483. * History:
  484. * Sat Mar 07 15:06:16 1992 -by- Hock San Lee [hockl]
  485. * Wrote it.
  486. \**************************************************************************/
  487. VOID MRBPP16::vInit
  488. (
  489. DWORD iType1,
  490. DWORD cPoly1,
  491. DWORD cptl1,
  492. CONST DWORD *ac1,
  493. CONST POINTL *aptl1,
  494. PMDC pmdc
  495. )
  496. {
  497. PUTS("MRBPP16::vInit\n");
  498. MRB::vInit(iType1, pmdc);
  499. cPoly = cPoly1;
  500. cpts = cptl1;
  501. RtlCopyMemory((PBYTE) &ac, (PBYTE) ac1, cPoly1 * sizeof(DWORD));
  502. POINTL_TO_POINTS((PPOINTS) &ac[cPoly1], aptl1, cptl1);
  503. }
  504. /******************************Public*Routine******************************\
  505. * VOID MRPOLYDRAW::vInit(pmdc, aptl1, ab1, cptl1)
  506. *
  507. * Initializers -- Initialize the metafile MRPOLYDRAW record.
  508. *
  509. * History:
  510. * Thu Oct 17 14:11:36 1991 -by- Hock San Lee [hockl]
  511. * Wrote it.
  512. \**************************************************************************/
  513. VOID MRPOLYDRAW::vInit(PMDC pmdc, CONST POINTL *aptl1, CONST BYTE *ab1, DWORD cptl1)
  514. {
  515. PUTS("MRPOLYDRAW::vInit\n");
  516. MRB::vInit(EMR_POLYDRAW, pmdc);
  517. cptl = cptl1;
  518. RtlCopyMemory((PBYTE) aptl, (PBYTE) aptl1, cptl1 * sizeof(POINTL));
  519. RtlCopyMemory((PBYTE) &aptl[cptl1], ab1, cptl1 * sizeof(BYTE));
  520. }
  521. /******************************Public*Routine******************************\
  522. * VOID MRPOLYDRAW16::vInit(pmdc, aptl1, ab1, cptl1)
  523. *
  524. * Initializers -- Initialize the metafile MRPOLYDRAW16 record.
  525. *
  526. * History:
  527. * Sat Mar 07 15:06:16 1992 -by- Hock San Lee [hockl]
  528. * Wrote it.
  529. \**************************************************************************/
  530. VOID MRPOLYDRAW16::vInit(PMDC pmdc, CONST POINTL *aptl1, CONST BYTE *ab1, DWORD cptl1)
  531. {
  532. PUTS("MRPOLYDRAW16::vInit\n");
  533. MRB::vInit(EMR_POLYDRAW16, pmdc);
  534. cpts = cptl1;
  535. POINTL_TO_POINTS(apts, aptl1, cptl1);
  536. RtlCopyMemory((PBYTE) &apts[cptl1], ab1, cptl1 * sizeof(BYTE));
  537. }
  538. /******************************Public*Routine******************************\
  539. * VOID MRTRIANGLEMESH::bInit
  540. *
  541. * Initializers -- Initialize the metafile MRTRIANGLEMESH
  542. *
  543. * History:
  544. *
  545. * 12/3/1996 Mark Enstrom [marke]
  546. *
  547. \**************************************************************************/
  548. VOID MRGRADIENTFILL::vInit(DWORD nVer1, CONST TRIVERTEX *pVer1, DWORD nTri1,CONST PVOID pTri1,ULONG ulMode1,PMDC pmdc)
  549. {
  550. PUTS("MRGRADIENTFILL::vInit\n");
  551. MRB::vInit(EMR_GRADIENTFILL, pmdc);
  552. nVer = nVer1;
  553. nTri = nTri1;
  554. ulMode = ulMode1;
  555. RtlCopyMemory((PBYTE) &Ver[0],pVer1,nVer * sizeof(TRIVERTEX));
  556. if (ulMode & GRADIENT_FILL_TRIANGLE)
  557. {
  558. RtlCopyMemory((PBYTE) &Ver[nVer],pTri1,nTri * sizeof(GRADIENT_TRIANGLE));
  559. }
  560. else
  561. {
  562. RtlCopyMemory((PBYTE) &Ver[nVer],pTri1,nTri * sizeof(GRADIENT_RECT));
  563. }
  564. }
  565. /******************************Public*Routine******************************\
  566. * BOOL MRMETAFILE::bValid()
  567. *
  568. * bValid -- Is this a valid record?
  569. *
  570. * History:
  571. * Tue Aug 20 18:19:38 1991 -by- Hock San Lee [hockl]
  572. * Wrote it.
  573. \**************************************************************************/
  574. BOOL MRMETAFILE::bValid()
  575. {
  576. PUTS("MRMETAFILE::bValid\n");
  577. // We do not check the version. We will try to play a future version of
  578. // enhanced metafile.
  579. if (dSignature != ENHMETA_SIGNATURE // check signature
  580. || iType != EMR_HEADER // check record type
  581. || nHandles == 0 // must have at least a reserved handle
  582. || nBytes % 4) // nBytes must be dword multiples
  583. return (FALSE);
  584. return(TRUE);
  585. }
  586. /******************************Public*Routine******************************\
  587. * BOOL MRCREATEPALETTE::bInit(hpal_, imhe_, cEntries_)
  588. *
  589. * Initializers -- Initialize the metafile MRCREATEPALETTE record.
  590. * It sets the peFlags in the palette entries to zeroes.
  591. *
  592. * History:
  593. * Sun Sep 22 16:34:36 1991 -by- Hock San Lee [hockl]
  594. * Wrote it.
  595. \**************************************************************************/
  596. BOOL MRCREATEPALETTE::bInit(HPALETTE hpal_, ULONG imhe_, USHORT cEntries_)
  597. {
  598. PUTS("MRCREATEPALETTE::bInit\n");
  599. MR::vInit(EMR_CREATEPALETTE);
  600. imhe = imhe_;
  601. logpal.palVersion = 0x300;
  602. logpal.palNumEntries = cEntries_;
  603. if (GetPaletteEntries(hpal_, 0, (UINT) cEntries_, logpal.palPalEntry)
  604. != (UINT) cEntries_)
  605. return(FALSE);
  606. for (USHORT ii = 0; ii < cEntries_; ii++)
  607. {
  608. // Since we don't support PC_EXPLICIT, we set it to black. This will
  609. // prevent us from adding meaningless colors to the metafile palette.
  610. ASSERTGDI(sizeof(PALETTEENTRY) == sizeof(DWORD), "Bad size");
  611. if (logpal.palPalEntry[ii].peFlags & PC_EXPLICIT)
  612. *((PDWORD) &logpal.palPalEntry[ii]) = RGB(0,0,0);
  613. else
  614. logpal.palPalEntry[ii].peFlags = 0;
  615. }
  616. return(TRUE);
  617. }
  618. /******************************Public*Routine******************************\
  619. * VOID MRSETPALETTEENTRIES::vInit(imhe_, iStart_, cEntries_, pPalEntries_)
  620. *
  621. * Initializers -- Initialize the metafile MRSETPALETTEENTRIES record.
  622. * It sets the peFlags in the palette entries to zeroes.
  623. *
  624. * History:
  625. * Sun Sep 22 16:34:36 1991 -by- Hock San Lee [hockl]
  626. * Wrote it.
  627. \**************************************************************************/
  628. VOID MRSETPALETTEENTRIES::vInit
  629. (
  630. ULONG imhe_,
  631. UINT iStart_,
  632. UINT cEntries_,
  633. CONST PALETTEENTRY *pPalEntries_
  634. )
  635. {
  636. PUTS("MRSETPALETTEENTRIES::bInit\n");
  637. MR::vInit(EMR_SETPALETTEENTRIES);
  638. imhe = imhe_;
  639. iStart = iStart_;
  640. cEntries = cEntries_;
  641. for (UINT ii = 0; ii < cEntries_; ii++)
  642. {
  643. aPalEntry[ii] = pPalEntries_[ii];
  644. // Since we don't support PC_EXPLICIT, we set it to black. This will
  645. // prevent us from adding meaningless colors to the metafile palette.
  646. ASSERTGDI(sizeof(PALETTEENTRY) == sizeof(DWORD), "Bad size");
  647. if (aPalEntry[ii].peFlags & PC_EXPLICIT)
  648. *((PDWORD) &aPalEntry[ii]) = RGB(0,0,0);
  649. else
  650. aPalEntry[ii].peFlags = 0;
  651. }
  652. }
  653. /******************************Public*Routine******************************\
  654. * BOOL MTEXT::bInit(hdc1, x1, y1, fl1, prc1, pString1, cchString1, pdx1,
  655. * pMR1, offString1, cjCh1)
  656. *
  657. * Initializers -- Initialize the base record for all textout metafile records.
  658. *
  659. * History:
  660. * Thu Aug 24 15:20:33 1992 -by- Hock San Lee [hockl]
  661. * Wrote it.
  662. \**************************************************************************/
  663. BOOL MTEXT::bInit
  664. (
  665. HDC hdc1,
  666. int x1,
  667. int y1,
  668. UINT fl1,
  669. CONST RECT *prc1,
  670. LPCSTR pString1,
  671. int cchString1,
  672. CONST INT *pdx1,
  673. PMR pMR1,
  674. DWORD offString1, // dword-aligned aDx follows the string
  675. int cjCh1 // size of a character in bytes
  676. )
  677. {
  678. int i;
  679. SIZEL szl;
  680. PUTS("MTEXT::bInit\n");
  681. ASSERTGDI(cjCh1 == sizeof(CHAR) || cjCh1 == sizeof(WCHAR),
  682. "MTEXT::bInit: bad char size");
  683. eptlRef.vInit((LONG) x1, (LONG) y1);
  684. fOptions = (DWORD) fl1;
  685. if (fl1 & (ETO_CLIPPED | ETO_OPAQUE))
  686. ercl.vInit(*(PRECTL) prc1);
  687. else
  688. ercl.vInit(rclNull);
  689. // Copy the string.
  690. cchString = cchString1;
  691. offString = offString1;
  692. RtlCopyMemory((PBYTE) pMR1 + offString1, (PBYTE) pString1, cchString1 * cjCh1);
  693. // Initialize the Dx array. If it is not given, we will make one up
  694. // since we always need one by design!
  695. offaDx = offString1 + (cchString1 * cjCh1 + 3) / 4 * 4; // make it dword-aligned
  696. PLONG aDx = (PLONG) ((PBYTE) pMR1 + offaDx);
  697. if (pdx1 != (CONST INT *)NULL)
  698. {
  699. RtlCopyMemory((PBYTE) aDx, (PBYTE) pdx1,
  700. cchString1 * (sizeof(LONG) * ((fOptions & ETO_PDY) ? 2 : 1)));
  701. }
  702. else if (cchString1 != 0)
  703. {
  704. if (cjCh1 == sizeof(CHAR))
  705. {
  706. // szl and nMaxExtent are needed by the function!
  707. if (!GetTextExtentExPointA
  708. (
  709. hdc1,
  710. pString1,
  711. cchString1,
  712. MAXLONG,
  713. (LPINT) NULL,
  714. (LPINT) aDx,
  715. (LPSIZE) &szl
  716. )
  717. )
  718. return(FALSE);
  719. }
  720. else
  721. {
  722. // szl and nMaxExtent are needed by the function!
  723. #ifdef LANGPACK
  724. // [bodind], I think this is non optimal solution
  725. // this should be done more elegantly
  726. if (gbLpk) // check if there is an LPK
  727. {
  728. BOOL bTmp;
  729. InterlockedIncrement( &gdwDisableMetafileRec ) ;
  730. bTmp = GetTextExtentExPointW
  731. (
  732. hdc1,
  733. (LPWSTR) pString1,
  734. cchString1,
  735. (ULONG)0xffffffff,
  736. NULL,
  737. (PINT) aDx,
  738. (LPSIZE) &szl
  739. );
  740. InterlockedDecrement( &gdwDisableMetafileRec ) ;
  741. if (!bTmp)
  742. {
  743. return FALSE ;
  744. }
  745. }
  746. else
  747. #endif
  748. {
  749. if (!NtGdiGetTextExtentExW
  750. (
  751. hdc1,
  752. (LPWSTR) pString1,
  753. cchString1,
  754. (ULONG)0xffffffff,
  755. NULL,
  756. (PULONG) aDx,
  757. (LPSIZE) &szl, 0
  758. )
  759. )
  760. return(FALSE);
  761. }
  762. }
  763. // Convert partial widths to individual widths.
  764. for (i = cchString1 - 1; i > 0; i--)
  765. aDx[i] -= aDx[i - 1];
  766. }
  767. return(TRUE);
  768. }
  769. /******************************Public*Routine******************************\
  770. * BOOL MRMETAFILE::bPlay(hdc, pht, cht)
  771. *
  772. * Play the metafile record.
  773. *
  774. * History:
  775. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  776. * Wrote it.
  777. \**************************************************************************/
  778. BOOL MRMETAFILE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  779. {
  780. PUTS("MRMETAFILE::bPlay\n");
  781. ASSERTGDI(iType == EMR_HEADER, "Bad record type");
  782. USE(cht);
  783. // If we are embedding the metafile, emit the public begin group comment.
  784. if (IS_ALTDC_TYPE(hdc))
  785. {
  786. PLDC pldc;
  787. DC_PLDC(hdc,pldc,FALSE);
  788. if (pldc->iType == LO_METADC)
  789. {
  790. PMF pmf;
  791. // Get metafile.
  792. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  793. return(FALSE);
  794. // Indicate we have emitted the begin group public comment for embedding this
  795. // enhanced metafile.
  796. pmf->bBeginGroup = TRUE;
  797. return(MF_GdiCommentBeginGroupEMF(hdc, (PENHMETAHEADER) this));
  798. }
  799. }
  800. return(TRUE);
  801. }
  802. /******************************Public*Routine******************************\
  803. * BOOL MRPOLYBEZIER::bPlay(hdc, pht, cht)
  804. *
  805. * Play the metafile record.
  806. *
  807. * History:
  808. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  809. * Wrote it.
  810. \**************************************************************************/
  811. BOOL MRPOLYBEZIER::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  812. {
  813. PUTS("MRPOLYBEZIER::bPlay\n");
  814. ASSERTGDI(iType == EMR_POLYBEZIER, "Bad record type");
  815. USE(pht);
  816. USE(cht);
  817. if (!bCheckRecord(pht))
  818. return(FALSE);
  819. return(PolyBezier(hdc, (LPPOINT) aptl, cptl));
  820. }
  821. /******************************Public*Routine******************************\
  822. * BOOL MRPOLYGON::bPlay(hdc, pht, cht)
  823. *
  824. * Play the metafile record.
  825. *
  826. * History:
  827. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  828. * Wrote it.
  829. \**************************************************************************/
  830. BOOL MRPOLYGON::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  831. {
  832. PUTS("MRPOLYGON::bPlay\n");
  833. ASSERTGDI(iType == EMR_POLYGON, "Bad record type");
  834. USE(pht);
  835. USE(cht);
  836. if (!bCheckRecord(pht))
  837. return(FALSE);
  838. return(Polygon(hdc, (LPPOINT) aptl, (int) cptl));
  839. }
  840. /******************************Public*Routine******************************\
  841. * BOOL MRPOLYLINE::bPlay(hdc, pht, cht)
  842. *
  843. * Play the metafile record.
  844. *
  845. * History:
  846. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  847. * Wrote it.
  848. \**************************************************************************/
  849. BOOL MRPOLYLINE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  850. {
  851. PUTS("MRPOLYLINE::bPlay\n");
  852. ASSERTGDI(iType == EMR_POLYLINE, "Bad record type");
  853. USE(pht);
  854. USE(cht);
  855. if (!bCheckRecord(pht))
  856. return(FALSE);
  857. return(Polyline(hdc, (LPPOINT) aptl, (int) cptl));
  858. }
  859. /******************************Public*Routine******************************\
  860. * BOOL MRGRADIENTFILL::bPlay(hdc, pht, cht)
  861. *
  862. * Play the metafile record.
  863. *
  864. * History:
  865. *
  866. * 12/3/1996 Mark Enstrom [marke]
  867. *
  868. \**************************************************************************/
  869. BOOL MRGRADIENTFILL::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  870. {
  871. PUTS("MRGRADIENTFILL::bPlay\n");
  872. ASSERTGDI(iType == EMR_GRADIENTFILL, "Bad record type");
  873. USE(pht);
  874. USE(cht);
  875. if (!bCheckRecord(pht))
  876. return(FALSE);
  877. return(GdiGradientFill(hdc,&Ver[0],nVer,(PUSHORT)(&Ver[nVer]),nTri,ulMode));
  878. }
  879. /******************************Public*Routine******************************\
  880. * BOOL MRPOLYBEZIERTO::bPlay(hdc, pht, cht)
  881. *
  882. * Play the metafile record.
  883. *
  884. * History:
  885. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  886. * Wrote it.
  887. \**************************************************************************/
  888. BOOL MRPOLYBEZIERTO::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  889. {
  890. PUTS("MRPOLYBEZIERTO::bPlay\n");
  891. ASSERTGDI(iType == EMR_POLYBEZIERTO, "Bad record type");
  892. USE(pht);
  893. USE(cht);
  894. if (!bCheckRecord(pht))
  895. return(FALSE);
  896. return(PolyBezierTo(hdc, (LPPOINT) aptl, cptl));
  897. }
  898. /******************************Public*Routine******************************\
  899. * BOOL MRPOLYLINETO::bPlay(hdc, pht, cht)
  900. *
  901. * Play the metafile record.
  902. *
  903. * History:
  904. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  905. * Wrote it.
  906. \**************************************************************************/
  907. BOOL MRPOLYLINETO::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  908. {
  909. PUTS("MRPOLYLINETO::bPlay\n");
  910. ASSERTGDI(iType == EMR_POLYLINETO, "Bad record type");
  911. USE(pht);
  912. USE(cht);
  913. if (!bCheckRecord(pht))
  914. return(FALSE);
  915. return(PolylineTo(hdc, (LPPOINT) aptl, cptl));
  916. }
  917. /******************************Public*Routine******************************\
  918. * BOOL MRBP16::bPlay(hdc, pht, cht)
  919. *
  920. * Play the 16-bit metafile records PolyBezier, Polygon, Polyline, PolyBezierTo
  921. * and PolylineTo.
  922. *
  923. * History:
  924. * Sat Mar 07 15:06:16 1992 -by- Hock San Lee [hockl]
  925. * Wrote it.
  926. \**************************************************************************/
  927. BOOL MRBP16::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  928. {
  929. BOOL bRet = FALSE;
  930. POINTL aptl[MAX_STACK_POINTL];
  931. PPOINTL pptl;
  932. PUTS("MRBP16::bPlay\n");
  933. USE(pht);
  934. USE(cht);
  935. if (!bCheckRecord(pht))
  936. return(bRet);
  937. if (cpts <= MAX_STACK_POINTL)
  938. pptl = aptl;
  939. else if (!(pptl = (PPOINTL) LocalAlloc(LMEM_FIXED, (UINT) cpts * sizeof(POINTL))))
  940. return(bRet);
  941. POINTS_TO_POINTL(pptl, apts, cpts);
  942. switch (iType)
  943. {
  944. case EMR_POLYBEZIER16:
  945. bRet = PolyBezier(hdc, (LPPOINT) pptl, cpts);
  946. break;
  947. case EMR_POLYGON16:
  948. bRet = Polygon(hdc, (LPPOINT) pptl, (int) cpts);
  949. break;
  950. case EMR_POLYLINE16:
  951. bRet = Polyline(hdc, (LPPOINT) pptl, (int) cpts);
  952. break;
  953. case EMR_POLYBEZIERTO16:
  954. bRet = PolyBezierTo(hdc, (LPPOINT) pptl, cpts);
  955. break;
  956. case EMR_POLYLINETO16:
  957. bRet = PolylineTo(hdc, (LPPOINT) pptl, cpts);
  958. break;
  959. default:
  960. ASSERTGDI(FALSE, "Bad record type");
  961. break;
  962. }
  963. if (cpts > MAX_STACK_POINTL)
  964. {
  965. if (LocalFree(pptl))
  966. {
  967. ASSERTGDI(FALSE, "MRBP16::bPlay: LocalFree failed");
  968. }
  969. }
  970. return(bRet);
  971. }
  972. /******************************Public*Routine******************************\
  973. * BOOL MRPOLYPOLYLINE::bPlay(hdc, pht, cht)
  974. *
  975. * Play the metafile record.
  976. *
  977. * History:
  978. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  979. * Wrote it.
  980. \**************************************************************************/
  981. BOOL MRPOLYPOLYLINE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  982. {
  983. PUTS("MRPOLYPOLYLINE::bPlay\n");
  984. ASSERTGDI(iType == EMR_POLYPOLYLINE, "Bad record type");
  985. USE(pht);
  986. USE(cht);
  987. if(!bCheckRecord(pht))
  988. return(FALSE);
  989. return(PolyPolyline(hdc, (LPPOINT) &ac[cPoly], ac, cPoly));
  990. }
  991. /******************************Public*Routine******************************\
  992. * BOOL MRPOLYPOLYGON::bPlay(hdc, pht, cht)
  993. *
  994. * Play the metafile record.
  995. *
  996. * History:
  997. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  998. * Wrote it.
  999. \**************************************************************************/
  1000. BOOL MRPOLYPOLYGON::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1001. {
  1002. PUTS("MRPOLYPOLYGON::bPlay\n");
  1003. ASSERTGDI(iType == EMR_POLYPOLYGON, "Bad record type");
  1004. USE(pht);
  1005. USE(cht);
  1006. if(!bCheckRecord(pht))
  1007. return(FALSE);
  1008. return(PolyPolygon(hdc, (LPPOINT) &ac[cPoly], (LPINT) ac, (int) cPoly));
  1009. }
  1010. /******************************Public*Routine******************************\
  1011. * BOOL MRBPP16::bPlay(hdc, pht, cht)
  1012. *
  1013. * Play the 16-bit metafile records PolyPolyline, PolyPolygon.
  1014. *
  1015. * History:
  1016. * Sat Mar 07 15:06:16 1992 -by- Hock San Lee [hockl]
  1017. * Wrote it.
  1018. \**************************************************************************/
  1019. BOOL MRBPP16::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1020. {
  1021. BOOL bRet = FALSE;
  1022. PPOINTL pptl;
  1023. POINTL aptl[MAX_STACK_POINTL];
  1024. PUTS("MRBPP16::bPlay\n");
  1025. USE(pht);
  1026. USE(cht);
  1027. if(!bCheckRecord(pht))
  1028. return(FALSE);
  1029. if (cpts <= MAX_STACK_POINTL)
  1030. pptl = aptl;
  1031. else if (!(pptl = (PPOINTL) LocalAlloc(LMEM_FIXED, (UINT) cpts * sizeof(POINTL))))
  1032. return(bRet);
  1033. POINTS_TO_POINTL(pptl, (PPOINTS) &ac[cPoly], cpts);
  1034. switch (iType)
  1035. {
  1036. case EMR_POLYPOLYLINE16:
  1037. bRet = PolyPolyline(hdc, (LPPOINT) pptl, ac, cPoly);
  1038. break;
  1039. case EMR_POLYPOLYGON16:
  1040. bRet = PolyPolygon(hdc, (LPPOINT) pptl, (LPINT) ac, (int) cPoly);
  1041. break;
  1042. default:
  1043. ASSERTGDI(FALSE, "Bad record type");
  1044. break;
  1045. }
  1046. if (cpts > MAX_STACK_POINTL)
  1047. {
  1048. if (LocalFree(pptl))
  1049. {
  1050. ASSERTGDI(FALSE, "MRBPP16::bPlay: LocalFree failed");
  1051. }
  1052. }
  1053. return(bRet);
  1054. }
  1055. /******************************Public*Routine******************************\
  1056. * BOOL MRPOLYDRAW::bPlay(hdc, pht, cht)
  1057. *
  1058. * Play the metafile record.
  1059. *
  1060. * History:
  1061. * Thu Oct 17 14:06:04 1991 -by- Hock San Lee [hockl]
  1062. * Wrote it.
  1063. \**************************************************************************/
  1064. BOOL MRPOLYDRAW::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1065. {
  1066. PUTS("MRPOLYDRAW::bPlay\n");
  1067. ASSERTGDI(iType == EMR_POLYDRAW, "Bad record type");
  1068. USE(pht);
  1069. USE(cht);
  1070. if(!bCheckRecord(pht))
  1071. return(FALSE);
  1072. return(PolyDraw(hdc, (LPPOINT) aptl, (LPBYTE) &aptl[cptl], (int) cptl));
  1073. }
  1074. /******************************Public*Routine******************************\
  1075. * BOOL MRPOLYDRAW16::bPlay(hdc, pht, cht)
  1076. *
  1077. * Play the 16-bit metafile record.
  1078. *
  1079. * History:
  1080. * Sat Mar 07 15:06:16 1992 -by- Hock San Lee [hockl]
  1081. * Wrote it.
  1082. \**************************************************************************/
  1083. BOOL MRPOLYDRAW16::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1084. {
  1085. BOOL bRet = FALSE;
  1086. POINTL aptl[MAX_STACK_POINTL];
  1087. PPOINTL pptl;
  1088. PUTS("MRPOLYDRAW16::bPlay\n");
  1089. ASSERTGDI(iType == EMR_POLYDRAW16, "Bad record type");
  1090. USE(pht);
  1091. USE(cht);
  1092. if (!bCheckRecord(pht))
  1093. return(FALSE);
  1094. if (cpts <= MAX_STACK_POINTL)
  1095. pptl = aptl;
  1096. else if (!(pptl = (PPOINTL) LocalAlloc(LMEM_FIXED, (UINT) cpts * sizeof(POINTL))))
  1097. return(bRet);
  1098. POINTS_TO_POINTL(pptl, apts, cpts);
  1099. bRet = PolyDraw(hdc, (LPPOINT) pptl, (LPBYTE) &apts[cpts], (int) cpts);
  1100. if (cpts > MAX_STACK_POINTL)
  1101. {
  1102. if (LocalFree(pptl))
  1103. {
  1104. ASSERTGDI(FALSE, "MRPOLYDRAW16::bPlay: LocalFree failed");
  1105. }
  1106. }
  1107. return(bRet);
  1108. }
  1109. /******************************Public*Routine******************************\
  1110. * BOOL MRSETWINDOWEXTEX::bPlay(hdc, pht, cht)
  1111. *
  1112. * Play the metafile record.
  1113. *
  1114. * History:
  1115. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1116. * Wrote it.
  1117. \**************************************************************************/
  1118. BOOL MRSETWINDOWEXTEX::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1119. {
  1120. PMF pmf;
  1121. PUTS("MRSETWINDOWEXTEX::bPlay\n");
  1122. ASSERTGDI(iType == EMR_SETWINDOWEXTEX, "Bad record type");
  1123. USE(cht);
  1124. // Get metafile.
  1125. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  1126. return(FALSE);
  1127. if (!bCheckRecord(pht))
  1128. return(FALSE);
  1129. // Cannot change extent in fixed scale mapping mode.
  1130. if (GetMapMode(pmf->hdcXform) <= MM_MAX_FIXEDSCALE)
  1131. return(TRUE);
  1132. // Play it to the virtual DC.
  1133. if (!SetWindowExtEx(pmf->hdcXform, (int) d1, (int) d2, (LPSIZE) NULL))
  1134. return(FALSE);
  1135. // Set up new transform in the target DC.
  1136. return(pmf->bSetTransform(hdc));
  1137. }
  1138. /******************************Public*Routine******************************\
  1139. * BOOL MRSETWINDOWORGEX::bPlay(hdc, pht, cht)
  1140. *
  1141. * Play the metafile record.
  1142. *
  1143. * History:
  1144. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1145. * Wrote it.
  1146. \**************************************************************************/
  1147. BOOL MRSETWINDOWORGEX::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1148. {
  1149. PMF pmf;
  1150. PUTS("MRSETWINDOWORGEX::bPlay\n");
  1151. ASSERTGDI(iType == EMR_SETWINDOWORGEX, "Bad record type");
  1152. USE(cht);
  1153. // Get metafile.
  1154. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  1155. return(FALSE);
  1156. if (!bCheckRecord(pht))
  1157. return(FALSE);
  1158. // Play it to the virtual DC.
  1159. if (!SetWindowOrgEx(pmf->hdcXform, (int) d1, (int) d2, (LPPOINT) NULL))
  1160. return(FALSE);
  1161. // Set up new transform in the target DC.
  1162. return(pmf->bSetTransform(hdc));
  1163. }
  1164. /******************************Public*Routine******************************\
  1165. * BOOL MRSETVIEWPORTEXTEX::bPlay(hdc, pht, cht)
  1166. *
  1167. * Play the metafile record.
  1168. *
  1169. * History:
  1170. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1171. * Wrote it.
  1172. \**************************************************************************/
  1173. BOOL MRSETVIEWPORTEXTEX::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1174. {
  1175. PMF pmf;
  1176. PUTS("MRSETVIEWPORTEXTEX::bPlay\n");
  1177. ASSERTGDI(iType == EMR_SETVIEWPORTEXTEX, "Bad record type");
  1178. USE(cht);
  1179. // Get metafile.
  1180. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  1181. return(FALSE);
  1182. if (!bCheckRecord(pht))
  1183. return(FALSE);
  1184. // Cannot change extent in fixed scale mapping mode.
  1185. if (GetMapMode(pmf->hdcXform) <= MM_MAX_FIXEDSCALE)
  1186. return(TRUE);
  1187. // Play it to the virtual DC.
  1188. if (!SetViewportExtEx(pmf->hdcXform, (int) d1, (int) d2, (LPSIZE) NULL))
  1189. return(FALSE);
  1190. // Set up new transform in the target DC.
  1191. return(pmf->bSetTransform(hdc));
  1192. }
  1193. /******************************Public*Routine******************************\
  1194. * BOOL MRSETVIEWPORTORGEX::bPlay(hdc, pht, cht)
  1195. *
  1196. * Play the metafile record.
  1197. *
  1198. * History:
  1199. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1200. * Wrote it.
  1201. \**************************************************************************/
  1202. BOOL MRSETVIEWPORTORGEX::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1203. {
  1204. PMF pmf;
  1205. PUTS("MRSETVIEWPORTORGEX::bPlay\n");
  1206. ASSERTGDI(iType == EMR_SETVIEWPORTORGEX, "Bad record type");
  1207. USE(cht);
  1208. // Get metafile.
  1209. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  1210. return(FALSE);
  1211. if (!bCheckRecord(pht))
  1212. return(FALSE);
  1213. // Play it to the virtual DC.
  1214. if (!SetViewportOrgEx(pmf->hdcXform, (int) d1, (int) d2, (LPPOINT) NULL))
  1215. return(FALSE);
  1216. // Set up new transform in the target DC.
  1217. return(pmf->bSetTransform(hdc));
  1218. }
  1219. /******************************Public*Routine******************************\
  1220. * BOOL MRSETBRUSHORGEX::bPlay(hdc, pht, cht)
  1221. *
  1222. * Play the metafile record.
  1223. *
  1224. * History:
  1225. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1226. * Wrote it.
  1227. \**************************************************************************/
  1228. BOOL MRSETBRUSHORGEX::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1229. {
  1230. PMF pmf;
  1231. PUTS("MRSETBRUSHORGEX::bPlay\n");
  1232. ASSERTGDI(iType == EMR_SETBRUSHORGEX, "Bad record type");
  1233. USE(cht);
  1234. // Get metafile.
  1235. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  1236. return(FALSE);
  1237. if (!bCheckRecord(pht))
  1238. return(FALSE);
  1239. // Since we do not scale brush patterns, we set the brush origin is in
  1240. // the original device units.
  1241. return(SetBrushOrgEx(hdc, (int) d1, (int) d2, (LPPOINT) NULL));
  1242. }
  1243. /******************************Public*Routine******************************\
  1244. * BOOL MREOF::bPlay(hdc, pht, cht)
  1245. *
  1246. * Play the metafile record.
  1247. *
  1248. * History:
  1249. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1250. * Wrote it.
  1251. \**************************************************************************/
  1252. BOOL MREOF::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1253. {
  1254. PUTS("MREOF::bPlay\n");
  1255. ASSERTGDI(iType == EMR_EOF, "Bad record type");
  1256. USE(cht);
  1257. // If we emitted the begin group public comment earlier, emit the corresponding
  1258. // end group comment now.
  1259. // If we are embedding the metafile, emit the public end group comment.
  1260. if (IS_ALTDC_TYPE(hdc))
  1261. {
  1262. PLDC pldc;
  1263. DC_PLDC(hdc,pldc,FALSE);
  1264. if (pldc->iType == LO_METADC)
  1265. {
  1266. PMF pmf;
  1267. // Get metafile.
  1268. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  1269. return(FALSE);
  1270. if (!bCheckRecord(pht))
  1271. return(FALSE);
  1272. if (pmf->bBeginGroup)
  1273. {
  1274. pmf->bBeginGroup = FALSE;
  1275. return(MF_GdiCommentEndGroupEMF(hdc));
  1276. }
  1277. }
  1278. }
  1279. return(TRUE);
  1280. }
  1281. /******************************Public*Routine******************************\
  1282. * BOOL MRGDICOMMENT::bPlay(hdc, pht, cht)
  1283. *
  1284. * Play the metafile record.
  1285. *
  1286. * History:
  1287. * Wed Apr 28 10:43:12 1993 -by- Hock San Lee [hockl]
  1288. * Wrote it.
  1289. \**************************************************************************/
  1290. BOOL MRGDICOMMENT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1291. {
  1292. PUTS("MRGDICOMMENT::bPlay\n");
  1293. ASSERTGDI(iType == EMR_GDICOMMENT, "Bad record type");
  1294. USE(pht);
  1295. USE(cht);
  1296. if (!bCheckRecord(pht))
  1297. return(FALSE);
  1298. // Handle private comments first.
  1299. if (!bIsPublicComment())
  1300. return(GdiComment(hdc, (UINT) cb, abComment));
  1301. // Handle public comments.
  1302. switch (((PEMRGDICOMMENT_PUBLIC) this)->iComment)
  1303. {
  1304. case GDICOMMENT_UNICODE_STRING:
  1305. case GDICOMMENT_UNICODE_END:
  1306. return (TRUE);
  1307. case GDICOMMENT_WINDOWS_METAFILE:
  1308. case GDICOMMENT_BEGINGROUP:
  1309. case GDICOMMENT_ENDGROUP:
  1310. default:
  1311. return(GdiComment(hdc, (UINT) cb, abComment));
  1312. case GDICOMMENT_MULTIFORMATS:
  1313. {
  1314. HENHMETAFILE hemf;
  1315. BOOL bRet;
  1316. int nEscape;
  1317. PEMRGDICOMMENT_MULTIFORMATS pemrcmf;
  1318. // Do embedding.
  1319. if (IS_ALTDC_TYPE(hdc))
  1320. {
  1321. PLDC pldc;
  1322. DC_PLDC(hdc,pldc,FALSE);
  1323. if (pldc->iType == LO_METADC)
  1324. return(GdiComment(hdc, (UINT) cb, abComment));
  1325. }
  1326. // Playback the first recognizable format.
  1327. pemrcmf = (PEMRGDICOMMENT_MULTIFORMATS) this;
  1328. for (DWORD i = 0; i < pemrcmf->nFormats; i++)
  1329. {
  1330. switch (pemrcmf->aemrformat[i].dSignature)
  1331. {
  1332. case ENHMETA_SIGNATURE:
  1333. if (pemrcmf->aemrformat[i].nVersion <= META_FORMAT_ENHANCED)
  1334. {
  1335. hemf = SetEnhMetaFileBits(
  1336. (UINT) pemrcmf->aemrformat[i].cbData,
  1337. &abComment[pemrcmf->aemrformat[i].offData]);
  1338. bRet = PlayEnhMetaFile(hdc, hemf,
  1339. (LPRECT) &pemrcmf->rclOutput);
  1340. DeleteEnhMetaFile(hemf);
  1341. return(bRet);
  1342. }
  1343. break;
  1344. case EPS_SIGNATURE:
  1345. nEscape = ENCAPSULATED_POSTSCRIPT;
  1346. if (DrawEscape(hdc, QUERYESCSUPPORT,
  1347. sizeof(nEscape), (LPCSTR) &nEscape) > 0)
  1348. {
  1349. int iRet;
  1350. DWORD cbEpsData;
  1351. PEPSDATA pEpsData;
  1352. POINT aptl3[3];
  1353. cbEpsData = sizeof(EPSDATA)
  1354. + pemrcmf->aemrformat[i].cbData;
  1355. pEpsData = (PEPSDATA) LocalAlloc(LMEM_FIXED,
  1356. (UINT) cbEpsData);
  1357. if (!pEpsData)
  1358. break; // try the next format
  1359. aptl3[0].x = pemrcmf->rclOutput.left;
  1360. aptl3[0].y = pemrcmf->rclOutput.top;
  1361. aptl3[1].x = pemrcmf->rclOutput.right;
  1362. aptl3[1].y = pemrcmf->rclOutput.top;
  1363. aptl3[2].x = pemrcmf->rclOutput.left;
  1364. aptl3[2].y = pemrcmf->rclOutput.bottom;
  1365. if (!NtGdiTransformPoints(hdc,aptl3,pEpsData->aptl,3,XFP_LPTODPFX))
  1366. {
  1367. LocalFree((HLOCAL) pEpsData);
  1368. return(FALSE);
  1369. }
  1370. pEpsData->cbData = cbEpsData;
  1371. pEpsData->nVersion = pemrcmf->aemrformat[i].nVersion;
  1372. RtlCopyMemory
  1373. (
  1374. (PBYTE) &pEpsData[1],
  1375. &abComment[pemrcmf->aemrformat[i].offData],
  1376. pemrcmf->aemrformat[i].cbData
  1377. );
  1378. iRet = DrawEscape(hdc, nEscape, (int) cbEpsData,
  1379. (LPCSTR) pEpsData);
  1380. if (LocalFree((HLOCAL) pEpsData))
  1381. {
  1382. ASSERTGDI(FALSE, "LocalFree failed");
  1383. }
  1384. // DrawEscape returns ERROR_NOT_SUPPORTED if it cannot
  1385. // draw this EPS data. For example, the EPS data
  1386. // may be level 2 but the driver supports only level 1.
  1387. if (iRet <= 0 && GetLastError() == ERROR_NOT_SUPPORTED)
  1388. break; // try the next format
  1389. return(iRet > 0);
  1390. }
  1391. break;
  1392. }
  1393. }
  1394. VERIFYGDI(FALSE, "MRGDICOMMENT::bPlay: No recognized format in GDICOMMENT_MULTIFORMATS public comments\n");
  1395. return(FALSE); // no format found!
  1396. }
  1397. break;
  1398. } // switch (((PEMRGDICOMMENT_PUBLIC) this)->iComment)
  1399. // Should not get here!
  1400. ASSERTGDI(FALSE, "MRGDICOMMENT::bPlay: unexpected error");
  1401. return(TRUE);
  1402. }
  1403. /******************************Public*Routine******************************\
  1404. * BOOL MRSETPIXELV::bPlay(hdc, pht, cht)
  1405. *
  1406. * Play the metafile record.
  1407. *
  1408. * History:
  1409. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1410. * Wrote it.
  1411. \**************************************************************************/
  1412. BOOL MRSETPIXELV::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1413. {
  1414. PUTS("MRSETPIXELV::bPlay\n");
  1415. ASSERTGDI(iType == EMR_SETPIXELV, "Bad record type");
  1416. USE(pht);
  1417. USE(cht);
  1418. if (!bCheckRecord(pht))
  1419. return(FALSE);
  1420. return(SetPixelV(hdc, (int) eptl.x, (int) eptl.y, crColor));
  1421. }
  1422. /******************************Public*Routine******************************\
  1423. * BOOL MRSETMAPPERFLAGS::bPlay(hdc, pht, cht)
  1424. *
  1425. * Play the metafile record.
  1426. *
  1427. * History:
  1428. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1429. * Wrote it.
  1430. \**************************************************************************/
  1431. BOOL MRSETMAPPERFLAGS::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1432. {
  1433. PUTS("MRSETMAPPERFLAGS::bPlay\n");
  1434. ASSERTGDI(iType == EMR_SETMAPPERFLAGS, "Bad record type");
  1435. USE(pht);
  1436. USE(cht);
  1437. if (!bCheckRecord(pht))
  1438. return(FALSE);
  1439. return(SetMapperFlags(hdc, d1) != GDI_ERROR);
  1440. }
  1441. /******************************Public*Routine******************************\
  1442. * BOOL MRSETMAPMODE::bPlay(hdc, pht, cht)
  1443. *
  1444. * Play the metafile record.
  1445. *
  1446. * History:
  1447. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1448. * Wrote it.
  1449. \**************************************************************************/
  1450. BOOL MRSETMAPMODE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1451. {
  1452. PMF pmf;
  1453. int iMapModeOld;
  1454. PUTS("MRSETMAPMODE::bPlay\n");
  1455. ASSERTGDI(iType == EMR_SETMAPMODE, "Bad record type");
  1456. USE(cht);
  1457. // Get metafile.
  1458. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  1459. return(FALSE);
  1460. if (!bCheckRecord(pht))
  1461. return(FALSE);
  1462. // Play it to the virtual DC.
  1463. if (!(iMapModeOld = SetMapMode(pmf->hdcXform, (int) d1)))
  1464. return(FALSE);
  1465. // No need to recompute transform if there is no change in mapping mode
  1466. // AND it is not MM_ISOTROPIC.
  1467. if (iMapModeOld == (int) d1 && iMapModeOld != MM_ISOTROPIC)
  1468. return(TRUE);
  1469. // Set up new transform in the target DC.
  1470. return(pmf->bSetTransform(hdc));
  1471. }
  1472. /******************************Public*Routine******************************\
  1473. * BOOL MRSETLAYOUT::bPlay(hdc, pht, cht)
  1474. *
  1475. * Play the metafile record.
  1476. *
  1477. * History:
  1478. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1479. * Wrote it.
  1480. \**************************************************************************/
  1481. BOOL MRSETLAYOUT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1482. {
  1483. PMF pmf;
  1484. DWORD dwOrientationOld;
  1485. PUTS("MRSETLAYOUT::bPlay\n");
  1486. ASSERTGDI(iType == EMR_SETLAYOUT, "Bad record type");
  1487. USE(cht);
  1488. // Get metafile.
  1489. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  1490. return(FALSE);
  1491. if (!bCheckRecord(pht))
  1492. return(FALSE);
  1493. // Play it to the virtual DC.
  1494. if ((dwOrientationOld = SetLayout(pmf->hdcXform, (DWORD) d1)) == GDI_ERROR)
  1495. return(FALSE);
  1496. // Set up new transform in the target DC.
  1497. return(pmf->bSetTransform(hdc));
  1498. }
  1499. /******************************Public*Routine******************************\
  1500. * BOOL MRSETBKMODE::bPlay(hdc, pht, cht)
  1501. *
  1502. * Play the metafile record.
  1503. *
  1504. * History:
  1505. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1506. * Wrote it.
  1507. \**************************************************************************/
  1508. BOOL MRSETBKMODE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1509. {
  1510. PUTS("MRSETBKMODE::bPlay\n");
  1511. ASSERTGDI(iType == EMR_SETBKMODE, "Bad record type");
  1512. USE(pht);
  1513. USE(cht);
  1514. if (!bCheckRecord(pht))
  1515. return(FALSE);
  1516. return(SetBkMode(hdc, (int) d1) != 0);
  1517. }
  1518. /******************************Public*Routine******************************\
  1519. * BOOL MRSETPOLYFILLMODE::bPlay(hdc, pht, cht)
  1520. *
  1521. * Play the metafile record.
  1522. *
  1523. * History:
  1524. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1525. * Wrote it.
  1526. \**************************************************************************/
  1527. BOOL MRSETPOLYFILLMODE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1528. {
  1529. PUTS("MRSETPOLYFILLMODE::bPlay\n");
  1530. ASSERTGDI(iType == EMR_SETPOLYFILLMODE, "Bad record type");
  1531. USE(pht);
  1532. USE(cht);
  1533. if (!bCheckRecord(pht))
  1534. return(FALSE);
  1535. return(SetPolyFillMode(hdc, (int) d1) != 0);
  1536. }
  1537. /******************************Public*Routine******************************\
  1538. * BOOL MRSETROP2::bPlay(hdc, pht, cht)
  1539. *
  1540. * Play the metafile record.
  1541. *
  1542. * History:
  1543. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1544. * Wrote it.
  1545. \**************************************************************************/
  1546. BOOL MRSETROP2::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1547. {
  1548. PUTS("MRSETROP2::bPlay\n");
  1549. ASSERTGDI(iType == EMR_SETROP2, "Bad record type");
  1550. USE(pht);
  1551. USE(cht);
  1552. if (!bCheckRecord(pht))
  1553. return(FALSE);
  1554. return(SetROP2(hdc, (int) d1) != 0);
  1555. }
  1556. /******************************Public*Routine******************************\
  1557. * BOOL MRSETSTRETCHBLTMODE::bPlay(hdc, pht, cht)
  1558. *
  1559. * Play the metafile record.
  1560. *
  1561. * History:
  1562. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1563. * Wrote it.
  1564. \**************************************************************************/
  1565. BOOL MRSETSTRETCHBLTMODE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1566. {
  1567. PUTS("MRSETSTRETCHBLTMODE::bPlay\n");
  1568. ASSERTGDI(iType == EMR_SETSTRETCHBLTMODE, "Bad record type");
  1569. USE(pht);
  1570. USE(cht);
  1571. if (!bCheckRecord(pht))
  1572. return(FALSE);
  1573. return(SetStretchBltMode(hdc, (int) d1) != 0);
  1574. }
  1575. /******************************Public*Routine******************************\
  1576. * BOOL MRSETTEXTALIGN::bPlay(hdc, pht, cht)
  1577. *
  1578. * Play the metafile record.
  1579. *
  1580. * History:
  1581. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1582. * Wrote it.
  1583. \**************************************************************************/
  1584. BOOL MRSETTEXTALIGN::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1585. {
  1586. PUTS("MRSETTEXTALIGN::bPlay\n");
  1587. ASSERTGDI(iType == EMR_SETTEXTALIGN, "Bad record type");
  1588. USE(pht);
  1589. USE(cht);
  1590. if (!bCheckRecord(pht))
  1591. return(FALSE);
  1592. return(SetTextAlign(hdc, (UINT) d1) != GDI_ERROR);
  1593. }
  1594. /******************************Public*Routine******************************\
  1595. * BOOL MRSETTEXTCOLOR::bPlay(hdc, pht, cht)
  1596. *
  1597. * Play the metafile record.
  1598. *
  1599. * History:
  1600. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1601. * Wrote it.
  1602. \**************************************************************************/
  1603. BOOL MRSETTEXTCOLOR::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1604. {
  1605. PUTS("MRSETTEXTCOLOR::bPlay\n");
  1606. ASSERTGDI(iType == EMR_SETTEXTCOLOR, "Bad record type");
  1607. USE(pht);
  1608. USE(cht);
  1609. if (!bCheckRecord(pht))
  1610. return(FALSE);
  1611. return(SetTextColor(hdc, (COLORREF) d1) != CLR_INVALID);
  1612. }
  1613. /******************************Public*Routine******************************\
  1614. * BOOL MRSETBKCOLOR::bPlay(hdc, pht, cht)
  1615. *
  1616. * Play the metafile record.
  1617. *
  1618. * History:
  1619. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1620. * Wrote it.
  1621. \**************************************************************************/
  1622. BOOL MRSETBKCOLOR::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1623. {
  1624. PUTS("MRSETBKCOLOR::bPlay\n");
  1625. ASSERTGDI(iType == EMR_SETBKCOLOR, "Bad record type");
  1626. USE(pht);
  1627. USE(cht);
  1628. if (!bCheckRecord(pht))
  1629. return(FALSE);
  1630. return(SetBkColor(hdc, (COLORREF) d1) != CLR_INVALID);
  1631. }
  1632. /******************************Public*Routine******************************\
  1633. * BOOL MRSETICMMODE::bPlay(hdc, pht, cht)
  1634. *
  1635. * Play the metafile record.
  1636. *
  1637. * History:
  1638. *
  1639. * 9/19/1996 Mark Enstrom [marke]
  1640. *
  1641. \**************************************************************************/
  1642. BOOL MRSETICMMODE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1643. {
  1644. PUTS("MRSETICMMODE::bPlay\n");
  1645. ASSERTGDI(iType == EMR_SETICMMODE, "Bad record type");
  1646. USE(pht);
  1647. USE(cht);
  1648. if (!bCheckRecord(pht))
  1649. return(FALSE);
  1650. return((SetICMMode(hdc, (int) d1) != 0));
  1651. }
  1652. /******************************Public*Routine******************************\
  1653. * BOOL MRSETCOLORSPACE::bPlay(hdc, pht, cht)
  1654. *
  1655. * Play the metafile record.
  1656. *
  1657. * History:
  1658. *
  1659. * 9/19/1996 Mark Enstrom [marke]
  1660. *
  1661. \**************************************************************************/
  1662. BOOL MRSETCOLORSPACE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1663. {
  1664. HCOLORSPACE hColorSpace;
  1665. PUTS("MRSETCOLORSPACE::bPlay\n");
  1666. ASSERTGDI(iType == EMR_SETCOLORSPACE, "Bad record type");
  1667. USE(cht);
  1668. if (!bCheckRecord(pht))
  1669. return(FALSE);
  1670. if(STOCK_IMHE(d1))
  1671. {
  1672. hColorSpace = (HCOLORSPACE) GetStockObject(d1 & ~ENHMETA_STOCK_OBJECT);
  1673. }
  1674. else
  1675. {
  1676. hColorSpace = (HCOLORSPACE) pht->objectHandle[d1];
  1677. }
  1678. return((SetColorSpace(hdc, hColorSpace) != 0));
  1679. }
  1680. /******************************Public*Routine******************************\
  1681. * BOOL MRCREATECOLORSPACE::bPlay(hdc, pht, cht)
  1682. *
  1683. * Play the metafile record (Windows 98 compatible record)
  1684. *
  1685. * History:
  1686. *
  1687. * 7/15/1998 Hideyuki Nagase [hideyukn]
  1688. *
  1689. \**************************************************************************/
  1690. BOOL MRCREATECOLORSPACE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1691. {
  1692. PUTS("MRCREATECOLORSPACE::bPlay\n");
  1693. ASSERTGDI(iType == EMR_CREATECOLORSPACE, "Bad record type");
  1694. USE(hdc);
  1695. if (!bCheckRecord(pht))
  1696. return(FALSE);
  1697. // Make sure the handle is in the table.
  1698. if (!VALID_IMHE(imhe, cht))
  1699. return(FALSE);
  1700. pht->objectHandle[imhe] = CreateColorSpaceA(&lcsp);
  1701. return(pht->objectHandle[imhe] != 0);
  1702. }
  1703. /******************************Public*Routine******************************\
  1704. * BOOL MRDELETECOLORSPACE::bPlay(hdc, pht, cht)
  1705. *
  1706. * Play the metafile record - stub for deletecolorspace
  1707. *
  1708. * History:
  1709. *
  1710. * 9/19/1996 Mark Enstrom [marke]
  1711. *
  1712. \**************************************************************************/
  1713. BOOL MRDELETECOLORSPACE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1714. {
  1715. PUTS("MRDELETECOLORSPACE::bPlay\n");
  1716. ASSERTGDI(iType == EMR_DELETECOLORSPACE, "Bad record type");
  1717. USE(hdc);
  1718. USE(pht);
  1719. USE(cht);
  1720. return(TRUE);
  1721. }
  1722. /******************************Public*Routine******************************\
  1723. * BOOL MRSETARCDIRECTION::bPlay(hdc, pht, cht)
  1724. *
  1725. * Play the metafile record.
  1726. *
  1727. * History:
  1728. * Thu Oct 17 16:46:33 1991 -by- Hock San Lee [hockl]
  1729. * Wrote it.
  1730. \**************************************************************************/
  1731. BOOL MRSETARCDIRECTION::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1732. {
  1733. PUTS("MRSETARCDIRECTION::bPlay\n");
  1734. ASSERTGDI(iType == EMR_SETARCDIRECTION, "Bad record type");
  1735. USE(pht);
  1736. USE(cht);
  1737. // Arc direction is recorded in the advanced graphics mode. Make sure we have
  1738. // set the advanced graphics mode.
  1739. ASSERTGDI
  1740. (
  1741. GetGraphicsMode(hdc) == GM_ADVANCED,
  1742. "MR::bPlay: Not in advanced graphics mode"
  1743. );
  1744. if (!bCheckRecord(pht))
  1745. return(FALSE);
  1746. return(SetArcDirection(hdc, (int) d1) != 0);
  1747. }
  1748. /******************************Public*Routine******************************\
  1749. * BOOL MRSETMITERLIMIT::bPlay(hdc, pht, cht)
  1750. *
  1751. * Play the metafile record.
  1752. *
  1753. * History:
  1754. * Thu Oct 17 16:46:33 1991 -by- Hock San Lee [hockl]
  1755. * Wrote it.
  1756. \**************************************************************************/
  1757. BOOL MRSETMITERLIMIT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1758. {
  1759. PUTS("MRSETMITERLIMIT::bPlay\n");
  1760. ASSERTGDI(iType == EMR_SETMITERLIMIT, "Bad record type");
  1761. USE(pht);
  1762. USE(cht);
  1763. if (!bCheckRecord(pht))
  1764. return(FALSE);
  1765. return(SetMiterLimit(hdc, (FLOAT) d1, (PFLOAT) NULL) != GDI_ERROR);
  1766. }
  1767. /******************************Public*Routine******************************\
  1768. * BOOL MRMOVETOEX::bPlay(hdc, pht, cht)
  1769. *
  1770. * Play the metafile record.
  1771. *
  1772. * History:
  1773. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1774. * Wrote it.
  1775. \**************************************************************************/
  1776. BOOL MRMOVETOEX::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1777. {
  1778. PUTS("MRMOVETOEX::bPlay\n");
  1779. ASSERTGDI(iType == EMR_MOVETOEX, "Bad record type");
  1780. USE(pht);
  1781. USE(cht);
  1782. if (!bCheckRecord(pht))
  1783. return(FALSE);
  1784. return(MoveToEx(hdc, (int) d1, (int) d2, (LPPOINT) NULL));
  1785. }
  1786. /******************************Public*Routine******************************\
  1787. * BOOL MRLINETO::bPlay(hdc, pht, cht)
  1788. *
  1789. * Play the metafile record.
  1790. *
  1791. * History:
  1792. * Wed Oct 02 10:30:36 1991 -by- Hock San Lee [hockl]
  1793. * Wrote it.
  1794. \**************************************************************************/
  1795. BOOL MRLINETO::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1796. {
  1797. PUTS("MRLINETO::bPlay\n");
  1798. ASSERTGDI(iType == EMR_LINETO, "Bad record type");
  1799. USE(pht);
  1800. USE(cht);
  1801. if (!bCheckRecord(pht))
  1802. return(FALSE);
  1803. return(LineTo(hdc, (int) d1, (int) d2));
  1804. }
  1805. /******************************Public*Routine******************************\
  1806. * BOOL MREXCLUDECLIPRECT::bPlay(hdc, pht, cht)
  1807. *
  1808. * Play the metafile record.
  1809. *
  1810. * History:
  1811. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1812. * Wrote it.
  1813. \**************************************************************************/
  1814. BOOL MREXCLUDECLIPRECT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1815. {
  1816. PUTS("MREXCLUDECLIPRECT::bPlay\n");
  1817. ASSERTGDI(iType == EMR_EXCLUDECLIPRECT, "Bad record type");
  1818. USE(pht);
  1819. USE(cht);
  1820. if (!bCheckRecord(pht))
  1821. return(FALSE);
  1822. return
  1823. (
  1824. ExcludeClipRect
  1825. (
  1826. hdc,
  1827. (int) d1,
  1828. (int) d2,
  1829. (int) d3,
  1830. (int) d4
  1831. )
  1832. != RGN_ERROR
  1833. );
  1834. }
  1835. /******************************Public*Routine******************************\
  1836. * BOOL MRINTERSECTCLIPRECT::bPlay(hdc, pht, cht)
  1837. *
  1838. * Play the metafile record.
  1839. *
  1840. * History:
  1841. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  1842. * Wrote it.
  1843. \**************************************************************************/
  1844. BOOL MRINTERSECTCLIPRECT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1845. {
  1846. PUTS("MRINTERSECTCLIPRECT::bPlay\n");
  1847. ASSERTGDI(iType == EMR_INTERSECTCLIPRECT, "Bad record type");
  1848. USE(pht);
  1849. USE(cht);
  1850. if (!bCheckRecord(pht))
  1851. return(FALSE);
  1852. return
  1853. (
  1854. IntersectClipRect
  1855. (
  1856. hdc,
  1857. (int) d1,
  1858. (int) d2,
  1859. (int) d3,
  1860. (int) d4
  1861. )
  1862. != RGN_ERROR
  1863. );
  1864. }
  1865. /******************************Public*Routine******************************\
  1866. * BOOL MRINVERTRGN::bPlay(hdc, pht, cht)
  1867. *
  1868. * Play the metafile record.
  1869. *
  1870. * History:
  1871. * Tue Oct 29 13:44:38 1991 -by- Hock San Lee [hockl]
  1872. * Wrote it.
  1873. \**************************************************************************/
  1874. BOOL MRINVERTRGN::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1875. {
  1876. PMF pmf;
  1877. BOOL bRet;
  1878. HRGN hrgn;
  1879. PUTS("MRINVERTRGN::bPlay\n");
  1880. ASSERTGDI(iType == EMR_INVERTRGN, "Bad record type");
  1881. USE(cht);
  1882. // Get metafile.
  1883. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  1884. return(FALSE);
  1885. if (!bCheckRecord(pht))
  1886. return(FALSE);
  1887. // Check bounds.
  1888. if (pmf->bClipped(erclBounds))
  1889. return(TRUE);
  1890. // Create the region.
  1891. if (!(hrgn = ExtCreateRegion((LPXFORM) NULL, cRgnData, (LPRGNDATA) &this[1])))
  1892. return(FALSE);
  1893. bRet = InvertRgn(hdc, hrgn);
  1894. if (!DeleteObject(hrgn))
  1895. {
  1896. ASSERTGDI(FALSE, "DeleteObject failed");
  1897. }
  1898. return(bRet);
  1899. }
  1900. /******************************Public*Routine******************************\
  1901. * BOOL MRPAINTRGN::bPlay(hdc, pht, cht)
  1902. *
  1903. * Play the metafile record.
  1904. *
  1905. * History:
  1906. * Tue Oct 29 13:44:38 1991 -by- Hock San Lee [hockl]
  1907. * Wrote it.
  1908. \**************************************************************************/
  1909. BOOL MRPAINTRGN::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1910. {
  1911. PMF pmf;
  1912. BOOL bRet;
  1913. HRGN hrgn;
  1914. PUTS("MRPAINTRGN::bPlay\n");
  1915. ASSERTGDI(iType == EMR_PAINTRGN, "Bad record type");
  1916. USE(cht);
  1917. // Get metafile.
  1918. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  1919. return(FALSE);
  1920. if (!bCheckRecord(pht))
  1921. return(FALSE);
  1922. // Check bounds.
  1923. if (pmf->bClipped(erclBounds))
  1924. return(TRUE);
  1925. // Create the region.
  1926. if (!(hrgn = ExtCreateRegion((LPXFORM) NULL, cRgnData, (LPRGNDATA) &this[1])))
  1927. return(FALSE);
  1928. bRet = PaintRgn(hdc, hrgn);
  1929. if (!DeleteObject(hrgn))
  1930. {
  1931. ASSERTGDI(FALSE, "DeleteObject failed");
  1932. }
  1933. return(bRet);
  1934. }
  1935. /******************************Public*Routine******************************\
  1936. * BOOL MRFILLRGN::bPlay(hdc, pht, cht)
  1937. *
  1938. * Play the metafile record.
  1939. *
  1940. * History:
  1941. * Tue Oct 29 13:44:38 1991 -by- Hock San Lee [hockl]
  1942. * Wrote it.
  1943. \**************************************************************************/
  1944. BOOL MRFILLRGN::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1945. {
  1946. PMF pmf;
  1947. BOOL bRet;
  1948. HRGN hrgn;
  1949. HBRUSH hbr;
  1950. PUTS("MRFILLRGN::bPlay\n");
  1951. ASSERTGDI(iType == EMR_FILLRGN, "Bad record type");
  1952. // Get metafile.
  1953. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  1954. return(FALSE);
  1955. if (!bCheckRecord(pht))
  1956. return(FALSE);
  1957. // Check bounds.
  1958. if (pmf->bClipped(erclBounds))
  1959. return(TRUE);
  1960. // Get the brush handle.
  1961. if (STOCK_IMHE(imheBrush))
  1962. {
  1963. // Stock brush.
  1964. hbr = (HBRUSH) GetStockObject(imheBrush & ~ENHMETA_STOCK_OBJECT);
  1965. }
  1966. else
  1967. {
  1968. // Make sure the handle is in the table.
  1969. if (!VALID_IMHE(imheBrush, cht))
  1970. return(FALSE);
  1971. // If brush creation failed earlier, hbr is 0 and FillRgn will
  1972. // just return an error.
  1973. hbr = (HBRUSH) pht->objectHandle[imheBrush];
  1974. }
  1975. // Create the region.
  1976. if (!(hrgn = ExtCreateRegion((LPXFORM) NULL, cRgnData, (LPRGNDATA) &this[1])))
  1977. return(FALSE);
  1978. bRet = FillRgn(hdc, hrgn, hbr);
  1979. if (!DeleteObject(hrgn))
  1980. {
  1981. ASSERTGDI(FALSE, "DeleteObject failed");
  1982. }
  1983. return(bRet);
  1984. }
  1985. /******************************Public*Routine******************************\
  1986. * BOOL MRFRAMERGN::bPlay(hdc, pht, cht)
  1987. *
  1988. * Play the metafile record.
  1989. *
  1990. * History:
  1991. * Tue Oct 29 13:44:38 1991 -by- Hock San Lee [hockl]
  1992. * Wrote it.
  1993. \**************************************************************************/
  1994. BOOL MRFRAMERGN::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  1995. {
  1996. PMF pmf;
  1997. BOOL bRet;
  1998. HRGN hrgn;
  1999. HBRUSH hbr;
  2000. PUTS("MRFRAMERGN::bPlay\n");
  2001. ASSERTGDI(iType == EMR_FRAMERGN, "Bad record type");
  2002. // Get metafile.
  2003. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  2004. return(FALSE);
  2005. if (!bCheckRecord(pht))
  2006. return(FALSE);
  2007. // Check bounds.
  2008. if (pmf->bClipped(erclBounds))
  2009. return(TRUE);
  2010. // Get the brush handle.
  2011. if (STOCK_IMHE(imheBrush))
  2012. {
  2013. // Stock brush.
  2014. hbr = (HBRUSH) GetStockObject(imheBrush & ~ENHMETA_STOCK_OBJECT);
  2015. }
  2016. else
  2017. {
  2018. // Make sure the handle is in the table.
  2019. if (!VALID_IMHE(imheBrush, cht))
  2020. return(FALSE);
  2021. // If brush creation failed earlier, hbr is 0 and FrameRgn will
  2022. // just return an error.
  2023. hbr = (HBRUSH) pht->objectHandle[imheBrush];
  2024. }
  2025. // Create the region.
  2026. if (!(hrgn = ExtCreateRegion((LPXFORM) NULL, cRgnData, (LPRGNDATA) &this[1])))
  2027. return(FALSE);
  2028. bRet = FrameRgn(hdc, hrgn, hbr, (int) nWidth, (int) nHeight);
  2029. if (!DeleteObject(hrgn))
  2030. {
  2031. ASSERTGDI(FALSE, "DeleteObject failed");
  2032. }
  2033. return(bRet);
  2034. }
  2035. /******************************Public*Routine******************************\
  2036. * BOOL MROFFSETCLIPRGN::bPlay(hdc, pht, cht)
  2037. *
  2038. * Play the metafile record.
  2039. *
  2040. * History:
  2041. * Tue Oct 29 13:44:38 1991 -by- Hock San Lee [hockl]
  2042. * Wrote it.
  2043. \**************************************************************************/
  2044. BOOL MROFFSETCLIPRGN::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2045. {
  2046. PUTS("MROFFSETCLIPRGN::bPlay\n");
  2047. ASSERTGDI(iType == EMR_OFFSETCLIPRGN, "Bad record type");
  2048. USE(pht);
  2049. USE(cht);
  2050. if (!bCheckRecord(pht))
  2051. return(FALSE);
  2052. // Since we have moved the initial destination clip region into the meta
  2053. // region (hrgnMeta), the offset will not affect the initial clip region.
  2054. return(OffsetClipRgn(hdc, (int) d1, (int) d2) != RGN_ERROR);
  2055. }
  2056. /******************************Public*Routine******************************\
  2057. * BOOL MREXTSELECTCLIPRGN::bPlay(hdc, pht, cht)
  2058. *
  2059. * Play the metafile record.
  2060. *
  2061. * History:
  2062. * Tue Oct 29 13:44:38 1991 -by- Hock San Lee [hockl]
  2063. * Wrote it.
  2064. \**************************************************************************/
  2065. BOOL MREXTSELECTCLIPRGN::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2066. {
  2067. PMF pmf;
  2068. BOOL bRet;
  2069. HRGN hrgn;
  2070. PUTS("MREXTSELECTCLIPRGN::bPlay\n");
  2071. ASSERTGDI(iType == EMR_EXTSELECTCLIPRGN, "Bad record type");
  2072. USE(cht);
  2073. // Get metafile.
  2074. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  2075. return(FALSE);
  2076. if (!bCheckRecord(pht))
  2077. return(FALSE);
  2078. // Create the region if necessary.
  2079. // The region will be created in the destination units.
  2080. if (cRgnData == 0) // default region
  2081. {
  2082. ASSERTGDI(iMode == RGN_COPY,
  2083. "MREXTSELECTCLIPRGN::bPlay: No region data");
  2084. hrgn = (HRGN) 0;
  2085. }
  2086. else if (!(hrgn = ExtCreateRegion(&pmf->xformBase,
  2087. // this happens to be xformBase
  2088. cRgnData,
  2089. (LPRGNDATA) &this[1])))
  2090. return(FALSE);
  2091. // Since we have moved the initial destination clip region into the meta
  2092. // region (hrgnMeta), the select will not affect the initial clip region.
  2093. bRet = ExtSelectClipRgn(hdc, hrgn, (int) iMode) != RGN_ERROR;
  2094. if (hrgn)
  2095. {
  2096. if (!DeleteObject(hrgn))
  2097. {
  2098. ASSERTGDI(FALSE, "DeleteObject failed");
  2099. }
  2100. }
  2101. return(bRet);
  2102. }
  2103. /******************************Public*Routine******************************\
  2104. * BOOL MRSETMETARGN::bPlay(hdc, pht, cht)
  2105. *
  2106. * Play the metafile record.
  2107. *
  2108. * History:
  2109. * Tue Apr 07 17:59:25 1992 -by- Hock San Lee [hockl]
  2110. * Wrote it.
  2111. \**************************************************************************/
  2112. BOOL MRSETMETARGN::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2113. {
  2114. PUTS("MRSETMETARGN::bPlay\n");
  2115. ASSERTGDI(iType == EMR_SETMETARGN, "Bad record type");
  2116. USE(pht);
  2117. USE(cht);
  2118. if (!bCheckRecord(pht))
  2119. return(FALSE);
  2120. return(SetMetaRgn(hdc) != RGN_ERROR);
  2121. }
  2122. /******************************Public*Routine******************************\
  2123. * BOOL MRSCALEVIEWPORTEXTEX::bPlay(hdc, pht, cht)
  2124. *
  2125. * Play the metafile record.
  2126. *
  2127. * History:
  2128. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  2129. * Wrote it.
  2130. \**************************************************************************/
  2131. BOOL MRSCALEVIEWPORTEXTEX::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2132. {
  2133. PMF pmf;
  2134. PUTS("MRSCALEVIEWPORTEXTEX::bPlay\n");
  2135. ASSERTGDI(iType == EMR_SCALEVIEWPORTEXTEX, "Bad record type");
  2136. USE(cht);
  2137. // Get metafile.
  2138. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  2139. return(FALSE);
  2140. // Cannot change extent in fixed scale mapping mode.
  2141. if (GetMapMode(pmf->hdcXform) <= MM_MAX_FIXEDSCALE)
  2142. return(TRUE);
  2143. if (!bCheckRecord(pht))
  2144. return(FALSE);
  2145. // Play it to the virtual DC.
  2146. if (!ScaleViewportExtEx(pmf->hdcXform,
  2147. (int) d1,
  2148. (int) d2,
  2149. (int) d3,
  2150. (int) d4,
  2151. (LPSIZE) NULL))
  2152. return(FALSE);
  2153. // Set up new transform in the target DC.
  2154. return(pmf->bSetTransform(hdc));
  2155. }
  2156. /******************************Public*Routine******************************\
  2157. * BOOL MRSCALEWINDOWEXTEX::bPlay(hdc, pht, cht)
  2158. *
  2159. * Play the metafile record.
  2160. *
  2161. * History:
  2162. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  2163. * Wrote it.
  2164. \**************************************************************************/
  2165. BOOL MRSCALEWINDOWEXTEX::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2166. {
  2167. PMF pmf;
  2168. PUTS("MRSCALEWINDOWEXTEX::bPlay\n");
  2169. ASSERTGDI(iType == EMR_SCALEWINDOWEXTEX, "Bad record type");
  2170. USE(cht);
  2171. // Get metafile.
  2172. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  2173. return(FALSE);
  2174. // Cannot change extent in fixed scale mapping mode.
  2175. if (GetMapMode(pmf->hdcXform) <= MM_MAX_FIXEDSCALE)
  2176. return(TRUE);
  2177. if (!bCheckRecord(pht))
  2178. return(FALSE);
  2179. // Play it to the virtual DC.
  2180. if (!ScaleWindowExtEx(pmf->hdcXform,
  2181. (int) d1,
  2182. (int) d2,
  2183. (int) d3,
  2184. (int) d4,
  2185. (LPSIZE) NULL))
  2186. return(FALSE);
  2187. // Set up new transform in the target DC.
  2188. return(pmf->bSetTransform(hdc));
  2189. }
  2190. /******************************Public*Routine******************************\
  2191. * BOOL MRSAVEDC::bPlay(hdc, pht, cht)
  2192. *
  2193. * Play the metafile record.
  2194. *
  2195. * History:
  2196. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  2197. * Wrote it.
  2198. \**************************************************************************/
  2199. BOOL MRSAVEDC::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2200. {
  2201. PMF pmf;
  2202. PUTS("MRSAVEDC::bPlay\n");
  2203. ASSERTGDI(iType == EMR_SAVEDC, "Bad record type");
  2204. USE(cht);
  2205. // Get metafile.
  2206. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  2207. return(FALSE);
  2208. if (!bCheckRecord(pht))
  2209. return(FALSE);
  2210. // Save the virtual DC used for transform computation.
  2211. if (!SaveDC(pmf->hdcXform))
  2212. return(FALSE);
  2213. // We may need to save the MF data structure here. Luckily there is no
  2214. // other data in the MF structure that requires us to do this.
  2215. // Save the target DC.
  2216. if (SaveDC(hdc) == 0)
  2217. {
  2218. RestoreDC(pmf->hdcXform, -1);
  2219. return(FALSE);
  2220. }
  2221. pmf->cLevel++;
  2222. return(TRUE);
  2223. }
  2224. /******************************Public*Routine******************************\
  2225. * BOOL MRRESTOREDC::bPlay(hdc, pht, cht)
  2226. *
  2227. * Play the metafile record.
  2228. *
  2229. * History:
  2230. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  2231. * Wrote it.
  2232. \**************************************************************************/
  2233. BOOL MRRESTOREDC::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2234. {
  2235. PMF pmf;
  2236. PUTS("MRRESTOREDC::bPlay\n");
  2237. ASSERTGDI(iType == EMR_RESTOREDC, "Bad record type");
  2238. USE(cht);
  2239. // Get metafile.
  2240. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  2241. return(FALSE);
  2242. if (!bCheckRecord(pht))
  2243. return(FALSE);
  2244. // No absolute level restore is allowed.
  2245. if ((int) d1 > 0)
  2246. return(FALSE);
  2247. // Restore the virtual DC used for transform computation.
  2248. // If we can restore the virtual DC, we know that it is a balanced restore.
  2249. // Otherwise, we return an error.
  2250. if (!RestoreDC(pmf->hdcXform, (int) d1))
  2251. return(FALSE);
  2252. // Restore the target DC.
  2253. pmf->cLevel += d1;
  2254. return(RestoreDC(hdc, (int) d1));
  2255. }
  2256. /******************************Public*Routine******************************\
  2257. * BOOL MRSETWORLDTRANSFORM::bPlay(hdc, pht, cht)
  2258. *
  2259. * Play the metafile record.
  2260. *
  2261. * History:
  2262. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  2263. * Wrote it.
  2264. \**************************************************************************/
  2265. BOOL MRSETWORLDTRANSFORM::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2266. {
  2267. PMF pmf;
  2268. PUTS("MRSETWORLDTRANSFORM::bPlay\n");
  2269. ASSERTGDI(iType == EMR_SETWORLDTRANSFORM, "Bad record type");
  2270. USE(cht);
  2271. // Get metafile.
  2272. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  2273. return(FALSE);
  2274. if (!bCheckRecord(pht))
  2275. return(FALSE);
  2276. // Play it to the virtual DC.
  2277. if (!SetWorldTransform(pmf->hdcXform, &xform))
  2278. return(FALSE);
  2279. // Set up new transform in the target DC.
  2280. return(pmf->bSetTransform(hdc));
  2281. }
  2282. /******************************Public*Routine******************************\
  2283. * BOOL MRMODIFYWORLDTRANSFORM::bPlay(hdc, pht, cht)
  2284. *
  2285. * Play the metafile record.
  2286. *
  2287. * History:
  2288. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  2289. * Wrote it.
  2290. \**************************************************************************/
  2291. BOOL MRMODIFYWORLDTRANSFORM::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2292. {
  2293. PMF pmf;
  2294. PUTS("MRMODIFYWORLDTRANSFORM::bPlay\n");
  2295. ASSERTGDI(iType == EMR_MODIFYWORLDTRANSFORM, "Bad record type");
  2296. USE(cht);
  2297. // Get metafile.
  2298. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  2299. return(FALSE);
  2300. if (!bCheckRecord(pht))
  2301. return(FALSE);
  2302. // Play it to the virtual DC.
  2303. if (!ModifyWorldTransform(pmf->hdcXform, &xform, d1))
  2304. return(FALSE);
  2305. // Do the easy case of left multiply.
  2306. if (d1 == MWT_LEFTMULTIPLY)
  2307. return(ModifyWorldTransform(hdc, &xform, d1));
  2308. // Recompute transform in the other two cases.
  2309. // Set up new transform in the target DC.
  2310. return(pmf->bSetTransform(hdc));
  2311. }
  2312. /******************************Public*Routine******************************\
  2313. * BOOL MRSELECTOBJECT::bPlay(hdc, pht, cht)
  2314. *
  2315. * Play the metafile record.
  2316. *
  2317. * History:
  2318. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  2319. * Wrote it.
  2320. \**************************************************************************/
  2321. BOOL MRSELECTOBJECT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2322. {
  2323. PUTS("MRSELECTOBJECT::bPlay\n");
  2324. ASSERTGDI(iType == EMR_SELECTOBJECT, "Bad record type");
  2325. if (!bCheckRecord(pht))
  2326. return(FALSE);
  2327. // Do stock objects first.
  2328. if (STOCK_IMHE(d1))
  2329. return
  2330. (
  2331. SelectObject(hdc, GetStockObject(d1 & ~ENHMETA_STOCK_OBJECT))
  2332. != 0
  2333. );
  2334. // Make sure the handle is in the table.
  2335. if (!VALID_IMHE(d1, cht))
  2336. return(FALSE);
  2337. // If object creation failed earlier, object handle is 0 and SelectObject
  2338. // will just return an error.
  2339. return(SelectObject(hdc, pht->objectHandle[d1]) != 0);
  2340. }
  2341. /******************************Public*Routine******************************\
  2342. * BOOL MRSELECTPALETTE::bPlay(hdc, pht, cht)
  2343. *
  2344. * Play the metafile record.
  2345. * The palette is always selected as a background palette.
  2346. *
  2347. * History:
  2348. * Sun Sep 22 16:53:24 1991 -by- Hock San Lee [hockl]
  2349. * Wrote it.
  2350. \**************************************************************************/
  2351. BOOL MRSELECTPALETTE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2352. {
  2353. PUTS("MRSELECTPALETTE::bPlay\n");
  2354. ASSERTGDI(iType == EMR_SELECTPALETTE, "Bad record type");
  2355. if (!bCheckRecord(pht))
  2356. return(FALSE);
  2357. // Do stock palette first.
  2358. if (d1 == (ENHMETA_STOCK_OBJECT | DEFAULT_PALETTE))
  2359. return
  2360. (
  2361. SelectPalette(hdc, (HPALETTE) GetStockObject(DEFAULT_PALETTE), TRUE)
  2362. != 0
  2363. );
  2364. // Make sure the handle is in the table.
  2365. if (!VALID_IMHE(d1, cht))
  2366. return(FALSE);
  2367. // If palette creation failed earlier, hpal is 0 and SelectPalette will
  2368. // just return an error.
  2369. return(SelectPalette(hdc, (HPALETTE) pht->objectHandle[d1], TRUE) != 0);
  2370. }
  2371. /******************************Public*Routine******************************\
  2372. * BOOL MRCOLORCORRECTPALETTE::bPlay(hdc, pht, cht)
  2373. *
  2374. * Play the metafile record.
  2375. *
  2376. * History:
  2377. \**************************************************************************/
  2378. BOOL MRCOLORCORRECTPALETTE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2379. {
  2380. PUTS("MRCOLORCORRECTPALETTE::bPlay\n");
  2381. ASSERTGDI(iType == EMR_COLORCORRECTPALETTE, "Bad record type");
  2382. if (!bCheckRecord(pht))
  2383. return(FALSE);
  2384. // Make sure the handle is in the table.
  2385. if (!VALID_IMHE(d1, cht))
  2386. return(FALSE);
  2387. return(ColorCorrectPalette(hdc, (HPALETTE) pht->objectHandle[d1], d2, d3) != 0);
  2388. }
  2389. /******************************Public*Routine******************************\
  2390. * BOOL MRCREATEPEN::bPlay(hdc, pht, cht)
  2391. *
  2392. * Play the metafile record.
  2393. *
  2394. * History:
  2395. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  2396. * Wrote it.
  2397. \**************************************************************************/
  2398. BOOL MRCREATEPEN::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2399. {
  2400. PUTS("MRCREATEPEN::bPlay\n");
  2401. ASSERTGDI(iType == EMR_CREATEPEN, "Bad record type");
  2402. USE(hdc);
  2403. if (!bCheckRecord(pht))
  2404. return(FALSE);
  2405. // Make sure the handle is in the table.
  2406. if (!VALID_IMHE(imhe, cht))
  2407. return(FALSE);
  2408. // Create the pen and store it in the table.
  2409. pht->objectHandle[imhe] = CreatePenIndirect(&logpen);
  2410. return(pht->objectHandle[imhe] != 0);
  2411. }
  2412. /******************************Public*Routine******************************\
  2413. * BOOL MREXTCREATEPEN::bPlay(hdc, pht, cht)
  2414. *
  2415. * Play the metafile record.
  2416. *
  2417. * History:
  2418. * Mon Mar 16 18:20:11 1992 -by- Hock San Lee [hockl]
  2419. * Wrote it.
  2420. \**************************************************************************/
  2421. BOOL MREXTCREATEPEN::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2422. {
  2423. LOGBRUSH lb;
  2424. HBITMAP hbm = (HBITMAP) 0;
  2425. PUTS("MREXTCREATEPEN::bPlay\n");
  2426. ASSERTGDI(iType == EMR_EXTCREATEPEN, "Bad record type");
  2427. USE(hdc);
  2428. if (!bCheckRecord(pht))
  2429. return(FALSE);
  2430. // Make sure the handle is in the table.
  2431. if (!VALID_IMHE(imhe, cht))
  2432. return(FALSE);
  2433. // Create the brush if any.
  2434. lb.lbStyle = elp.elpBrushStyle;
  2435. lb.lbColor = elp.elpColor;
  2436. lb.lbHatch = (ULONG_PTR)(elp.elpHatch);
  2437. if (elp.elpBrushStyle == BS_PATTERN)
  2438. {
  2439. if (!bValidOff(pht, offBitsInfo) || !bValidOff(pht, offBits))
  2440. {
  2441. EMFVALFAIL(("MREXTCREATEPEN::bPlay: bValidOff offBitsInfo = %08x, offBits = %08x Failed\n", offBitsInfo, offBits));
  2442. goto mecp_exit;
  2443. }
  2444. // Mono bitmap.
  2445. if (!(hbm = CreateMonoDib
  2446. (
  2447. (PBMI) ((PBYTE) this + offBitsInfo),
  2448. (CONST BYTE *) ((PBYTE) this + offBits),
  2449. *(PUINT) &elp.elpColor
  2450. )
  2451. )
  2452. )
  2453. goto mecp_exit;
  2454. lb.lbHatch = (ULONG_PTR)hbm;
  2455. }
  2456. else if (elp.elpBrushStyle == BS_DIBPATTERNPT
  2457. || elp.elpBrushStyle == BS_DIBPATTERN)
  2458. {
  2459. // DIB bitmap.
  2460. if (!bValidOff(pht, offBitsInfo))
  2461. {
  2462. EMFVALFAIL(("MREXTCREATEPEN::bPlay: bValidOff offBitsInfo = %08x Failed\n", offBitsInfo));
  2463. goto mecp_exit;
  2464. }
  2465. lb.lbStyle = BS_DIBPATTERNPT;
  2466. lb.lbHatch = (ULONG_PTR)((PBYTE) this + offBitsInfo);
  2467. }
  2468. // Create the pen and store it in the table.
  2469. pht->objectHandle[imhe] = ExtCreatePen
  2470. (
  2471. (DWORD) elp.elpPenStyle,
  2472. (DWORD) elp.elpWidth,
  2473. &lb,
  2474. elp.elpNumEntries,
  2475. elp.elpNumEntries
  2476. ? elp.elpStyleEntry
  2477. : (LPDWORD) NULL
  2478. );
  2479. mecp_exit:
  2480. if (hbm)
  2481. {
  2482. if (!DeleteObject(hbm))
  2483. {
  2484. ASSERTGDI(FALSE, "MREXTCREATEPEN::bPlay: DeleteObject failed");
  2485. }
  2486. }
  2487. return(pht->objectHandle[imhe] != 0);
  2488. }
  2489. /******************************Public*Routine******************************\
  2490. * BOOL MRCREATEPALETTE::bPlay(hdc, pht, cht)
  2491. *
  2492. * Play the metafile record.
  2493. *
  2494. * History:
  2495. * Sun Sep 22 15:07:56 1991 -by- Hock San Lee [hockl]
  2496. * Wrote it.
  2497. \**************************************************************************/
  2498. BOOL MRCREATEPALETTE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2499. {
  2500. PUTS("MRCREATEPALETTE::bPlay\n");
  2501. ASSERTGDI(iType == EMR_CREATEPALETTE, "Bad record type");
  2502. USE(hdc);
  2503. if (!bCheckRecord(pht))
  2504. return(FALSE);
  2505. // Make sure the handle is in the table.
  2506. if (!VALID_IMHE(imhe, cht))
  2507. return(FALSE);
  2508. // Create the palette and store it in the table.
  2509. pht->objectHandle[imhe] = CreatePalette(&logpal);
  2510. return(pht->objectHandle[imhe] != 0);
  2511. }
  2512. /******************************Public*Routine******************************\
  2513. * BOOL MRCREATEBRUSHINDIRECT::bPlay(hdc, pht, cht)
  2514. *
  2515. * Play the metafile record.
  2516. *
  2517. * History:
  2518. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  2519. * Wrote it.
  2520. \**************************************************************************/
  2521. BOOL MRCREATEBRUSHINDIRECT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2522. {
  2523. LOGBRUSH lbNew;
  2524. PUTS("MRCREATEBRUSHINDIRECT::bPlay\n");
  2525. ASSERTGDI(iType == EMR_CREATEBRUSHINDIRECT, "Bad record type");
  2526. USE(hdc);
  2527. if (!bCheckRecord(pht))
  2528. return(FALSE);
  2529. // Make sure the handle is in the table.
  2530. if (!VALID_IMHE(imhe, cht))
  2531. return(FALSE);
  2532. // Create the brush and store it in the table.
  2533. if (lb.lbStyle != BS_SOLID
  2534. && lb.lbStyle != BS_HATCHED
  2535. && lb.lbStyle != BS_HOLLOW)
  2536. return(FALSE);
  2537. lbNew.lbStyle = lb.lbStyle;
  2538. lbNew.lbColor = lb.lbColor;
  2539. lbNew.lbHatch = (UINT_PTR)lb.lbHatch;
  2540. pht->objectHandle[imhe] = CreateBrushIndirect(&lbNew);
  2541. return(pht->objectHandle[imhe] != 0);
  2542. }
  2543. /******************************Public*Routine******************************\
  2544. * BOOL MRCREATEMONOBRUSH::bPlay(hdc, pht, cht)
  2545. *
  2546. * Play the metafile record.
  2547. *
  2548. * History:
  2549. * Thu Mar 12 17:13:53 1992 -by- Hock San Lee [hockl]
  2550. * Wrote it.
  2551. \**************************************************************************/
  2552. BOOL MRCREATEMONOBRUSH::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2553. {
  2554. HBITMAP hbm;
  2555. PUTS("MRCREATEMONOBRUSH::bPlay\n");
  2556. ASSERTGDI(iType == EMR_CREATEMONOBRUSH, "Bad record type");
  2557. USE(hdc);
  2558. if (!bCheckRecord(pht))
  2559. return(FALSE);
  2560. // Make sure the handle is in the table.
  2561. if (!VALID_IMHE(imhe, cht))
  2562. return(FALSE);
  2563. if (!bValidOff(pht, offBitsInfo) || !bValidOff(pht, offBits))
  2564. {
  2565. EMFVALFAIL(("MRCREATEMONOBRUSH::bPlay: bValidOff offBitsInfo = %08x, offBits = %08x Failed\n", offBitsInfo, offBits));
  2566. return(FALSE);
  2567. }
  2568. // Create the brush and store it in the table.
  2569. if (!(hbm = CreateMonoDib
  2570. (
  2571. (PBMI) ((PBYTE) this + offBitsInfo),
  2572. (CONST BYTE *) ((PBYTE) this + offBits),
  2573. (UINT) iUsage
  2574. )
  2575. )
  2576. )
  2577. return(FALSE);
  2578. pht->objectHandle[imhe] = CreatePatternBrush(hbm);
  2579. if (!DeleteObject(hbm))
  2580. {
  2581. ASSERTGDI(FALSE, "MRCREATEMONOBRUSH::bPlay: DeleteObject failed");
  2582. }
  2583. return(pht->objectHandle[imhe] != 0);
  2584. }
  2585. /******************************Public*Routine******************************\
  2586. * BOOL MRCREATEDIBPATTERNBRUSHPT::bPlay(hdc, pht, cht)
  2587. *
  2588. * Play the metafile record.
  2589. *
  2590. * History:
  2591. * Thu Mar 12 17:13:53 1992 -by- Hock San Lee [hockl]
  2592. * Wrote it.
  2593. \**************************************************************************/
  2594. BOOL MRCREATEDIBPATTERNBRUSHPT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2595. {
  2596. PUTS("MRCREATEDIBPATTERNBRUSHPT::bPlay\n");
  2597. ASSERTGDI(iType == EMR_CREATEDIBPATTERNBRUSHPT, "Bad record type");
  2598. USE(hdc);
  2599. if (!bCheckRecord(pht))
  2600. return(FALSE);
  2601. // Make sure the handle is in the table.
  2602. if (!VALID_IMHE(imhe, cht))
  2603. return(FALSE);
  2604. if (!bValidOff(pht, offBitsInfo))
  2605. {
  2606. EMFVALFAIL(("EMR_CREATEDIBPATTERNBRUSHPT::bPlay: bValidOff offBitsInfo = %08x Failed\n", offBitsInfo));
  2607. return(FALSE);
  2608. }
  2609. // Create the brush and store it in the table.
  2610. pht->objectHandle[imhe] = CreateDIBPatternBrushPt
  2611. (
  2612. (LPBITMAPINFO) ((PBYTE) this + offBitsInfo),
  2613. (UINT) iUsage
  2614. );
  2615. return(pht->objectHandle[imhe] != 0);
  2616. }
  2617. /******************************Public*Routine******************************\
  2618. * BOOL MREXTCREATEFONTINDIRECTW::bPlay(hdc, pht, cht)
  2619. *
  2620. * Play the metafile record.
  2621. *
  2622. * History:
  2623. * Tue Jan 14 14:10:43 1992 -by- Hock San Lee [hockl]
  2624. * Wrote it.
  2625. \**************************************************************************/
  2626. BOOL MREXTCREATEFONTINDIRECTW::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2627. {
  2628. PUTS("MREXTCREATEFONTINDIRECTW::bPlay\n");
  2629. ASSERTGDI(iType == EMR_EXTCREATEFONTINDIRECTW, "Bad record type");
  2630. USE(hdc);
  2631. if (!bCheckRecord(pht))
  2632. return(FALSE);
  2633. // Make sure the handle is in the table.
  2634. if (!VALID_IMHE(imhe, cht))
  2635. return(FALSE);
  2636. // As of NT 5.0 we only record records that contain ENUMLOGFONTEXDVW,
  2637. // but we still need to be able to play records that contain EXTLOGFONT
  2638. // that may have been recorded on win9x or pre NT 5.0 system
  2639. if (nSize <= sizeof(MREXTCREATEFONTINDIRECTW))
  2640. {
  2641. // the old type structure, contains only EXTLOGFONT or even only LOGFONTW
  2642. pht->objectHandle[imhe] = CreateFontIndirectW((CONST LOGFONTW *) &elfw);
  2643. }
  2644. else
  2645. {
  2646. // this record contains ENUMLOGFONTEXDVW structure
  2647. pht->objectHandle[imhe] = CreateFontIndirectExW((CONST ENUMLOGFONTEXDVW*) &elfw);
  2648. }
  2649. return(pht->objectHandle[imhe] != 0);
  2650. }
  2651. /******************************Public*Routine******************************\
  2652. * BOOL MRDELETEOBJECT::bPlay(hdc, pht, cht)
  2653. *
  2654. * Play the metafile record.
  2655. *
  2656. * History:
  2657. * Thu Aug 22 16:44:09 1991 -by- Hock San Lee [hockl]
  2658. * Wrote it.
  2659. \**************************************************************************/
  2660. BOOL MRDELETEOBJECT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2661. {
  2662. BOOL bRet;
  2663. PUTS("MRDELETEOBJECT::bPlay\n");
  2664. ASSERTGDI(iType == EMR_DELETEOBJECT, "Bad record type");
  2665. USE(hdc);
  2666. if (!bCheckRecord(pht))
  2667. return(FALSE);
  2668. // Our metafile driver never emits delete stock object records.
  2669. // Handle it anyway.
  2670. if (STOCK_IMHE(d1))
  2671. {
  2672. ERROR_ASSERT(FALSE, "MRDELETEOBJECT::bPlay: Deleting a stock object");
  2673. return(TRUE); // see DeleteObject
  2674. }
  2675. // Make sure the handle is in the table.
  2676. if (!VALID_IMHE(d1, cht))
  2677. return(FALSE);
  2678. // Delete the object and remove it from the table.
  2679. bRet = DeleteObject(pht->objectHandle[d1]);
  2680. pht->objectHandle[d1] = 0;
  2681. return(bRet);
  2682. }
  2683. /******************************Public*Routine******************************\
  2684. * BOOL MRANGLEARC::bPlay(hdc, pht, cht)
  2685. *
  2686. * Play the metafile record.
  2687. *
  2688. * History:
  2689. * Fri Sep 13 17:54:00 1991 -by- Hock San Lee [hockl]
  2690. * Wrote it.
  2691. \**************************************************************************/
  2692. BOOL MRANGLEARC::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2693. {
  2694. PUTS("MRANGLEARC::bPlay\n");
  2695. ASSERTGDI(iType == EMR_ANGLEARC, "Bad record type");
  2696. USE(pht);
  2697. USE(cht);
  2698. if (!bCheckRecord(pht))
  2699. return(FALSE);
  2700. return(AngleArc(hdc, (int) eptl.x, (int) eptl.y, nRadius, eStartAngle, eSweepAngle));
  2701. }
  2702. /******************************Public*Routine******************************\
  2703. * BOOL MRELLIPSE::bPlay(hdc, pht, cht)
  2704. *
  2705. * Play the metafile record.
  2706. *
  2707. * History:
  2708. * Fri Sep 13 17:54:00 1991 -by- Hock San Lee [hockl]
  2709. * Wrote it.
  2710. \**************************************************************************/
  2711. BOOL MRELLIPSE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2712. {
  2713. PUTS("MRELLIPSE::bPlay\n");
  2714. ASSERTGDI(iType == EMR_ELLIPSE, "Bad record type");
  2715. USE(pht);
  2716. USE(cht);
  2717. // erclBox is inclusive-inclusive. Make sure we have set the advanced
  2718. // graphics mode.
  2719. ASSERTGDI
  2720. (
  2721. GetGraphicsMode(hdc) == GM_ADVANCED,
  2722. "MR::bPlay: Not in advanced graphics mode"
  2723. );
  2724. if (!bCheckRecord(pht))
  2725. return(FALSE);
  2726. return
  2727. (
  2728. Ellipse
  2729. (
  2730. hdc,
  2731. (int) erclBox.left,
  2732. (int) erclBox.top,
  2733. (int) erclBox.right,
  2734. (int) erclBox.bottom
  2735. )
  2736. );
  2737. }
  2738. /******************************Public*Routine******************************\
  2739. * BOOL MRRECTANGLE::bPlay(hdc, pht, cht)
  2740. *
  2741. * Play the metafile record.
  2742. *
  2743. * History:
  2744. * Fri Sep 13 17:54:00 1991 -by- Hock San Lee [hockl]
  2745. * Wrote it.
  2746. \**************************************************************************/
  2747. BOOL MRRECTANGLE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2748. {
  2749. PUTS("MRRECTANGLE::bPlay\n");
  2750. ASSERTGDI(iType == EMR_RECTANGLE, "Bad record type");
  2751. USE(pht);
  2752. USE(cht);
  2753. // erclBox is inclusive-inclusive. Make sure we have set the advanced
  2754. // graphics mode.
  2755. ASSERTGDI
  2756. (
  2757. GetGraphicsMode(hdc) == GM_ADVANCED,
  2758. "MR::bPlay: Not in advanced graphics mode"
  2759. );
  2760. if (!bCheckRecord(pht))
  2761. return(FALSE);
  2762. return
  2763. (
  2764. Rectangle
  2765. (
  2766. hdc,
  2767. (int) erclBox.left,
  2768. (int) erclBox.top,
  2769. (int) erclBox.right,
  2770. (int) erclBox.bottom
  2771. )
  2772. );
  2773. }
  2774. /******************************Public*Routine******************************\
  2775. * BOOL MRROUNDRECT::bPlay(hdc, pht, cht)
  2776. *
  2777. * Play the metafile record.
  2778. *
  2779. * History:
  2780. * Fri Sep 13 17:54:00 1991 -by- Hock San Lee [hockl]
  2781. * Wrote it.
  2782. \**************************************************************************/
  2783. BOOL MRROUNDRECT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2784. {
  2785. PUTS("MRROUNDRECT::bPlay\n");
  2786. ASSERTGDI(iType == EMR_ROUNDRECT, "Bad record type");
  2787. USE(pht);
  2788. USE(cht);
  2789. // erclBox is inclusive-inclusive. Make sure we have set the advanced
  2790. // graphics mode.
  2791. ASSERTGDI
  2792. (
  2793. GetGraphicsMode(hdc) == GM_ADVANCED,
  2794. "MR::bPlay: Not in advanced graphics mode"
  2795. );
  2796. if (!bCheckRecord(pht))
  2797. return(FALSE);
  2798. return
  2799. (
  2800. RoundRect
  2801. (
  2802. hdc,
  2803. (int) erclBox.left,
  2804. (int) erclBox.top,
  2805. (int) erclBox.right,
  2806. (int) erclBox.bottom,
  2807. (int) szlEllipse.cx,
  2808. (int) szlEllipse.cy
  2809. )
  2810. );
  2811. }
  2812. /******************************Public*Routine******************************\
  2813. * BOOL MRARC::bPlay(hdc, pht, cht)
  2814. *
  2815. * Play the metafile record.
  2816. *
  2817. * History:
  2818. * Fri Sep 13 17:54:00 1991 -by- Hock San Lee [hockl]
  2819. * Wrote it.
  2820. \**************************************************************************/
  2821. BOOL MRARC::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2822. {
  2823. PUTS("MRARC::bPlay\n");
  2824. ASSERTGDI(iType == EMR_ARC, "Bad record type");
  2825. USE(pht);
  2826. USE(cht);
  2827. // erclBox is inclusive-inclusive. Make sure we have set the advanced
  2828. // graphics mode.
  2829. ASSERTGDI
  2830. (
  2831. GetGraphicsMode(hdc) == GM_ADVANCED,
  2832. "MR::bPlay: Not in advanced graphics mode"
  2833. );
  2834. if (!bCheckRecord(pht))
  2835. return(FALSE);
  2836. return
  2837. (
  2838. Arc
  2839. (
  2840. hdc,
  2841. (int) erclBox.left,
  2842. (int) erclBox.top,
  2843. (int) erclBox.right,
  2844. (int) erclBox.bottom,
  2845. (int) eptlStart.x,
  2846. (int) eptlStart.y,
  2847. (int) eptlEnd.x,
  2848. (int) eptlEnd.y
  2849. )
  2850. );
  2851. }
  2852. /******************************Public*Routine******************************\
  2853. * BOOL MRARCTO::bPlay(hdc, pht, cht)
  2854. *
  2855. * Play the metafile record.
  2856. *
  2857. * History:
  2858. * Wed Oct 02 10:44:31 1991 -by- Hock San Lee [hockl]
  2859. * Wrote it.
  2860. \**************************************************************************/
  2861. BOOL MRARCTO::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2862. {
  2863. PUTS("MRARCTO::bPlay\n");
  2864. ASSERTGDI(iType == EMR_ARCTO, "Bad record type");
  2865. USE(pht);
  2866. USE(cht);
  2867. // erclBox is inclusive-inclusive. Make sure we have set the advanced
  2868. // graphics mode.
  2869. ASSERTGDI
  2870. (
  2871. GetGraphicsMode(hdc) == GM_ADVANCED,
  2872. "MR::bPlay: Not in advanced graphics mode"
  2873. );
  2874. if (!bCheckRecord(pht))
  2875. return(FALSE);
  2876. return
  2877. (
  2878. ArcTo
  2879. (
  2880. hdc,
  2881. (int) erclBox.left,
  2882. (int) erclBox.top,
  2883. (int) erclBox.right,
  2884. (int) erclBox.bottom,
  2885. (int) eptlStart.x,
  2886. (int) eptlStart.y,
  2887. (int) eptlEnd.x,
  2888. (int) eptlEnd.y
  2889. )
  2890. );
  2891. }
  2892. /******************************Public*Routine******************************\
  2893. * BOOL MRCHORD::bPlay(hdc, pht, cht)
  2894. *
  2895. * Play the metafile record.
  2896. *
  2897. * History:
  2898. * Fri Sep 13 17:54:00 1991 -by- Hock San Lee [hockl]
  2899. * Wrote it.
  2900. \**************************************************************************/
  2901. BOOL MRCHORD::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2902. {
  2903. PUTS("MRCHORD::bPlay\n");
  2904. ASSERTGDI(iType == EMR_CHORD, "Bad record type");
  2905. USE(pht);
  2906. USE(cht);
  2907. // erclBox is inclusive-inclusive. Make sure we have set the advanced
  2908. // graphics mode.
  2909. ASSERTGDI
  2910. (
  2911. GetGraphicsMode(hdc) == GM_ADVANCED,
  2912. "MR::bPlay: Not in advanced graphics mode"
  2913. );
  2914. if (!bCheckRecord(pht))
  2915. return(FALSE);
  2916. return
  2917. (
  2918. Chord
  2919. (
  2920. hdc,
  2921. (int) erclBox.left,
  2922. (int) erclBox.top,
  2923. (int) erclBox.right,
  2924. (int) erclBox.bottom,
  2925. (int) eptlStart.x,
  2926. (int) eptlStart.y,
  2927. (int) eptlEnd.x,
  2928. (int) eptlEnd.y
  2929. )
  2930. );
  2931. }
  2932. /******************************Public*Routine******************************\
  2933. * BOOL MRPIE::bPlay(hdc, pht, cht)
  2934. *
  2935. * Play the metafile record.
  2936. *
  2937. * History:
  2938. * Fri Sep 13 17:54:00 1991 -by- Hock San Lee [hockl]
  2939. * Wrote it.
  2940. \**************************************************************************/
  2941. BOOL MRPIE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2942. {
  2943. PUTS("MRPIE::bPlay\n");
  2944. ASSERTGDI(iType == EMR_PIE, "Bad record type");
  2945. USE(pht);
  2946. USE(cht);
  2947. // erclBox is inclusive-inclusive. Make sure we have set the advanced
  2948. // graphics mode.
  2949. ASSERTGDI
  2950. (
  2951. GetGraphicsMode(hdc) == GM_ADVANCED,
  2952. "MR::bPlay: Not in advanced graphics mode"
  2953. );
  2954. if (!bCheckRecord(pht))
  2955. return(FALSE);
  2956. return
  2957. (
  2958. Pie
  2959. (
  2960. hdc,
  2961. (int) erclBox.left,
  2962. (int) erclBox.top,
  2963. (int) erclBox.right,
  2964. (int) erclBox.bottom,
  2965. (int) eptlStart.x,
  2966. (int) eptlStart.y,
  2967. (int) eptlEnd.x,
  2968. (int) eptlEnd.y
  2969. )
  2970. );
  2971. }
  2972. /******************************Public*Routine******************************\
  2973. * BOOL MRSETPALETTEENTRIES::bPlay(hdc, pht, cht)
  2974. *
  2975. * Play the metafile record.
  2976. *
  2977. * History:
  2978. * Sun Sep 22 16:34:36 1991 -by- Hock San Lee [hockl]
  2979. * Wrote it.
  2980. \**************************************************************************/
  2981. BOOL MRSETPALETTEENTRIES::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  2982. {
  2983. PUTS("MRSETPALETTEENTRIES::bPlay\n");
  2984. ASSERTGDI(iType == EMR_SETPALETTEENTRIES, "Bad record type");
  2985. USE(hdc);
  2986. // Make sure the handle is in the table.
  2987. if (!VALID_IMHE(imhe, cht))
  2988. return(FALSE);
  2989. // If palette creation failed earlier, hpal is 0 and SetPaletteEntries
  2990. // will just return an error.
  2991. if (!bCheckRecord(pht))
  2992. return(FALSE);
  2993. return
  2994. (
  2995. SetPaletteEntries
  2996. (
  2997. (HPALETTE) pht->objectHandle[imhe],
  2998. (UINT) iStart,
  2999. (UINT) cEntries,
  3000. aPalEntry
  3001. )
  3002. != 0
  3003. );
  3004. }
  3005. /******************************Public*Routine******************************\
  3006. * BOOL MRRESIZEPALETTE::bPlay(hdc, pht, cht)
  3007. *
  3008. * Play the metafile record.
  3009. *
  3010. * History:
  3011. * Sun Sep 22 16:34:36 1991 -by- Hock San Lee [hockl]
  3012. * Wrote it.
  3013. \**************************************************************************/
  3014. BOOL MRRESIZEPALETTE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  3015. {
  3016. PUTS("MRRESIZEPALETTE::bPlay\n");
  3017. ASSERTGDI(iType == EMR_RESIZEPALETTE, "Bad record type");
  3018. USE(hdc);
  3019. // Make sure the handle is in the table.
  3020. if (!VALID_IMHE(d1, cht))
  3021. return(FALSE);
  3022. if (!bCheckRecord(pht))
  3023. return(FALSE);
  3024. // If palette creation failed earlier, hpal is 0 and ResizePalette will
  3025. // just return an error.
  3026. return(ResizePalette((HPALETTE) pht->objectHandle[d1], (UINT) d2));
  3027. }
  3028. /******************************Public*Routine******************************\
  3029. * BOOL MRREALIZEPALETTE::bPlay(hdc, pht, cht)
  3030. *
  3031. * Play the metafile record.
  3032. *
  3033. * History:
  3034. * Mon Sep 23 17:41:46 1991 -by- Hock San Lee [hockl]
  3035. * Wrote it.
  3036. \**************************************************************************/
  3037. BOOL MRREALIZEPALETTE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  3038. {
  3039. PUTS("MRREALIZEPALETTE::bPlay\n");
  3040. ASSERTGDI(iType == EMR_REALIZEPALETTE, "Bad record type");
  3041. USE(pht);
  3042. USE(cht);
  3043. if (!bCheckRecord(pht))
  3044. return(FALSE);
  3045. return(RealizePalette(hdc) != -1);
  3046. }
  3047. /******************************Public*Routine******************************\
  3048. * BOOL MREXTFLOODFILL::bPlay(hdc, pht, cht)
  3049. *
  3050. * Play the metafile record.
  3051. *
  3052. * History:
  3053. * Fri Sep 13 17:54:00 1991 -by- Hock San Lee [hockl]
  3054. * Wrote it.
  3055. \**************************************************************************/
  3056. BOOL MREXTFLOODFILL::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  3057. {
  3058. BOOL bRet = FALSE;
  3059. PMF pmf;
  3060. HRGN hrgn = (HRGN) 0;
  3061. POINTL ptlRef;
  3062. PENHMETAHEADER pmrmf = NULL;
  3063. PUTS("MREXTFLOODFILL::bPlay\n");
  3064. ASSERTGDI(iType == EMR_EXTFLOODFILL, "Bad record type");
  3065. USE(cht);
  3066. // Get metafile.
  3067. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  3068. return(FALSE);
  3069. if (!bCheckRecord(pht))
  3070. return(FALSE);
  3071. // Save the DC.
  3072. if (!SaveDC(hdc))
  3073. return(FALSE);
  3074. // We are going to use the picture frame to set up the clipping before
  3075. // flood fill. This is to make sure that the fill will not flood beyond
  3076. // the picture. We first convert the picture frame to the source device
  3077. // coordinates and set up the transform such that the source world to
  3078. // device transform is identity. Then we intersect the picture
  3079. // frame using the IntersecClipRect function. Note that the reference
  3080. // point is also converted to source device coordinates.
  3081. // Convert the reference point to the device units on the source device.
  3082. ptlRef.x = eptl.x;
  3083. ptlRef.y = eptl.y;
  3084. if (!LPtoDP(pmf->hdcXform, (LPPOINT) &ptlRef, 1))
  3085. goto mreff_exit;
  3086. // Reset source transform to identity.
  3087. // We simply set the total transform to the xformBase.
  3088. if (!SetWorldTransform(hdc, &pmf->xformBase))
  3089. goto mreff_exit;
  3090. // Compute the picture frame in the source device coordinates.
  3091. RECTL rclSrc;
  3092. pmrmf = pmf->emfc.GetEMFHeader();
  3093. rclSrc.left = MulDiv((int) pmrmf->rclFrame.left,
  3094. (int) pmrmf->szlDevice.cx,
  3095. (int) (100 * pmrmf->szlMillimeters.cx));
  3096. rclSrc.right = MulDiv((int) pmrmf->rclFrame.right,
  3097. (int) pmrmf->szlDevice.cx,
  3098. (int) (100 * pmrmf->szlMillimeters.cx));
  3099. rclSrc.top = MulDiv((int) pmrmf->rclFrame.top,
  3100. (int) pmrmf->szlDevice.cy,
  3101. (int) (100 * pmrmf->szlMillimeters.cy));
  3102. rclSrc.bottom = MulDiv((int) pmrmf->rclFrame.bottom,
  3103. (int) pmrmf->szlDevice.cy,
  3104. (int) (100 * pmrmf->szlMillimeters.cy));
  3105. // Intersect the clip region with the size of the picture bounds.
  3106. if (IntersectClipRect(hdc,
  3107. (int) rclSrc.left,
  3108. (int) rclSrc.top,
  3109. (int) rclSrc.right + 1,
  3110. (int) rclSrc.bottom + 1)
  3111. == ERROR)
  3112. goto mreff_exit;
  3113. // Finally, do the flood fill.
  3114. bRet = ExtFloodFill(hdc, (int) ptlRef.x, (int) ptlRef.y, clrRef, (UINT) iMode);
  3115. // Clean up.
  3116. mreff_exit:
  3117. if (!RestoreDC(hdc, -1))
  3118. {
  3119. ASSERTGDI(FALSE, "MREXTFLOODFILL::bPlay: RestoreDC failed");
  3120. }
  3121. return(bRet);
  3122. }
  3123. /******************************Public*Routine******************************\
  3124. * BOOL MRBEGINPATH::bPlay(hdc, pht, cht)
  3125. *
  3126. * Play the metafile record.
  3127. *
  3128. * History:
  3129. * Thu Oct 17 17:10:02 1991 -by- Hock San Lee [hockl]
  3130. * Wrote it.
  3131. \**************************************************************************/
  3132. BOOL MRBEGINPATH::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  3133. {
  3134. PUTS("MRBEGINPATH::bPlay\n");
  3135. ASSERTGDI(iType == EMR_BEGINPATH, "Bad record type");
  3136. USE(pht);
  3137. USE(cht);
  3138. if (!bCheckRecord(pht))
  3139. return(FALSE);
  3140. return(BeginPath(hdc));
  3141. }
  3142. /******************************Public*Routine******************************\
  3143. * BOOL MRENDPATH::bPlay(hdc, pht, cht)
  3144. *
  3145. * Play the metafile record.
  3146. *
  3147. * History:
  3148. * Thu Oct 17 17:10:02 1991 -by- Hock San Lee [hockl]
  3149. * Wrote it.
  3150. \**************************************************************************/
  3151. BOOL MRENDPATH::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  3152. {
  3153. PUTS("MRENDPATH::bPlay\n");
  3154. ASSERTGDI(iType == EMR_ENDPATH, "Bad record type");
  3155. USE(pht);
  3156. USE(cht);
  3157. if (!bCheckRecord(pht))
  3158. return(FALSE);
  3159. return(EndPath(hdc));
  3160. }
  3161. /******************************Public*Routine******************************\
  3162. * BOOL MRCLOSEFIGURE::bPlay(hdc, pht, cht)
  3163. *
  3164. * Play the metafile record.
  3165. *
  3166. * History:
  3167. * Thu Oct 17 17:10:02 1991 -by- Hock San Lee [hockl]
  3168. * Wrote it.
  3169. \**************************************************************************/
  3170. BOOL MRCLOSEFIGURE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  3171. {
  3172. PUTS("MRCLOSEFIGURE::bPlay\n");
  3173. ASSERTGDI(iType == EMR_CLOSEFIGURE, "Bad record type");
  3174. USE(pht);
  3175. USE(cht);
  3176. if (!bCheckRecord(pht))
  3177. return(FALSE);
  3178. return(CloseFigure(hdc));
  3179. }
  3180. /******************************Public*Routine******************************\
  3181. * BOOL MRFLATTENPATH::bPlay(hdc, pht, cht)
  3182. *
  3183. * Play the metafile record.
  3184. *
  3185. * History:
  3186. * Thu Oct 17 17:10:02 1991 -by- Hock San Lee [hockl]
  3187. * Wrote it.
  3188. \**************************************************************************/
  3189. BOOL MRFLATTENPATH::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  3190. {
  3191. PUTS("MRFLATTENPATH::bPlay\n");
  3192. ASSERTGDI(iType == EMR_FLATTENPATH, "Bad record type");
  3193. USE(pht);
  3194. USE(cht);
  3195. if (!bCheckRecord(pht))
  3196. return(FALSE);
  3197. return(FlattenPath(hdc));
  3198. }
  3199. /******************************Public*Routine******************************\
  3200. * BOOL MRWIDENPATH::bPlay(hdc, pht, cht)
  3201. *
  3202. * Play the metafile record.
  3203. *
  3204. * History:
  3205. * Thu Oct 17 17:10:02 1991 -by- Hock San Lee [hockl]
  3206. * Wrote it.
  3207. \**************************************************************************/
  3208. BOOL MRWIDENPATH::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  3209. {
  3210. PUTS("MRWIDENPATH::bPlay\n");
  3211. ASSERTGDI(iType == EMR_WIDENPATH, "Bad record type");
  3212. USE(pht);
  3213. USE(cht);
  3214. if (!bCheckRecord(pht))
  3215. return(FALSE);
  3216. return(WidenPath(hdc));
  3217. }
  3218. /******************************Public*Routine******************************\
  3219. * BOOL MRFILLPATH::bPlay(hdc, pht, cht)
  3220. *
  3221. * Play the metafile record.
  3222. *
  3223. * History:
  3224. * Thu Oct 17 17:10:02 1991 -by- Hock San Lee [hockl]
  3225. * Wrote it.
  3226. \**************************************************************************/
  3227. BOOL MRFILLPATH::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  3228. {
  3229. PMF pmf;
  3230. PUTS("MRFILLPATH::bPlay\n");
  3231. ASSERTGDI(iType == EMR_FILLPATH, "Bad record type");
  3232. USE(pht);
  3233. USE(cht);
  3234. if (!bCheckRecord(pht))
  3235. return(FALSE);
  3236. return(FillPath(hdc));
  3237. }
  3238. /******************************Public*Routine******************************\
  3239. * BOOL MRSTROKEANDFILLPATH::bPlay(hdc, pht, cht)
  3240. *
  3241. * Play the metafile record.
  3242. *
  3243. * History:
  3244. * Thu Oct 17 17:10:02 1991 -by- Hock San Lee [hockl]
  3245. * Wrote it.
  3246. \**************************************************************************/
  3247. BOOL MRSTROKEANDFILLPATH::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  3248. {
  3249. PMF pmf;
  3250. PUTS("MRSTROKEANDFILLPATH::bPlay\n");
  3251. ASSERTGDI(iType == EMR_STROKEANDFILLPATH, "Bad record type");
  3252. USE(pht);
  3253. USE(cht);
  3254. if (!bCheckRecord(pht))
  3255. return(FALSE);
  3256. return(StrokeAndFillPath(hdc));
  3257. }
  3258. /******************************Public*Routine******************************\
  3259. * BOOL MRSTROKEPATH::bPlay(hdc, pht, cht)
  3260. *
  3261. * Play the metafile record.
  3262. *
  3263. * History:
  3264. * Thu Oct 17 17:10:02 1991 -by- Hock San Lee [hockl]
  3265. * Wrote it.
  3266. \**************************************************************************/
  3267. BOOL MRSTROKEPATH::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  3268. {
  3269. PMF pmf;
  3270. PUTS("MRSTROKEPATH::bPlay\n");
  3271. ASSERTGDI(iType == EMR_STROKEPATH, "Bad record type");
  3272. USE(pht);
  3273. USE(cht);
  3274. if (!bCheckRecord(pht))
  3275. return(FALSE);
  3276. return(StrokePath(hdc));
  3277. }
  3278. /******************************Public*Routine******************************\
  3279. * BOOL MRSELECTCLIPPATH::bPlay(hdc, pht, cht)
  3280. *
  3281. * Play the metafile record.
  3282. *
  3283. * History:
  3284. * Fri Oct 18 11:33:05 1991 -by- Hock San Lee [hockl]
  3285. * Wrote it.
  3286. \**************************************************************************/
  3287. BOOL MRSELECTCLIPPATH::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  3288. {
  3289. PUTS("MRSELECTCLIPPATH::bPlay\n");
  3290. ASSERTGDI(iType == EMR_SELECTCLIPPATH, "Bad record type");
  3291. USE(pht);
  3292. USE(cht);
  3293. if (!bCheckRecord(pht))
  3294. return(FALSE);
  3295. // Since we have moved the initial destination clip region into the meta
  3296. // region (hrgnMeta), this function should not affect the initial clip region.
  3297. return(SelectClipPath(hdc, (int) d1));
  3298. }
  3299. /******************************Public*Routine******************************\
  3300. * BOOL MRABORTPATH::bPlay(hdc, pht, cht)
  3301. *
  3302. * Play the metafile record.
  3303. *
  3304. * History:
  3305. * Thu Oct 17 17:10:02 1991 -by- Hock San Lee [hockl]
  3306. * Wrote it.
  3307. \**************************************************************************/
  3308. BOOL MRABORTPATH::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  3309. {
  3310. PUTS("MRABORTPATH::bPlay\n");
  3311. ASSERTGDI(iType == EMR_ABORTPATH, "Bad record type");
  3312. USE(pht);
  3313. USE(cht);
  3314. if (!bCheckRecord(pht))
  3315. return(FALSE);
  3316. // This call is recorded in place of PathToRegion in metafiles.
  3317. // See comments in PathToRegion for more information.
  3318. return(AbortPath(hdc));
  3319. }
  3320. /******************************Public*Routine******************************\
  3321. * BOOL MRBITBLT::bPlay(hdc, pht, cht)
  3322. *
  3323. * Play the metafile record.
  3324. *
  3325. * History:
  3326. * Fri Nov 22 18:30:27 1991 -by- Hock San Lee [hockl]
  3327. * Wrote it.
  3328. \**************************************************************************/
  3329. BOOL MRBITBLT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  3330. {
  3331. PMF pmf;
  3332. BOOL bRet = FALSE;
  3333. HBITMAP hbmSrc = (HBITMAP) 0;
  3334. HBITMAP hbmTmp = (HBITMAP) 0;
  3335. HDC hdcSrc = (HDC) 0;
  3336. PUTS("MRBITBLT::bPlay\n");
  3337. ASSERTGDI(iType == EMR_BITBLT, "Bad record type");
  3338. USE(cht);
  3339. // Get metafile.
  3340. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  3341. return(FALSE);
  3342. if (!bCheckRecord(pht))
  3343. return(FALSE);
  3344. // Check bounds.
  3345. if (pmf->bClipped(erclBounds))
  3346. return(TRUE);
  3347. // Handle bitblt with no source DC.
  3348. if (!ISSOURCEINROP3(rop))
  3349. return
  3350. (
  3351. BitBlt
  3352. (
  3353. hdc,
  3354. (int) xDst,
  3355. (int) yDst,
  3356. (int) cxDst,
  3357. (int) cyDst,
  3358. (HDC) 0,
  3359. (int) xSrc,
  3360. (int) ySrc,
  3361. rop
  3362. )
  3363. );
  3364. // Handle bitblt with a source bitmap.
  3365. // Create a compatible source DC.
  3366. if (!(hdcSrc = CreateCompatibleDCAdvanced(hdc)))
  3367. goto mrbb_exit;
  3368. // Create the source bitmap.
  3369. if (!bValidOff(pht, offBitsInfoSrc) || !bValidOff(pht, offBitsSrc))
  3370. {
  3371. EMFVALFAIL(("MRBITBLT::bPlay: bValidOff offBitsInfoSrc = %08x, offBitsSrc = %08x Failed\n", offBitsInfoSrc, offBitsSrc));
  3372. goto mrbb_exit;
  3373. }
  3374. if (!(hbmSrc = CreateDIBitmap
  3375. (
  3376. hdcSrc,
  3377. (LPBITMAPINFOHEADER) ((PBYTE) this + offBitsInfoSrc),
  3378. CBM_INIT | CBM_CREATEDIB,
  3379. (LPBYTE) ((PBYTE) this + offBitsSrc),
  3380. (LPBITMAPINFO) ((PBYTE) this + offBitsInfoSrc),
  3381. (UINT) iUsageSrc
  3382. )
  3383. )
  3384. )
  3385. goto mrbb_exit;
  3386. // Select the bitmap.
  3387. if (!(hbmTmp = (HBITMAP)SelectObject(hdcSrc, hbmSrc)))
  3388. goto mrbb_exit;
  3389. // Set up source DC transform and background color.
  3390. if (!SetWorldTransform(hdcSrc, &xformSrc))
  3391. goto mrbb_exit;
  3392. if (SetBkColor(hdcSrc, clrBkSrc) == CLR_INVALID)
  3393. goto mrbb_exit;
  3394. // Do the blt.
  3395. bRet = BitBlt
  3396. (
  3397. hdc,
  3398. (int) xDst,
  3399. (int) yDst,
  3400. (int) cxDst,
  3401. (int) cyDst,
  3402. hdcSrc,
  3403. (int) xSrc,
  3404. (int) ySrc,
  3405. rop
  3406. );
  3407. mrbb_exit:
  3408. if (hbmTmp)
  3409. {
  3410. if (!SelectObject(hdcSrc, hbmTmp))
  3411. {
  3412. ASSERTGDI(FALSE, "MRBITBLT::bPlay: SelectObject failed");
  3413. }
  3414. }
  3415. if (hbmSrc)
  3416. {
  3417. if (!DeleteObject(hbmSrc))
  3418. {
  3419. ASSERTGDI(FALSE, "MRBITBLT::bPlay: DeleteObject failed");
  3420. }
  3421. }
  3422. if (hdcSrc)
  3423. {
  3424. if (!DeleteDC(hdcSrc))
  3425. {
  3426. ASSERTGDI(FALSE, "MRBITBLT::bPlay: DeleteDC failed");
  3427. }
  3428. }
  3429. return(bRet);
  3430. }
  3431. /******************************Public*Routine******************************\
  3432. * BOOL MRSTRETCHBLT::bPlay(hdc, pht, cht)
  3433. *
  3434. * Play the metafile record.
  3435. *
  3436. * History:
  3437. * Fri Nov 22 18:30:27 1991 -by- Hock San Lee [hockl]
  3438. * Wrote it.
  3439. \**************************************************************************/
  3440. BOOL MRSTRETCHBLT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  3441. {
  3442. PMF pmf;
  3443. BOOL bRet = FALSE;
  3444. HBITMAP hbmSrc = (HBITMAP) 0;
  3445. HBITMAP hbmTmp = (HBITMAP) 0;
  3446. HDC hdcSrc = (HDC) 0;
  3447. PUTS("MRSTRETCHBLT::bPlay\n");
  3448. ASSERTGDI(iType == EMR_STRETCHBLT, "Bad record type");
  3449. USE(cht);
  3450. // Get metafile.
  3451. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  3452. return(FALSE);
  3453. if (!bCheckRecord(pht))
  3454. return(FALSE);
  3455. // Check bounds.
  3456. if (pmf->bClipped(erclBounds))
  3457. return(TRUE);
  3458. // Handle stretchblt with no source DC.
  3459. if (!ISSOURCEINROP3(rop))
  3460. return
  3461. (
  3462. StretchBlt
  3463. (
  3464. hdc,
  3465. (int) xDst,
  3466. (int) yDst,
  3467. (int) cxDst,
  3468. (int) cyDst,
  3469. (HDC) 0,
  3470. (int) xSrc,
  3471. (int) ySrc,
  3472. (int) cxSrc,
  3473. (int) cySrc,
  3474. rop
  3475. )
  3476. );
  3477. // Handle stretchblt with a source bitmap.
  3478. // Create a compatible source DC.
  3479. if (!(hdcSrc = CreateCompatibleDCAdvanced(hdc)))
  3480. goto mrsb_exit;
  3481. if (!bValidOff(pht, offBitsInfoSrc) || !bValidOff(pht, offBitsSrc))
  3482. {
  3483. EMFVALFAIL(("MRSTRCHBLT::bPlay: bValidOff offBitsInfoSrc = %08x, offBitsSrc = %08x Failed\n", offBitsInfoSrc, offBitsSrc));
  3484. goto mrsb_exit;
  3485. }
  3486. // Create the source bitmap.
  3487. if (!(hbmSrc = CreateDIBitmap
  3488. (
  3489. hdcSrc,
  3490. (LPBITMAPINFOHEADER) ((PBYTE) this + offBitsInfoSrc),
  3491. CBM_INIT | CBM_CREATEDIB,
  3492. (LPBYTE) ((PBYTE) this + offBitsSrc),
  3493. (LPBITMAPINFO) ((PBYTE) this + offBitsInfoSrc),
  3494. (UINT) iUsageSrc
  3495. )
  3496. )
  3497. )
  3498. goto mrsb_exit;
  3499. // Select the bitmap.
  3500. if (!(hbmTmp = (HBITMAP)SelectObject(hdcSrc, hbmSrc)))
  3501. goto mrsb_exit;
  3502. // Set up source DC transform and background color.
  3503. if (!SetWorldTransform(hdcSrc, &xformSrc))
  3504. goto mrsb_exit;
  3505. if (SetBkColor(hdcSrc, clrBkSrc) == CLR_INVALID)
  3506. goto mrsb_exit;
  3507. // Do the blt.
  3508. bRet = StretchBlt
  3509. (
  3510. hdc,
  3511. (int) xDst,
  3512. (int) yDst,
  3513. (int) cxDst,
  3514. (int) cyDst,
  3515. hdcSrc,
  3516. (int) xSrc,
  3517. (int) ySrc,
  3518. (int) cxSrc,
  3519. (int) cySrc,
  3520. rop
  3521. );
  3522. mrsb_exit:
  3523. if (hbmTmp)
  3524. {
  3525. if (!SelectObject(hdcSrc, hbmTmp))
  3526. {
  3527. ASSERTGDI(FALSE, "MRSTRETCHBLT::bPlay: SelectObject failed");
  3528. }
  3529. }
  3530. if (hbmSrc)
  3531. {
  3532. if (!DeleteObject(hbmSrc))
  3533. {
  3534. ASSERTGDI(FALSE, "MRSTRETCHBLT::bPlay: DeleteObject failed");
  3535. }
  3536. }
  3537. if (hdcSrc)
  3538. {
  3539. if (!DeleteDC(hdcSrc))
  3540. {
  3541. ASSERTGDI(FALSE, "MRSTRETCHBLT::bPlay: DeleteDC failed");
  3542. }
  3543. }
  3544. return(bRet);
  3545. }
  3546. /******************************Public*Routine******************************\
  3547. * BOOL MRALPHABLEND::bPlay(hdc, pht, cht)
  3548. *
  3549. * Play the metafile record.
  3550. *
  3551. * History:
  3552. *
  3553. * 12/3/1996 Mark Enstrom [marke]
  3554. *
  3555. \**************************************************************************/
  3556. BOOL MRALPHABLEND::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  3557. {
  3558. PMF pmf;
  3559. BOOL bRet = FALSE;
  3560. HBITMAP hbmSrc = (HBITMAP) 0;
  3561. HBITMAP hbmTmp = (HBITMAP) 0;
  3562. HDC hdcSrc = (HDC) 0;
  3563. PUTS("MRALPHABLEND::bPlay\n");
  3564. ASSERTGDI(iType == EMR_ALPHABLEND, "Bad record type");
  3565. USE(cht);
  3566. // Get metafile.
  3567. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  3568. return(FALSE);
  3569. if (!bCheckRecord(pht))
  3570. return(FALSE);
  3571. // Check bounds.
  3572. if (pmf->bClipped(erclBounds))
  3573. return(TRUE);
  3574. // Create a compatible source DC.
  3575. if (!(hdcSrc = CreateCompatibleDCAdvanced(hdc)))
  3576. goto mrai_exit;
  3577. if (!bValidOff(pht, offBitsInfoSrc) || !bValidOff(pht, offBitsSrc))
  3578. {
  3579. EMFVALFAIL(("MRALPHABLEND::bPlay: bValidOff offBitsInfoSrc = %08x, offBitsSrc = %08x Failed\n", offBitsInfoSrc, offBitsSrc));
  3580. goto mrai_exit;
  3581. }
  3582. // Create the source bitmap.
  3583. if (!(hbmSrc = CreateDIBitmap
  3584. (
  3585. hdcSrc,
  3586. (LPBITMAPINFOHEADER) ((PBYTE) this + offBitsInfoSrc),
  3587. CBM_INIT | CBM_CREATEDIB,
  3588. (LPBYTE) ((PBYTE) this + offBitsSrc),
  3589. (LPBITMAPINFO) ((PBYTE) this + offBitsInfoSrc),
  3590. (UINT) iUsageSrc
  3591. )
  3592. )
  3593. )
  3594. goto mrai_exit;
  3595. // Select the bitmap.
  3596. if (!(hbmTmp = (HBITMAP)SelectObject(hdcSrc, hbmSrc)))
  3597. goto mrai_exit;
  3598. // Set up source DC transform and background color.
  3599. if (!SetWorldTransform(hdcSrc, &xformSrc))
  3600. goto mrai_exit;
  3601. if (SetBkColor(hdcSrc, clrBkSrc) == CLR_INVALID)
  3602. goto mrai_exit;
  3603. // Do the blt.
  3604. BLENDULONG Blend;
  3605. Blend.ul = rop;
  3606. bRet = GdiAlphaBlend
  3607. (
  3608. hdc,
  3609. (int) xDst,
  3610. (int) yDst,
  3611. (int) cxDst,
  3612. (int) cyDst,
  3613. hdcSrc,
  3614. (int) xSrc,
  3615. (int) ySrc,
  3616. (int) cxSrc,
  3617. (int) cySrc,
  3618. Blend.Blend
  3619. );
  3620. mrai_exit:
  3621. if (hbmTmp)
  3622. {
  3623. if (!SelectObject(hdcSrc, hbmTmp))
  3624. {
  3625. ASSERTGDI(FALSE, "MRALPHABLEND::bPlay: SelectObject failed");
  3626. }
  3627. }
  3628. if (hbmSrc)
  3629. {
  3630. if (!DeleteObject(hbmSrc))
  3631. {
  3632. ASSERTGDI(FALSE, "MRALPHABLEND::bPlay: DeleteObject failed");
  3633. }
  3634. }
  3635. if (hdcSrc)
  3636. {
  3637. if (!DeleteDC(hdcSrc))
  3638. {
  3639. ASSERTGDI(FALSE, "MRALPHABLEND::bPlay: DeleteDC failed");
  3640. }
  3641. }
  3642. return(bRet);
  3643. }
  3644. /******************************Public*Routine******************************\
  3645. * BOOL MRTRANSPARENTIMAGE::bPlay(hdc, pht, cht)
  3646. *
  3647. * Play the metafile record.
  3648. *
  3649. * History:
  3650. *
  3651. * 12/3/1996 Mark Enstrom [marke]
  3652. *
  3653. \**************************************************************************/
  3654. BOOL MRTRANSPARENTBLT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  3655. {
  3656. PMF pmf;
  3657. BOOL bRet = FALSE;
  3658. HBITMAP hbmSrc = (HBITMAP) 0;
  3659. HBITMAP hbmTmp = (HBITMAP) 0;
  3660. HDC hdcSrc = (HDC) 0;
  3661. PUTS("MRTRANSPARENTBLT::bPlay\n");
  3662. ASSERTGDI(iType == EMR_TRANSPARENTBLT, "Bad record type");
  3663. USE(cht);
  3664. // Get metafile.
  3665. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  3666. return(FALSE);
  3667. if (!bCheckRecord(pht))
  3668. return(FALSE);
  3669. // Check bounds.
  3670. if (pmf->bClipped(erclBounds))
  3671. return(TRUE);
  3672. // Create a compatible source DC.
  3673. if (!(hdcSrc = CreateCompatibleDCAdvanced(hdc)))
  3674. goto mrti_exit;
  3675. if (!bValidOff(pht, offBitsInfoSrc) || !bValidOff(pht, offBitsSrc))
  3676. {
  3677. EMFVALFAIL(("MRTRANSPARENTBLT::bPlay: bValidOff offBitsInfoSrc = %08x, offBitsSrc = %08x Failed\n", offBitsInfoSrc, offBitsSrc));
  3678. goto mrti_exit;
  3679. }
  3680. // Create the source bitmap.
  3681. if (!(hbmSrc = CreateDIBitmap
  3682. (
  3683. hdcSrc,
  3684. (LPBITMAPINFOHEADER) ((PBYTE) this + offBitsInfoSrc),
  3685. CBM_INIT | CBM_CREATEDIB,
  3686. (LPBYTE) ((PBYTE) this + offBitsSrc),
  3687. (LPBITMAPINFO) ((PBYTE) this + offBitsInfoSrc),
  3688. (UINT) iUsageSrc
  3689. )
  3690. )
  3691. )
  3692. goto mrti_exit;
  3693. // Select the bitmap.
  3694. if (!(hbmTmp = (HBITMAP)SelectObject(hdcSrc, hbmSrc)))
  3695. goto mrti_exit;
  3696. // Set up source DC transform and background color.
  3697. if (!SetWorldTransform(hdcSrc, &xformSrc))
  3698. goto mrti_exit;
  3699. if (SetBkColor(hdcSrc, clrBkSrc) == CLR_INVALID)
  3700. goto mrti_exit;
  3701. // Do the blt.
  3702. bRet = GdiTransparentBlt
  3703. (
  3704. hdc,
  3705. (int) xDst,
  3706. (int) yDst,
  3707. (int) cxDst,
  3708. (int) cyDst,
  3709. hdcSrc,
  3710. (int) xSrc,
  3711. (int) ySrc,
  3712. (int) cxSrc,
  3713. (int) cySrc,
  3714. rop //color
  3715. );
  3716. mrti_exit:
  3717. if (hbmTmp)
  3718. {
  3719. if (!SelectObject(hdcSrc, hbmTmp))
  3720. {
  3721. ASSERTGDI(FALSE, "MRSTRETCHBLT::bPlay: SelectObject failed");
  3722. }
  3723. }
  3724. if (hbmSrc)
  3725. {
  3726. if (!DeleteObject(hbmSrc))
  3727. {
  3728. ASSERTGDI(FALSE, "MRSTRETCHBLT::bPlay: DeleteObject failed");
  3729. }
  3730. }
  3731. if (hdcSrc)
  3732. {
  3733. if (!DeleteDC(hdcSrc))
  3734. {
  3735. ASSERTGDI(FALSE, "MRSTRETCHBLT::bPlay: DeleteDC failed");
  3736. }
  3737. }
  3738. return(bRet);
  3739. }
  3740. /******************************Public*Routine******************************\
  3741. * BOOL MRMASKBLT::bPlay(hdc, pht, cht)
  3742. *
  3743. * Play the metafile record.
  3744. *
  3745. * History:
  3746. * Fri Nov 22 18:30:27 1991 -by- Hock San Lee [hockl]
  3747. * Wrote it.
  3748. \**************************************************************************/
  3749. BOOL MRMASKBLT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  3750. {
  3751. PMF pmf;
  3752. BOOL bRet = FALSE;
  3753. HBITMAP hbmSrc = (HBITMAP) 0;
  3754. HBITMAP hbmTmp = (HBITMAP) 0;
  3755. HBITMAP hbmMask = (HBITMAP) 0;
  3756. HDC hdcSrc = (HDC) 0;
  3757. PUTS("MRMASKBLT::bPlay\n");
  3758. ASSERTGDI(iType == EMR_MASKBLT, "Bad record type");
  3759. USE(cht);
  3760. // Get metafile.
  3761. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  3762. return(FALSE);
  3763. if (!bCheckRecord(pht))
  3764. return(FALSE);
  3765. // Check bounds.
  3766. if (pmf->bClipped(erclBounds))
  3767. return(TRUE);
  3768. // Create the mask bitmap if it exists.
  3769. if (cbBitsInfoMask)
  3770. {
  3771. if (!bValidOff(pht, offBitsInfoMask) || !bValidOff(pht, offBitsMask))
  3772. {
  3773. EMFVALFAIL(("MRMASKBLT::bPlay: bValidOff offBitsInfoMask = %08x, offBitsMask = %08x Failed\n", offBitsInfoMask, offBitsMask));
  3774. return(FALSE);
  3775. }
  3776. if (!(hbmMask = CreateMonoDib
  3777. (
  3778. (LPBITMAPINFO) ((PBYTE) this + offBitsInfoMask),
  3779. (CONST BYTE *) ((PBYTE) this + offBitsMask),
  3780. (UINT) iUsageMask
  3781. )
  3782. )
  3783. )
  3784. return(FALSE);
  3785. }
  3786. // Create a compatible source DC. This is needed even if the rop does not
  3787. // require a source.
  3788. if (!(hdcSrc = CreateCompatibleDCAdvanced(hdc)))
  3789. goto mrmb_exit;
  3790. // Set up source DC transform.
  3791. if (!SetWorldTransform(hdcSrc, &xformSrc))
  3792. goto mrmb_exit;
  3793. // Handle maskblt with no source bitmap.
  3794. if (!ISSOURCEINROP3(rop))
  3795. {
  3796. bRet = MaskBlt
  3797. (
  3798. hdc,
  3799. (int) xDst,
  3800. (int) yDst,
  3801. (int) cxDst,
  3802. (int) cyDst,
  3803. (HDC) hdcSrc,
  3804. (int) xSrc,
  3805. (int) ySrc,
  3806. hbmMask,
  3807. (int) xMask,
  3808. (int) yMask,
  3809. rop
  3810. );
  3811. goto mrmb_exit;
  3812. }
  3813. if (!bValidOff(pht, offBitsInfoSrc) || !bValidOff(pht, offBitsSrc))
  3814. {
  3815. EMFVALFAIL(("MRMASKBLT::bPlay: bValidOff offBitsInfoSrc = %08x, offBitsSrc = %08x Failed\n", offBitsInfoSrc, offBitsSrc));
  3816. goto mrmb_exit;
  3817. }
  3818. // Handle maskblt with a source bitmap.
  3819. // Create the source bitmap.
  3820. if (!(hbmSrc = CreateDIBitmap
  3821. (
  3822. hdcSrc,
  3823. (LPBITMAPINFOHEADER) ((PBYTE) this + offBitsInfoSrc),
  3824. CBM_INIT | CBM_CREATEDIB,
  3825. (LPBYTE) ((PBYTE) this + offBitsSrc),
  3826. (LPBITMAPINFO) ((PBYTE) this + offBitsInfoSrc),
  3827. (UINT) iUsageSrc
  3828. )
  3829. )
  3830. )
  3831. goto mrmb_exit;
  3832. // Select the bitmap.
  3833. if (!(hbmTmp = (HBITMAP)SelectObject(hdcSrc, hbmSrc)))
  3834. goto mrmb_exit;
  3835. // Set up source DC background color.
  3836. if (SetBkColor(hdcSrc, clrBkSrc) == CLR_INVALID)
  3837. goto mrmb_exit;
  3838. // Do the blt.
  3839. bRet = MaskBlt
  3840. (
  3841. hdc,
  3842. (int) xDst,
  3843. (int) yDst,
  3844. (int) cxDst,
  3845. (int) cyDst,
  3846. hdcSrc,
  3847. (int) xSrc,
  3848. (int) ySrc,
  3849. hbmMask,
  3850. (int) xMask,
  3851. (int) yMask,
  3852. rop
  3853. );
  3854. mrmb_exit:
  3855. if (hbmTmp)
  3856. {
  3857. if (!SelectObject(hdcSrc, hbmTmp))
  3858. {
  3859. ASSERTGDI(FALSE, "MRMASKBLT::bPlay: SelectObject failed");
  3860. }
  3861. }
  3862. if (hbmSrc)
  3863. {
  3864. if (!DeleteObject(hbmSrc))
  3865. {
  3866. ASSERTGDI(FALSE, "MRMASKBLT::bPlay: DeleteObject failed");
  3867. }
  3868. }
  3869. if (hdcSrc)
  3870. {
  3871. if (!DeleteDC(hdcSrc))
  3872. {
  3873. ASSERTGDI(FALSE, "MRMASKBLT::bPlay: DeleteDC failed");
  3874. }
  3875. }
  3876. if (hbmMask)
  3877. {
  3878. if (!DeleteObject(hbmMask))
  3879. {
  3880. ASSERTGDI(FALSE, "MRMASKBLT::bPlay: DeleteObject failed");
  3881. }
  3882. }
  3883. return(bRet);
  3884. }
  3885. /******************************Public*Routine******************************\
  3886. * BOOL MRPLGBLT::bPlay(hdc, pht, cht)
  3887. *
  3888. * Play the metafile record.
  3889. *
  3890. * History:
  3891. * Fri Nov 22 18:30:27 1991 -by- Hock San Lee [hockl]
  3892. * Wrote it.
  3893. \**************************************************************************/
  3894. BOOL MRPLGBLT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  3895. {
  3896. PMF pmf;
  3897. BOOL bRet = FALSE;
  3898. HBITMAP hbmSrc = (HBITMAP) 0;
  3899. HBITMAP hbmTmp = (HBITMAP) 0;
  3900. HBITMAP hbmMask = (HBITMAP) 0;
  3901. HDC hdcSrc = (HDC) 0;
  3902. PUTS("MRPLGBLT::bPlay\n");
  3903. ASSERTGDI(iType == EMR_PLGBLT, "Bad record type");
  3904. USE(cht);
  3905. // There must be a source DC in this call
  3906. // Get metafile.
  3907. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  3908. return(FALSE);
  3909. if (!bCheckRecord(pht))
  3910. return(FALSE);
  3911. // Check bounds.
  3912. if (pmf->bClipped(erclBounds))
  3913. return(TRUE);
  3914. // Create the mask bitmap if it exists.
  3915. if (cbBitsInfoMask)
  3916. {
  3917. if (!bValidOff(pht, offBitsInfoMask) || !bValidOff(pht, offBitsMask))
  3918. {
  3919. EMFVALFAIL(("MRPLGBLT::bPlay: bValidOff offBitsInfoMask = %08x, offBitsMask = %08x Failed\n", offBitsInfoMask, offBitsMask));
  3920. return(FALSE);
  3921. }
  3922. if (!(hbmMask = CreateMonoDib
  3923. (
  3924. (LPBITMAPINFO) ((PBYTE) this + offBitsInfoMask),
  3925. (CONST BYTE *) ((PBYTE) this + offBitsMask),
  3926. (UINT) iUsageMask
  3927. )
  3928. )
  3929. )
  3930. return(FALSE);
  3931. }
  3932. // Handle plgblt with a source bitmap.
  3933. // Create a compatible source DC.
  3934. if (!(hdcSrc = CreateCompatibleDCAdvanced(hdc)))
  3935. goto mrpb_exit;
  3936. if (!bValidOff(pht, offBitsInfoSrc) || !bValidOff(pht, offBitsSrc))
  3937. {
  3938. EMFVALFAIL(("MRPLGBLT::bPlay: bValidOff offBitsInfoSrc = %08x, offBitsSrc = %08x Failed\n", offBitsInfoSrc, offBitsSrc));
  3939. goto mrpb_exit;
  3940. }
  3941. // Create the source bitmap.
  3942. if (!(hbmSrc = CreateDIBitmap
  3943. (
  3944. hdcSrc,
  3945. (LPBITMAPINFOHEADER) ((PBYTE) this + offBitsInfoSrc),
  3946. CBM_INIT | CBM_CREATEDIB,
  3947. (LPBYTE) ((PBYTE) this + offBitsSrc),
  3948. (LPBITMAPINFO) ((PBYTE) this + offBitsInfoSrc),
  3949. (UINT) iUsageSrc
  3950. )
  3951. )
  3952. )
  3953. goto mrpb_exit;
  3954. // Select the bitmap.
  3955. if (!(hbmTmp = (HBITMAP)SelectObject(hdcSrc, hbmSrc)))
  3956. goto mrpb_exit;
  3957. // Set up source DC transform and background color.
  3958. if (!SetWorldTransform(hdcSrc, &xformSrc))
  3959. goto mrpb_exit;
  3960. if (SetBkColor(hdcSrc, clrBkSrc) == CLR_INVALID)
  3961. goto mrpb_exit;
  3962. // Do the blt.
  3963. bRet = PlgBlt
  3964. (
  3965. hdc,
  3966. (LPPOINT) aptlDst,
  3967. hdcSrc,
  3968. (int) xSrc,
  3969. (int) ySrc,
  3970. (int) cxSrc,
  3971. (int) cySrc,
  3972. hbmMask,
  3973. (int) xMask,
  3974. (int) yMask
  3975. );
  3976. mrpb_exit:
  3977. if (hbmTmp)
  3978. {
  3979. if (!SelectObject(hdcSrc, hbmTmp))
  3980. {
  3981. ASSERTGDI(FALSE, "MRPLGBLT::bPlay: SelectObject failed");
  3982. }
  3983. }
  3984. if (hbmSrc)
  3985. {
  3986. if (!DeleteObject(hbmSrc))
  3987. {
  3988. ASSERTGDI(FALSE, "MRPLGBLT::bPlay: DeleteObject failed");
  3989. }
  3990. }
  3991. if (hdcSrc)
  3992. {
  3993. if (!DeleteDC(hdcSrc))
  3994. {
  3995. ASSERTGDI(FALSE, "MRPLGBLT::bPlay: DeleteDC failed");
  3996. }
  3997. }
  3998. if (hbmMask)
  3999. {
  4000. if (!DeleteObject(hbmMask))
  4001. {
  4002. ASSERTGDI(FALSE, "MRPLGBLT::bPlay: DeleteObject failed");
  4003. }
  4004. }
  4005. return(bRet);
  4006. }
  4007. /******************************Public*Routine******************************\
  4008. * BOOL MRSETDIBITSTODEVICE::bPlay(hdc, pht, cht)
  4009. *
  4010. * Play the metafile record.
  4011. *
  4012. * History:
  4013. * Fri Nov 22 18:30:27 1991 -by- Hock San Lee [hockl]
  4014. * Wrote it.
  4015. \**************************************************************************/
  4016. BOOL MRSETDIBITSTODEVICE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  4017. {
  4018. PMF pmf;
  4019. BOOL bRet = FALSE;
  4020. POINT ptDst;
  4021. PBMI pBitsInfoDib;
  4022. PUTS("MRSETDIBITSTODEVICE::bPlay\n");
  4023. ASSERTGDI(iType == EMR_SETDIBITSTODEVICE, "Bad record type");
  4024. USE(cht);
  4025. // Get metafile.
  4026. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  4027. return(FALSE);
  4028. if (!bCheckRecord(pht))
  4029. return(FALSE);
  4030. // Check bounds.
  4031. if (pmf->bClipped(erclBounds))
  4032. return(TRUE);
  4033. // Do the simple case where xformBase is identity
  4034. // Since there may be a non identity xformBase, we cannot simply
  4035. // call SetDIBitsToDevice directly. Instead, we will convert it to a
  4036. // StretchDIBits call. There is one catch here: in SetDIBitsToDevice,
  4037. // the destination width and height are in device units but in StretchDIBits,
  4038. // they are in world units. We have to replace the original transform
  4039. // in the metafile with a identity transform before calling StretchDIBits.
  4040. // Convert the destination origin to the device units on the original device.
  4041. ptDst.x = (long) xDst;
  4042. ptDst.y = (long) yDst;
  4043. if (!LPtoDP(pmf->hdcXform, &ptDst, 1))
  4044. return(FALSE);
  4045. // Reset original destination transform to identity.
  4046. // We simply set the total transform to the xformBase.
  4047. if (!SetWorldTransform(hdc, &pmf->xformBase))
  4048. return(FALSE);
  4049. // Check arithmetic overflow and Validate offsets
  4050. if (!bValidOffExt(pht, offBitsInfoDib, cbBitsInfoDib))
  4051. {
  4052. EMFVALFAIL(("MRSETDIBITSTODEVICE::bPlay: bValidOffExt offBitsInfoDib = %08x cbBitsInfoDib = %08x Failed\n", offBitsInfoDib, cbBitsInfoDib));
  4053. return(FALSE);
  4054. }
  4055. // Since StretchDIBits takes a full dib, we have to adjust the source dib info.
  4056. if (!(pBitsInfoDib = (PBMI) LocalAlloc(LMEM_FIXED, (UINT) cbBitsInfoDib)))
  4057. goto mrsdb_exit;
  4058. RtlCopyMemory((PBYTE) pBitsInfoDib, (PBYTE) this + offBitsInfoDib, cbBitsInfoDib);
  4059. if (pBitsInfoDib->bmiHeader.biHeight > 0)
  4060. {
  4061. pBitsInfoDib->bmiHeader.biHeight = cScans;
  4062. }
  4063. else
  4064. {
  4065. // top-down
  4066. pBitsInfoDib->bmiHeader.biHeight = cScans;
  4067. pBitsInfoDib->bmiHeader.biHeight = -pBitsInfoDib->bmiHeader.biHeight;
  4068. }
  4069. pBitsInfoDib->bmiHeader.biSizeImage = cbBitsDib;
  4070. if (cbBitsDib)
  4071. {
  4072. if (!bValidOffExt(pht, offBitsDib, cbBitsDib))
  4073. {
  4074. EMFVALFAIL(("MRSETDIBITSTODEVICE::bPlay: bValidOffExt offBitsDib = %08x cbBitsDib = %08x,\n",offBitsDib, cbBitsDib));
  4075. goto mrsdb_exit;
  4076. }
  4077. }
  4078. // Do the blt.
  4079. bRet = StretchDIBits
  4080. (
  4081. hdc,
  4082. (int) ptDst.x,
  4083. (int) ptDst.y,
  4084. (int) cxDib,
  4085. (int) cyDib,
  4086. (int) xDib,
  4087. (int) yDib - (int) iStartScan,
  4088. (int) cxDib,
  4089. (int) cyDib,
  4090. cbBitsDib
  4091. ? (LPBYTE) ((PBYTE) this + offBitsDib)
  4092. : (LPBYTE) NULL,
  4093. pBitsInfoDib,
  4094. (UINT) iUsageDib,
  4095. SRCCOPY
  4096. ) != 0;
  4097. if (LocalFree(pBitsInfoDib))
  4098. {
  4099. ASSERTGDI(FALSE, "MRSETDIBITSTODEVICE::bPlay: LocalFree failed");
  4100. }
  4101. mrsdb_exit:
  4102. // Restore current transform.
  4103. if (!pmf->bSetTransform(hdc))
  4104. {
  4105. WARNING("MRSETDIBITSTODEVICE::bPlay: Restore xform failed");
  4106. }
  4107. return(bRet);
  4108. }
  4109. /******************************Public*Routine******************************\
  4110. * BOOL MRSTRETCHDIBITS::bPlay(hdc, pht, cht)
  4111. *
  4112. * Play the metafile record.
  4113. *
  4114. * History:
  4115. * Fri Nov 22 18:30:27 1991 -by- Hock San Lee [hockl]
  4116. * Wrote it.
  4117. \**************************************************************************/
  4118. BOOL MRSTRETCHDIBITS::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  4119. {
  4120. PMF pmf;
  4121. PUTS("MRSTRETCHDIBITS::bPlay\n");
  4122. ASSERTGDI(iType == EMR_STRETCHDIBITS, "Bad record type");
  4123. USE(cht);
  4124. // Get metafile.
  4125. if (!(pmf = GET_PMF((HENHMETAFILE)pht->objectHandle[0])))
  4126. return(FALSE);
  4127. if (!bCheckRecord(pht))
  4128. return(FALSE);
  4129. // Check bounds.
  4130. if (pmf->bClipped(erclBounds))
  4131. return(TRUE);
  4132. if (cbBitsDib)
  4133. {
  4134. if (!bValidOffExt(pht, offBitsDib, cbBitsDib))
  4135. {
  4136. EMFVALFAIL(("MESTRETCHDIBITS::bPlay: bValidOffExt offBitsDib = %08x, cbBitsDib = %08x Failed\n", offBitsDib, cbBitsDib));
  4137. return(FALSE);
  4138. }
  4139. }
  4140. if (cbBitsInfoDib)
  4141. {
  4142. if (!bValidOffExt(pht, offBitsInfoDib, cbBitsInfoDib))
  4143. {
  4144. EMFVALFAIL(("MESTRETCHDIBITS::bPlay: bValidOffExt offBitsInfoDib = %08x cbBitsInfoDib = %08x Failed\n", offBitsInfoDib, cbBitsInfoDib));
  4145. return(FALSE);
  4146. }
  4147. }
  4148. // Do the blt.
  4149. return
  4150. (
  4151. StretchDIBits
  4152. (
  4153. hdc,
  4154. (int) xDst,
  4155. (int) yDst,
  4156. (int) cxDst,
  4157. (int) cyDst,
  4158. (int) xDib,
  4159. (int) yDib,
  4160. (int) cxDib,
  4161. (int) cyDib,
  4162. cbBitsDib
  4163. ? (LPBYTE) ((PBYTE) this + offBitsDib)
  4164. : (LPBYTE) NULL,
  4165. cbBitsInfoDib
  4166. ? (LPBITMAPINFO) ((PBYTE) this + offBitsInfoDib)
  4167. : (LPBITMAPINFO) NULL,
  4168. (UINT) iUsageDib,
  4169. rop
  4170. ) != 0
  4171. );
  4172. }
  4173. /******************************Public*Routine******************************\
  4174. * BOOL MREXTTEXTOUT::bPlay(hdc, pht, cht)
  4175. *
  4176. * Play the metafile record.
  4177. *
  4178. * History:
  4179. * Thu Aug 24 15:20:33 1992 -by- Hock San Lee [hockl]
  4180. * Wrote it.
  4181. \**************************************************************************/
  4182. BOOL MREXTTEXTOUT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  4183. {
  4184. BOOL bRet;
  4185. PUTS("MREXTTEXTOUT::bPlay\n");
  4186. ASSERTGDI(iType == EMR_EXTTEXTOUTA || iType == EMR_EXTTEXTOUTW,
  4187. "Bad record type");
  4188. USE(pht);
  4189. USE(cht);
  4190. if (!bCheckRecord(pht))
  4191. return(FALSE);
  4192. if (mtext.cchString && (
  4193. !bValidOff(pht, mtext.offString) ||
  4194. !bValidOff(pht, mtext.offaDx)))
  4195. {
  4196. EMFVALFAIL(("MREXTTEXTOUT::bPlay: bValidOff mtext.offString = %08x, mtext.offaDx = %08x Failed\n", mtext.offString, mtext.offaDx));
  4197. return(FALSE);
  4198. }
  4199. // Set the graphics mode if necessary.
  4200. // The metafile playback is always in the advanced graphics mode.
  4201. if (iGraphicsMode != GM_ADVANCED)
  4202. {
  4203. if (!SetGraphicsMode(hdc, iGraphicsMode))
  4204. return(FALSE);
  4205. if (!SetFontXform(hdc, exScale, eyScale))
  4206. return(FALSE);
  4207. }
  4208. if (iType == EMR_EXTTEXTOUTA)
  4209. bRet = ExtTextOutA
  4210. (
  4211. hdc,
  4212. (int) mtext.eptlRef.x,
  4213. (int) mtext.eptlRef.y,
  4214. (UINT) mtext.fOptions,
  4215. (LPRECT) &mtext.ercl,
  4216. (LPSTR) ((PBYTE) this + mtext.offString),
  4217. (int) mtext.cchString,
  4218. (LPINT) (mtext.offaDx ? ((PBYTE) this + mtext.offaDx) : 0)
  4219. );
  4220. else
  4221. bRet = ExtTextOutW
  4222. (
  4223. hdc,
  4224. (int) mtext.eptlRef.x,
  4225. (int) mtext.eptlRef.y,
  4226. (UINT) mtext.fOptions,
  4227. (LPRECT) &mtext.ercl,
  4228. (LPWSTR) ((PBYTE) this + mtext.offString),
  4229. (int) mtext.cchString,
  4230. (LPINT) (mtext.offaDx ? ((PBYTE) this + mtext.offaDx) : 0)
  4231. );
  4232. // Restore the graphics mode.
  4233. if (iGraphicsMode != GM_ADVANCED)
  4234. {
  4235. if (!SetGraphicsMode(hdc, GM_ADVANCED))
  4236. return(FALSE);
  4237. if (!SetFontXform(hdc, 0.0f, 0.0f))
  4238. return(FALSE);
  4239. }
  4240. return(bRet);
  4241. }
  4242. /******************************Public*Routine******************************\
  4243. * BOOL MRPOLYTEXTOUT::bPlay(hdc, pht, cht)
  4244. *
  4245. * Play the metafile record.
  4246. *
  4247. * History:
  4248. * Thu Aug 24 15:20:33 1992 -by- Hock San Lee [hockl]
  4249. * Wrote it.
  4250. \**************************************************************************/
  4251. BOOL MRPOLYTEXTOUT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  4252. {
  4253. POLYTEXTA * ppta;
  4254. BOOL bRet = FALSE;
  4255. LONG i;
  4256. PUTS("MRPOLYTEXTOUT::bPlay\n");
  4257. ASSERTGDI(iType == EMR_POLYTEXTOUTA || iType == EMR_POLYTEXTOUTW,
  4258. "Bad record type");
  4259. USE(pht);
  4260. USE(cht);
  4261. if (!bCheckRecord(pht))
  4262. return(FALSE);
  4263. // Set the graphics mode if necessary.
  4264. // The metafile playback is always in the advanced graphics mode.
  4265. if (iGraphicsMode != GM_ADVANCED)
  4266. {
  4267. if (!SetGraphicsMode(hdc, (int) iGraphicsMode))
  4268. return(FALSE);
  4269. if (!SetFontXform(hdc, exScale, eyScale))
  4270. return(FALSE);
  4271. }
  4272. // Allocate a POLYTEXTA array.
  4273. if (!(ppta = (POLYTEXTA *) LocalAlloc(LMEM_FIXED, (UINT) cmtext * sizeof(POLYTEXTA))))
  4274. goto mpto_exit;
  4275. // Copy the POLYTEXTA array.
  4276. ASSERTGDI(sizeof(MTEXT) == sizeof(POLYTEXTA)
  4277. && offsetof(MTEXT,eptlRef.x) == offsetof(POLYTEXTA,x)
  4278. && offsetof(MTEXT,eptlRef.y) == offsetof(POLYTEXTA,y)
  4279. && offsetof(MTEXT,cchString) == offsetof(POLYTEXTA,n)
  4280. && offsetof(MTEXT,offString) == offsetof(POLYTEXTA,lpstr)
  4281. && offsetof(MTEXT,fOptions) == offsetof(POLYTEXTA,uiFlags)
  4282. && offsetof(MTEXT,ercl) == offsetof(POLYTEXTA,rcl)
  4283. && offsetof(MTEXT,offaDx) == offsetof(POLYTEXTA,pdx),
  4284. "MRPOLYTEXTOUT::bPlay: structures different");
  4285. RtlCopyMemory((PBYTE) ppta, (PBYTE) &amtext[0], cmtext * sizeof(POLYTEXTA));
  4286. // Update the pointers.
  4287. for (i = 0; i < cmtext; i++)
  4288. {
  4289. if (!bValidOff(pht, amtext[i].offString) || !bValidOff(pht, amtext[i].offaDx))
  4290. {
  4291. EMFVALFAIL(("MRPOLYTEXTOUT::bPlay() amtext[%d].offString = %08x amtext[%d].offaDx = %08x\n", i, amtext[i].offString, i , amtext[i].offaDx));
  4292. goto mpto_free_and_exit;
  4293. }
  4294. ppta[i].lpstr = (PCSTR) ((PBYTE) this + amtext[i].offString);
  4295. ppta[i].pdx = (int *) ((PBYTE) this + amtext[i].offaDx);
  4296. }
  4297. // Make the call.
  4298. if (iType == EMR_POLYTEXTOUTA)
  4299. bRet = PolyTextOutA(hdc, ppta, (int) cmtext);
  4300. else
  4301. bRet = PolyTextOutW(hdc, (POLYTEXTW *) ppta, (int) cmtext);
  4302. mpto_free_and_exit:
  4303. if (LocalFree((HANDLE) ppta))
  4304. {
  4305. ASSERTGDI(FALSE, "MRPOLYTEXTOUT::bPlay: LocalFree failed");
  4306. }
  4307. mpto_exit:
  4308. // Restore the graphics mode.
  4309. if (iGraphicsMode != GM_ADVANCED)
  4310. {
  4311. if (!SetGraphicsMode(hdc, GM_ADVANCED))
  4312. return(FALSE);
  4313. if (!SetFontXform(hdc, 0.0f, 0.0f))
  4314. return(FALSE);
  4315. }
  4316. return(bRet);
  4317. }
  4318. /******************************Public*Routine******************************\
  4319. * BOOL MRSETCOLORADJUSTMENT::bPlay(hdc, pht, cht)
  4320. *
  4321. * Play the metafile record.
  4322. *
  4323. * History:
  4324. * Tue Oct 27 09:59:28 1992 -by- Hock San Lee [hockl]
  4325. * Wrote it.
  4326. \**************************************************************************/
  4327. BOOL MRSETCOLORADJUSTMENT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  4328. {
  4329. PUTS("MRSETCOLORADJUSTMENT::bPlay\n");
  4330. ASSERTGDI(iType == EMR_SETCOLORADJUSTMENT, "Bad record type");
  4331. USE(pht);
  4332. USE(cht);
  4333. if (!bCheckRecord(pht))
  4334. return(FALSE);
  4335. return(SetColorAdjustment(hdc, &ColorAdjustment));
  4336. }
  4337. BOOL MRESCAPE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  4338. {
  4339. if (!bCheckRecord(pht))
  4340. return(FALSE);
  4341. switch( iType )
  4342. {
  4343. case EMR_DRAWESCAPE:
  4344. // MFD2("Playing Meta DrawEscape %d\n", iEscape);
  4345. DrawEscape( hdc, iEscape, cjIn, (const char*) ((PBYTE) this + sizeof(MRESCAPE)) );
  4346. break;
  4347. case EMR_EXTESCAPE:
  4348. // MFD2("Playing Meta ExtEscape %d\n", iEscape);
  4349. ExtEscape( hdc, iEscape, cjIn,
  4350. (const char*) ((PBYTE) this + sizeof(MRESCAPE)), 0,
  4351. (LPSTR) NULL );
  4352. break;
  4353. default:
  4354. ASSERTGDI((FALSE), "MRESCAPE::bPlay invalid type\n");
  4355. break;
  4356. }
  4357. USE(pht);
  4358. USE(cht);
  4359. return(TRUE);
  4360. }
  4361. BOOL MRNAMEDESCAPE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  4362. {
  4363. if (!bCheckRecord(pht))
  4364. return(FALSE);
  4365. NamedEscape(hdc,
  4366. (LPWSTR) ((PBYTE) this + sizeof(MRNAMEDESCAPE)),
  4367. iEscape,
  4368. cjIn,
  4369. (const char*) (PBYTE) this + sizeof(MRNAMEDESCAPE) + cjDriver,
  4370. 0,
  4371. NULL);
  4372. USE(pht);
  4373. USE(cht);
  4374. return(TRUE);
  4375. }
  4376. BOOL MRSTARTDOC::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  4377. {
  4378. PBYTE pj = (PBYTE) this+sizeof(MRSTARTDOC);
  4379. PBYTE pjEnd = (PBYTE) this + nSize;
  4380. ASSERTGDI(iType == EMR_STARTDOC, "Bad record type");
  4381. DOCINFOW doi1;
  4382. // nothing for now
  4383. USE(pht);
  4384. USE(cht);
  4385. if (!bCheckRecord(pht))
  4386. return(FALSE);
  4387. *(&doi1) = *(&doi);
  4388. if( doi1.lpszDocName != NULL )
  4389. {
  4390. doi1.lpszDocName = (LPWSTR) pj;
  4391. SIZE_T len;
  4392. if(FAILED(StringCbLengthW((CONST WCHAR*)pj,(SIZE_T)(pjEnd-pj),(size_t*)&len)))
  4393. {
  4394. EMFVALFAIL(("MRSTARTDOC::bPlay StringCbLenth failed\n"));
  4395. return(FALSE);
  4396. }
  4397. len = ((len+1)* sizeof(WCHAR) + 4) & ~(0x3);
  4398. if (!bValidOff(pht,(DWORD)len))
  4399. {
  4400. EMFVALFAIL(("MRSTARTDOC::bPlay bValidOff(%08x) failed\n", len));
  4401. return(FALSE);
  4402. }
  4403. pj += len;
  4404. }
  4405. if( doi1.lpszOutput != NULL )
  4406. {
  4407. doi1.lpszOutput = (LPWSTR) pj;
  4408. }
  4409. MFD3("Playing StartDocA %s %s\n", doi1.lpszDocName, doi1.lpszOutput);
  4410. return( StartDocW( hdc, &doi1 ) );
  4411. }
  4412. #define QUICK_BUF_SIZE 120
  4413. BOOL MRSMALLTEXTOUT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  4414. {
  4415. RECT *pRect = NULL;
  4416. BYTE *pjThis = (PBYTE) this + sizeof(MRSMALLTEXTOUT);
  4417. WCHAR wcQuickBuf[QUICK_BUF_SIZE],*pwc;
  4418. BOOL bRet;
  4419. if (!bCheckRecord(pht))
  4420. return(FALSE);
  4421. if (iGraphicsMode != GM_ADVANCED)
  4422. {
  4423. if (!SetGraphicsMode(hdc, iGraphicsMode))
  4424. return(FALSE);
  4425. if (!SetFontXform(hdc, exScale, eyScale))
  4426. return(FALSE);
  4427. }
  4428. if( !(fuOptions & ETO_NO_RECT) )
  4429. {
  4430. pRect = (RECT*) pjThis;
  4431. pjThis += sizeof(RECT);
  4432. }
  4433. if( fuOptions & ETO_SMALL_CHARS )
  4434. {
  4435. INT c;
  4436. WCHAR *pwc1;
  4437. if( cChars > QUICK_BUF_SIZE )
  4438. {
  4439. pwc = (WCHAR*) LocalAlloc( LMEM_FIXED, sizeof(WCHAR) * cChars );
  4440. if( pwc == NULL )
  4441. {
  4442. WARNING("MRSMALLTEXTOUT::bPlay -- out of memory\n" );
  4443. return(FALSE);
  4444. }
  4445. }
  4446. else
  4447. {
  4448. pwc = wcQuickBuf;
  4449. }
  4450. for( pwc1 = pwc, c = cChars; c > 0 ; c-- )
  4451. {
  4452. *pwc1++ = (WCHAR) *pjThis++;
  4453. }
  4454. }
  4455. else
  4456. {
  4457. pwc = (WCHAR*) pjThis;
  4458. }
  4459. bRet = ExtTextOutW( hdc,
  4460. x,
  4461. y,
  4462. fuOptions & ~(ETO_NO_RECT|ETO_SMALL_CHARS),
  4463. pRect,
  4464. pwc,
  4465. cChars,
  4466. NULL );
  4467. if( (pwc != wcQuickBuf ) && ( pwc != (WCHAR*) pjThis ) )
  4468. {
  4469. LocalFree( pwc );
  4470. }
  4471. if(iGraphicsMode != GM_ADVANCED)
  4472. {
  4473. if (!SetGraphicsMode(hdc, GM_ADVANCED))
  4474. return(FALSE);
  4475. if (!SetFontXform(hdc, 0.0f, 0.0f))
  4476. return(FALSE);
  4477. }
  4478. return(bRet);
  4479. }
  4480. BOOL MRFORCEUFIMAPPING::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  4481. {
  4482. ASSERTGDI(iType == EMR_FORCEUFIMAPPING, "Bad record type");
  4483. // nothing for now
  4484. USE(pht);
  4485. USE(cht);
  4486. MFD1("Playing ForceUFIMapping\n");
  4487. if (!bCheckRecord(pht))
  4488. return(FALSE);
  4489. return NtGdiForceUFIMapping(hdc, &ufi);
  4490. }
  4491. BOOL MRSETLINKEDUFIS::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  4492. {
  4493. ASSERTGDI(iType == EMR_SETLINKEDUFIS, "Bad record type");
  4494. // nothing for now
  4495. USE(pht);
  4496. USE(cht);
  4497. MFD1("Playing SetLinkedUFIs\n");
  4498. if (!bCheckRecord(pht))
  4499. return(FALSE);
  4500. return(NtGdiSetLinkedUFIs(hdc, pufiList, uNumLinkedUFIs));
  4501. }
  4502. /******************************Public*Routine******************************\
  4503. *
  4504. * MRGLSRECORD::bPlay(hdc, pht, cht)
  4505. *
  4506. * Play the metafile record
  4507. *
  4508. * History:
  4509. * Thu Feb 23 14:41:41 1995 -by- Drew Bliss [drewb]
  4510. * Created
  4511. *
  4512. \**************************************************************************/
  4513. BOOL MRGLSRECORD::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  4514. {
  4515. PUTS("MRGLSRECORD::bPlay\n");
  4516. ASSERTGDI(iType == EMR_GLSRECORD, "Bad record type");
  4517. USE(pht);
  4518. USE(cht);
  4519. if (!bCheckRecord(pht))
  4520. return(FALSE);
  4521. return GlmfPlayGlsRecord(hdc, cb, abRecord, NULL);
  4522. }
  4523. /******************************Public*Routine******************************\
  4524. *
  4525. * MRGLSBOUNDEDRECORD::bPlay(hdc, pht, cht)
  4526. *
  4527. * Play the metafile record
  4528. *
  4529. * History:
  4530. * Thu Feb 23 14:41:41 1995 -by- Drew Bliss [drewb]
  4531. * Created
  4532. *
  4533. \**************************************************************************/
  4534. BOOL MRGLSBOUNDEDRECORD::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  4535. {
  4536. PUTS("MRGLSBOUNDEDRECORD::bPlay\n");
  4537. ASSERTGDI(iType == EMR_GLSBOUNDEDRECORD, "Bad record type");
  4538. USE(pht);
  4539. USE(cht);
  4540. if (!bCheckRecord(pht))
  4541. return(FALSE);
  4542. return GlmfPlayGlsRecord(hdc, cb, abRecord, &rclBounds);
  4543. }
  4544. /******************************Public*Routine******************************\
  4545. *
  4546. * MRPIXELFORMAT::bPlay(hdc, pht, cht)
  4547. *
  4548. * Play the metafile record
  4549. *
  4550. * History:
  4551. * Mon Mar 27 14:41:41 1995 -by- Drew Bliss [drewb]
  4552. * Created
  4553. *
  4554. \**************************************************************************/
  4555. BOOL MRPIXELFORMAT::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  4556. {
  4557. int iPixelFormat;
  4558. PUTS("MRPIXELFORMAT::bPlay\n");
  4559. ASSERTGDI(iType == EMR_PIXELFORMAT, "Bad record type");
  4560. USE(pht);
  4561. USE(cht);
  4562. if (!bCheckRecord(pht))
  4563. return(FALSE);
  4564. iPixelFormat = ChoosePixelFormat(hdc, &pfd);
  4565. if (iPixelFormat == 0)
  4566. {
  4567. return FALSE;
  4568. }
  4569. else
  4570. {
  4571. // Ignore errors from this call because the metafile player
  4572. // may have already set up a pixel format and it can't
  4573. // be set twice
  4574. //
  4575. // The check alone isn't sufficient because of race conditions,
  4576. // it just cuts down on debug messages from OpenGL warning
  4577. // about duplicate sets
  4578. if (GetPixelFormat(hdc) == 0)
  4579. {
  4580. SetPixelFormat(hdc, iPixelFormat, &pfd);
  4581. }
  4582. return TRUE;
  4583. }
  4584. }
  4585. /******************************Public*Routine******************************\
  4586. *
  4587. * MRSETICMPROFILE::bPlay(hdc, pht, cht)
  4588. *
  4589. * Play the metafile record
  4590. *
  4591. * History:
  4592. * Wed May 07 17:38:00 1997 -by- Hideyuki Nagase [hideyukn]
  4593. * Created
  4594. *
  4595. \**************************************************************************/
  4596. BOOL MRSETICMPROFILE::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  4597. {
  4598. PUTS("MRSETICMPROFILE::bPlay\n");
  4599. ASSERTGDI((iType == EMR_SETICMPROFILEA) || (iType == EMR_SETICMPROFILEW),
  4600. "Bad record type");
  4601. USE(pht);
  4602. USE(cht);
  4603. if (!bCheckRecord(pht))
  4604. return(FALSE);
  4605. BOOL bRet = FALSE;
  4606. PCACHED_COLORSPACE pCachedColorSpace;
  4607. if (dwFlags & SETICMPROFILE_EMBEDED)
  4608. {
  4609. LOGCOLORSPACEW LogColorSpaceW;
  4610. PROFILE Profile;
  4611. //
  4612. // ICC Profile is attched into Metafile,
  4613. //
  4614. RtlZeroMemory(&LogColorSpaceW,sizeof(LOGCOLORSPACEW));
  4615. //
  4616. // Build fake LOGCOLORSPACEW for this color space.
  4617. //
  4618. LogColorSpaceW.lcsSignature = LCS_SIGNATURE;
  4619. LogColorSpaceW.lcsVersion = 0x400;
  4620. LogColorSpaceW.lcsSize = sizeof(LOGCOLORSPACEW);
  4621. LogColorSpaceW.lcsCSType = LCS_CALIBRATED_RGB;
  4622. LogColorSpaceW.lcsIntent = LCS_DEFAULT_INTENT;
  4623. if (iType == EMR_SETICMPROFILEW)
  4624. {
  4625. //
  4626. // Copy desired filename in Unicode.
  4627. //
  4628. BuildIcmProfilePath((WCHAR *)Data,LogColorSpaceW.lcsFilename,MAX_PATH);
  4629. }
  4630. else
  4631. {
  4632. WCHAR TempFile[MAX_PATH];
  4633. //
  4634. // Data is ansi based string, Convert the string to Unicode.
  4635. //
  4636. vToUnicodeN(TempFile,MAX_PATH,(char *)Data,strlen((char *)Data)+1);
  4637. //
  4638. // Copy desired filename in Unicode.
  4639. //
  4640. BuildIcmProfilePath(TempFile,LogColorSpaceW.lcsFilename,MAX_PATH);
  4641. }
  4642. //
  4643. // Make PROFILE structure pointing color profile in metafile.
  4644. //
  4645. Profile.dwType = PROFILE_MEMBUFFER;
  4646. Profile.pProfileData = Data+cbName;
  4647. Profile.cbDataSize = cbData;
  4648. //
  4649. // Search this color space from cache.
  4650. //
  4651. pCachedColorSpace = IcmGetColorSpaceByColorSpace(
  4652. hdc, &LogColorSpaceW, &Profile,
  4653. (METAFILE_COLORSPACE | ON_MEMORY_PROFILE));
  4654. if (pCachedColorSpace == NULL)
  4655. {
  4656. pCachedColorSpace = IcmCreateColorSpaceByColorSpace(
  4657. hdc, &LogColorSpaceW, &Profile,
  4658. (METAFILE_COLORSPACE | ON_MEMORY_PROFILE));
  4659. }
  4660. if (pCachedColorSpace)
  4661. {
  4662. bRet = SetICMProfileInternalW(hdc,NULL,pCachedColorSpace,0);
  4663. // - if bRet is TRUE.
  4664. //
  4665. // SetICMProfileInternal increments ref. count of colorspace.
  4666. // but we have done it by Icm[Get|Create]ColorSpaceByName, so
  4667. // decrement ref count of color space here.
  4668. //
  4669. // - if bRet is FALSE.
  4670. //
  4671. // we failed to select to this color space to target, so we should
  4672. // decrement ref count which done by Icm[Get|Create]ColorSpace
  4673. //
  4674. IcmReleaseColorSpace(NULL,pCachedColorSpace,FALSE);
  4675. }
  4676. }
  4677. else
  4678. {
  4679. //
  4680. // The record only has profile filename in Data.
  4681. //
  4682. if (iType == EMR_SETICMPROFILEA)
  4683. {
  4684. bRet = SetICMProfileInternalA(hdc,(LPSTR)Data,NULL,METAFILE_COLORSPACE);
  4685. }
  4686. else
  4687. {
  4688. bRet = SetICMProfileInternalW(hdc,(LPWSTR)Data,NULL,METAFILE_COLORSPACE);
  4689. }
  4690. }
  4691. return bRet;
  4692. }
  4693. /******************************Public*Routine******************************\
  4694. *
  4695. * MRCOLORMATCHTOTARGET::bPlay(hdc, pht, cht)
  4696. *
  4697. * Play the metafile record
  4698. *
  4699. * History:
  4700. * Wed Jun 23 12:00:00 1998 -by- Hideyuki Nagase [hideyukn]
  4701. * Created
  4702. *
  4703. \**************************************************************************/
  4704. BOOL MRCOLORMATCHTOTARGET::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  4705. {
  4706. PUTS("MRCOLORMATCHTOTARGET::bPlay\n");
  4707. ASSERTGDI(iType == EMR_COLORMATCHTOTARGETW,"Bad record type");
  4708. USE(pht);
  4709. USE(cht);
  4710. if (!bCheckRecord(pht))
  4711. return(FALSE);
  4712. BOOL bRet = TRUE;
  4713. if (dwAction == CS_ENABLE)
  4714. {
  4715. PCACHED_COLORSPACE pCachedColorSpace;
  4716. if (dwFlags & COLORMATCHTOTARGET_EMBEDED)
  4717. {
  4718. LOGCOLORSPACEW LogColorSpaceW;
  4719. PROFILE Profile;
  4720. //
  4721. // ICC Profile is attched into Metafile,
  4722. //
  4723. RtlZeroMemory(&LogColorSpaceW,sizeof(LOGCOLORSPACEW));
  4724. //
  4725. // Build fake LOGCOLORSPACEW for this color space.
  4726. //
  4727. LogColorSpaceW.lcsSignature = LCS_SIGNATURE;
  4728. LogColorSpaceW.lcsVersion = 0x400;
  4729. LogColorSpaceW.lcsSize = sizeof(LOGCOLORSPACEW);
  4730. LogColorSpaceW.lcsCSType = LCS_CALIBRATED_RGB;
  4731. LogColorSpaceW.lcsIntent = LCS_DEFAULT_INTENT;
  4732. //
  4733. // Copy desired filename in Unicode.
  4734. //
  4735. BuildIcmProfilePath((WCHAR *)Data,LogColorSpaceW.lcsFilename,MAX_PATH);
  4736. //
  4737. // Make PROFILE structure pointing color profile in metafile.
  4738. //
  4739. Profile.dwType = PROFILE_MEMBUFFER;
  4740. Profile.pProfileData = Data+cbName;
  4741. Profile.cbDataSize = cbData;
  4742. //
  4743. // Search this color space from cache.
  4744. //
  4745. pCachedColorSpace = IcmGetColorSpaceByColorSpace(
  4746. hdc, &LogColorSpaceW, &Profile,
  4747. (METAFILE_COLORSPACE | ON_MEMORY_PROFILE));
  4748. if (pCachedColorSpace == NULL)
  4749. {
  4750. pCachedColorSpace = IcmCreateColorSpaceByColorSpace(
  4751. hdc, &LogColorSpaceW, &Profile,
  4752. (METAFILE_COLORSPACE | ON_MEMORY_PROFILE));
  4753. }
  4754. }
  4755. else
  4756. {
  4757. //
  4758. // The record only has profile filename in Data.
  4759. //
  4760. pCachedColorSpace = IcmGetColorSpaceByName(
  4761. hdc,(LPWSTR)Data,
  4762. LCS_DEFAULT_INTENT,
  4763. METAFILE_COLORSPACE);
  4764. if (pCachedColorSpace == NULL)
  4765. {
  4766. pCachedColorSpace = IcmCreateColorSpaceByName(
  4767. hdc,(LPWSTR)Data,
  4768. LCS_DEFAULT_INTENT,
  4769. METAFILE_COLORSPACE);
  4770. }
  4771. }
  4772. if (pCachedColorSpace)
  4773. {
  4774. bRet = ColorMatchToTargetInternal(hdc,pCachedColorSpace,dwAction);
  4775. // - if bRet is TRUE.
  4776. //
  4777. // ColorMatchToTargetInternal increments ref. count of colorspace.
  4778. // but we have done it by Icm[Get|Create]ColorSpaceByName, so
  4779. // decrement ref count of color space here.
  4780. //
  4781. // - if bRet is FALSE.
  4782. //
  4783. // we failed to select to this color space to target, so we should
  4784. // decrement ref count which done by Icm[Get|Create]ColorSpace
  4785. //
  4786. IcmReleaseColorSpace(NULL,pCachedColorSpace,FALSE);
  4787. }
  4788. }
  4789. else
  4790. {
  4791. //
  4792. // Reset Target color space
  4793. //
  4794. bRet = ColorMatchToTargetInternal(hdc,NULL,dwAction);
  4795. }
  4796. return bRet;
  4797. }
  4798. /******************************Public*Routine******************************\
  4799. *
  4800. * MRCREATECOLORSPACEW::bPlay(hdc, pht, cht)
  4801. *
  4802. * Play the metafile record
  4803. *
  4804. * History:
  4805. * Wed Jun 23 12:00:00 1998 -by- Hideyuki Nagase [hideyukn]
  4806. * Created
  4807. *
  4808. \**************************************************************************/
  4809. BOOL MRCREATECOLORSPACEW::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  4810. {
  4811. PUTS("MRCREATECOLORSPACEW::bPlay\n");
  4812. ASSERTGDI(iType == EMR_CREATECOLORSPACEW, "Bad record type");
  4813. USE(hdc);
  4814. if (!bCheckRecord(pht))
  4815. return(FALSE);
  4816. // Make sure the handle is in the table.
  4817. if (!VALID_IMHE(imhe, cht))
  4818. return(FALSE);
  4819. pht->objectHandle[imhe] = CreateColorSpaceW(&lcsp);
  4820. return(pht->objectHandle[imhe] != 0);
  4821. }
  4822. /****************************Public*Routine**************************\
  4823. *
  4824. * MRSETTEXTJUSTIFICATION::bPlay(hdc, pht, cht)
  4825. *
  4826. * Play the metafile record of SetTextJustification
  4827. *
  4828. * History:
  4829. * 07-May-1997 -by- Xudong Wu [Tessiew]
  4830. * Wrote it.
  4831. \*********************************************************************/
  4832. BOOL MRSETTEXTJUSTIFICATION::bPlay(HDC hdc, PHANDLETABLE pht, UINT cht)
  4833. {
  4834. PUTS("MRSETTEXTJUSTIFICATION::bPlay\n");
  4835. ASSERTGDI(iType == EMR_SETTEXTJUSTIFICATION, "MRSETTEXTJUSTIFICATION Bad record type\n");
  4836. USE(pht);
  4837. USE(cht);
  4838. if (!bCheckRecord(pht))
  4839. return(FALSE);
  4840. return (SetTextJustification(hdc, (int)d1, (int)d2));
  4841. }