Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

GdiplusMetafile.h 12 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374
  1. /**************************************************************************\
  2. *
  3. * Copyright (c) 1998-2000, Microsoft Corp. All Rights Reserved.
  4. *
  5. * Module Name:
  6. *
  7. * GdiplusMetafile.h
  8. *
  9. * Abstract:
  10. *
  11. * Metafile related declarations
  12. *
  13. \**************************************************************************/
  14. #ifndef _GDIPLUSMETAFILE_H
  15. #define _GDIPLUSMETAFILE_H
  16. class Metafile : public Image
  17. {
  18. public:
  19. friend class Image;
  20. // Read a metafile
  21. Metafile()
  22. {
  23. SetNativeImage(NULL);
  24. lastResult = Ok;
  25. }
  26. // Playback a metafile from a HMETAFILE
  27. // If deleteWmf is TRUE, then when the metafile is deleted,
  28. // the hWmf will also be deleted. Otherwise, it won't be.
  29. Metafile(IN HMETAFILE hWmf,
  30. IN const APMFileHeader * apmFileHeader,
  31. IN BOOL deleteWmf = FALSE)
  32. {
  33. GpMetafile * metafile = NULL;
  34. lastResult = DllExports::GdipCreateMetafileFromWmf(hWmf, deleteWmf, apmFileHeader, &metafile);
  35. SetNativeImage(metafile);
  36. }
  37. // Playback a metafile from a HENHMETAFILE
  38. // If deleteEmf is TRUE, then when the metafile is deleted,
  39. // the hEmf will also be deleted. Otherwise, it won't be.
  40. Metafile(IN HENHMETAFILE hEmf,
  41. IN BOOL deleteEmf = FALSE)
  42. {
  43. GpMetafile * metafile = NULL;
  44. lastResult = DllExports::GdipCreateMetafileFromEmf(hEmf, deleteEmf, &metafile);
  45. SetNativeImage(metafile);
  46. }
  47. // Playback a metafile from a file
  48. Metafile(IN const WCHAR* filename)
  49. {
  50. GpMetafile * metafile = NULL;
  51. lastResult = DllExports::GdipCreateMetafileFromFile(filename, &metafile);
  52. SetNativeImage(metafile);
  53. }
  54. // Playback a WMF metafile from a file
  55. Metafile(IN const WCHAR* filename,
  56. IN const APMFileHeader * apmFileHeader
  57. )
  58. {
  59. GpMetafile * metafile = NULL;
  60. lastResult = DllExports::GdipCreateMetafileFromWmfFile(filename, apmFileHeader, &metafile);
  61. SetNativeImage(metafile);
  62. }
  63. // Playback a metafile from a stream
  64. Metafile(IN IStream* stream)
  65. {
  66. GpMetafile * metafile = NULL;
  67. lastResult = DllExports::GdipCreateMetafileFromStream(stream, &metafile);
  68. SetNativeImage(metafile);
  69. }
  70. // Record a metafile to memory
  71. Metafile(
  72. IN HDC referenceHdc,
  73. IN EmfType type = EmfTypeEmfPlusDual,
  74. IN const WCHAR * description = NULL
  75. )
  76. {
  77. GpMetafile * metafile = NULL;
  78. lastResult = DllExports::GdipRecordMetafile(
  79. referenceHdc, type, NULL, MetafileFrameUnitGdi,
  80. description, &metafile);
  81. SetNativeImage(metafile);
  82. }
  83. // Record a metafile to memory
  84. Metafile(
  85. IN HDC referenceHdc,
  86. IN const RectF & frameRect,
  87. IN MetafileFrameUnit frameUnit = MetafileFrameUnitGdi,
  88. IN EmfType type = EmfTypeEmfPlusDual,
  89. IN const WCHAR * description = NULL
  90. )
  91. {
  92. GpMetafile * metafile = NULL;
  93. lastResult = DllExports::GdipRecordMetafile(
  94. referenceHdc, type, &frameRect, frameUnit,
  95. description, &metafile);
  96. SetNativeImage(metafile);
  97. }
  98. // Record a metafile to memory
  99. Metafile(
  100. IN HDC referenceHdc,
  101. IN const Rect & frameRect,
  102. IN MetafileFrameUnit frameUnit = MetafileFrameUnitGdi,
  103. IN EmfType type = EmfTypeEmfPlusDual,
  104. IN const WCHAR * description = NULL
  105. )
  106. {
  107. GpMetafile * metafile = NULL;
  108. lastResult = DllExports::GdipRecordMetafileI(
  109. referenceHdc, type, &frameRect, frameUnit,
  110. description, &metafile);
  111. SetNativeImage(metafile);
  112. }
  113. // Record a metafile to a file
  114. Metafile(
  115. IN const WCHAR* fileName,
  116. IN HDC referenceHdc,
  117. IN EmfType type = EmfTypeEmfPlusDual,
  118. IN const WCHAR * description = NULL
  119. )
  120. {
  121. GpMetafile * metafile = NULL;
  122. lastResult = DllExports::GdipRecordMetafileFileName(fileName,
  123. referenceHdc, type, NULL, MetafileFrameUnitGdi,
  124. description, &metafile);
  125. SetNativeImage(metafile);
  126. }
  127. // Record a metafile to a file
  128. Metafile(
  129. IN const WCHAR* fileName,
  130. IN HDC referenceHdc,
  131. IN const RectF & frameRect,
  132. IN MetafileFrameUnit frameUnit = MetafileFrameUnitGdi,
  133. IN EmfType type = EmfTypeEmfPlusDual,
  134. IN const WCHAR * description = NULL
  135. )
  136. {
  137. GpMetafile * metafile = NULL;
  138. lastResult = DllExports::GdipRecordMetafileFileName(fileName,
  139. referenceHdc, type, &frameRect, frameUnit,
  140. description, &metafile);
  141. SetNativeImage(metafile);
  142. }
  143. // Record a metafile to a file
  144. Metafile(
  145. IN const WCHAR* fileName,
  146. IN HDC referenceHdc,
  147. IN const Rect & frameRect,
  148. IN MetafileFrameUnit frameUnit = MetafileFrameUnitGdi,
  149. IN EmfType type = EmfTypeEmfPlusDual,
  150. IN const WCHAR * description = NULL
  151. )
  152. {
  153. GpMetafile * metafile = NULL;
  154. lastResult = DllExports::GdipRecordMetafileFileNameI(fileName,
  155. referenceHdc, type, &frameRect, frameUnit,
  156. description, &metafile);
  157. SetNativeImage(metafile);
  158. }
  159. // Record a metafile to a stream
  160. Metafile(
  161. IN IStream * stream,
  162. IN HDC referenceHdc,
  163. IN EmfType type = EmfTypeEmfPlusDual,
  164. IN const WCHAR * description = NULL
  165. )
  166. {
  167. GpMetafile * metafile = NULL;
  168. lastResult = DllExports::GdipRecordMetafileStream(stream,
  169. referenceHdc, type, NULL, MetafileFrameUnitGdi,
  170. description, &metafile);
  171. SetNativeImage(metafile);
  172. }
  173. // Record a metafile to a stream
  174. Metafile(
  175. IN IStream * stream,
  176. IN HDC referenceHdc,
  177. IN const RectF & frameRect,
  178. IN MetafileFrameUnit frameUnit = MetafileFrameUnitGdi,
  179. IN EmfType type = EmfTypeEmfPlusDual,
  180. IN const WCHAR * description = NULL
  181. )
  182. {
  183. GpMetafile * metafile = NULL;
  184. lastResult = DllExports::GdipRecordMetafileStream(stream,
  185. referenceHdc, type, &frameRect, frameUnit,
  186. description, &metafile);
  187. SetNativeImage(metafile);
  188. }
  189. // Write a metafile to a stream with down-level GDI records
  190. Metafile(
  191. IN IStream * stream,
  192. IN HDC referenceHdc,
  193. IN const Rect & frameRect,
  194. IN MetafileFrameUnit frameUnit = MetafileFrameUnitGdi,
  195. IN EmfType type = EmfTypeEmfPlusDual,
  196. IN const WCHAR * description = NULL
  197. )
  198. {
  199. GpMetafile * metafile = NULL;
  200. lastResult = DllExports::GdipRecordMetafileStreamI(stream,
  201. referenceHdc, type, &frameRect, frameUnit,
  202. description, &metafile);
  203. SetNativeImage(metafile);
  204. }
  205. static Status GetMetafileHeader(
  206. IN HMETAFILE hWmf,
  207. IN const APMFileHeader * apmFileHeader,
  208. OUT MetafileHeader * header
  209. )
  210. {
  211. return DllExports::GdipGetMetafileHeaderFromWmf(hWmf, apmFileHeader, header);
  212. }
  213. static Status GetMetafileHeader(
  214. IN HENHMETAFILE hEmf,
  215. OUT MetafileHeader * header
  216. )
  217. {
  218. return DllExports::GdipGetMetafileHeaderFromEmf(hEmf, header);
  219. }
  220. static Status GetMetafileHeader(
  221. IN const WCHAR* filename,
  222. OUT MetafileHeader * header
  223. )
  224. {
  225. return DllExports::GdipGetMetafileHeaderFromFile(filename, header);
  226. }
  227. static Status GetMetafileHeader(
  228. IN IStream * stream,
  229. OUT MetafileHeader * header
  230. )
  231. {
  232. return DllExports::GdipGetMetafileHeaderFromStream(stream, header);
  233. }
  234. Status GetMetafileHeader(
  235. OUT MetafileHeader * header
  236. ) const
  237. {
  238. return SetStatus(DllExports::GdipGetMetafileHeaderFromMetafile(
  239. (GpMetafile *)nativeImage,
  240. header));
  241. }
  242. // Once this method is called, the Metafile object is in an invalid state
  243. // and can no longer be used. It is the responsiblity of the caller to
  244. // invoke DeleteEnhMetaFile to delete this hEmf.
  245. HENHMETAFILE GetHENHMETAFILE()
  246. {
  247. HENHMETAFILE hEmf;
  248. SetStatus(DllExports::GdipGetHemfFromMetafile((GpMetafile *)nativeImage, &hEmf));
  249. return hEmf;
  250. }
  251. // Used in conjuction with Graphics::EnumerateMetafile to play an EMF+
  252. // The data must be DWORD aligned if it's an EMF or EMF+. It must be
  253. // WORD aligned if it's a WMF.
  254. Status
  255. PlayRecord(
  256. IN EmfPlusRecordType recordType,
  257. IN UINT flags,
  258. IN UINT dataSize,
  259. IN const BYTE * data
  260. ) const
  261. {
  262. return SetStatus(DllExports::GdipPlayMetafileRecord(
  263. (GpMetafile *)nativeImage,
  264. recordType,
  265. flags,
  266. dataSize,
  267. data));
  268. }
  269. // If you're using a printer HDC for the metafile, but you want the
  270. // metafile rasterized at screen resolution, then use this API to set
  271. // the rasterization dpi of the metafile to the screen resolution,
  272. // e.g. 96 dpi or 120 dpi.
  273. Status SetDownLevelRasterizationLimit(
  274. IN UINT metafileRasterizationLimitDpi
  275. )
  276. {
  277. return SetStatus(DllExports::GdipSetMetafileDownLevelRasterizationLimit(
  278. (GpMetafile *)nativeImage,
  279. metafileRasterizationLimitDpi));
  280. }
  281. UINT GetDownLevelRasterizationLimit() const
  282. {
  283. UINT metafileRasterizationLimitDpi = 0;
  284. SetStatus(DllExports::GdipGetMetafileDownLevelRasterizationLimit(
  285. (GpMetafile *)nativeImage,
  286. &metafileRasterizationLimitDpi));
  287. return metafileRasterizationLimitDpi;
  288. }
  289. static UINT EmfToWmfBits(
  290. IN HENHMETAFILE hemf,
  291. IN UINT cbData16,
  292. IN LPBYTE pData16,
  293. IN INT iMapMode = MM_ANISOTROPIC,
  294. IN EmfToWmfBitsFlags eFlags = EmfToWmfBitsFlagsDefault
  295. )
  296. {
  297. return DllExports::GdipEmfToWmfBits(
  298. hemf,
  299. cbData16,
  300. pData16,
  301. iMapMode,
  302. eFlags);
  303. }
  304. #ifdef DCR_USE_NEW_250932
  305. private:
  306. Metafile(const Metafile &);
  307. Metafile& operator=(const Metafile &);
  308. #endif
  309. };
  310. #endif // !_METAFILE_H