gdiplusmetaheader.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. /*
  2. * gdiplusmetaheader.h
  3. *
  4. * GDI+ metafile header structure
  5. *
  6. * This file is part of the w32api package.
  7. *
  8. * Contributors:
  9. * Created by Markus Koenig <markus@stber-koenig.de>
  10. *
  11. * THIS SOFTWARE IS NOT COPYRIGHTED
  12. *
  13. * This source code is offered for use in the public domain. You may
  14. * use, modify or distribute it freely.
  15. *
  16. * This code is distributed in the hope that it will be useful but
  17. * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
  18. * DISCLAIMED. This includes but is not limited to warranties of
  19. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  20. *
  21. */
  22. #ifndef __GDIPLUS_METAHEADER_H
  23. #define __GDIPLUS_METAHEADER_H
  24. #if __GNUC__ >=3
  25. #pragma GCC system_header
  26. #endif
  27. /*
  28. * FIXME: is 1 the correct value for GDIP_EMFPLUSFLAGS_DISPLAY? This number
  29. * has been determined by calling Metafile::GetMetafileHeader() on a EMF+
  30. * metafile which was recorded on a display device context (SampleMetafile.emf).
  31. */
  32. #ifdef __cplusplus
  33. const UINT GDIP_EMFPLUSFLAGS_DISPLAY = 1;
  34. #else
  35. #define GDIP_EMFPLUSFLAGS_DISPLAY ((UINT) 1)
  36. #endif
  37. typedef struct tagENHMETAHEADER3 {
  38. DWORD iType;
  39. DWORD nSize;
  40. RECTL rclBounds;
  41. RECTL rclFrame;
  42. DWORD dSignature;
  43. DWORD nVersion;
  44. DWORD nBytes;
  45. DWORD nRecords;
  46. WORD nHandles;
  47. WORD sReserved;
  48. DWORD nDescription;
  49. DWORD offDescription;
  50. DWORD nPalEntries;
  51. SIZEL szlDevice;
  52. SIZEL szlMillimeters;
  53. } ENHMETAHEADER3,*LPENHMETAHEADER3;
  54. typedef struct PWMFRect16 {
  55. INT16 Left;
  56. INT16 Top;
  57. INT16 Right;
  58. INT16 Bottom;
  59. } PWMFRect16;
  60. typedef struct WmfPlaceableFileHeader {
  61. UINT32 Key;
  62. INT16 Hmf;
  63. PWMFRect16 BoundingBox;
  64. INT16 Inch;
  65. UINT32 Reserved;
  66. INT16 Checksum;
  67. } WmfPlaceableFileHeader;
  68. typedef struct MetafileHeader {
  69. MetafileType Type;
  70. UINT Size;
  71. UINT Version;
  72. UINT EmfPlusFlags;
  73. REAL DpiX;
  74. REAL DpiY;
  75. INT X;
  76. INT Y;
  77. INT Width;
  78. INT Height;
  79. __extension__ union {
  80. METAHEADER WmfHeader;
  81. ENHMETAHEADER3 EmfHeader;
  82. };
  83. INT EmfPlusHeaderSize;
  84. INT LogicalDpiX;
  85. INT LogicalDpiY;
  86. #ifdef __cplusplus
  87. public:
  88. void GetBounds(Rect *rect) const
  89. {
  90. if (rect)
  91. {
  92. rect->X = X;
  93. rect->Y = Y;
  94. rect->Width = Width;
  95. rect->Height = Height;
  96. }
  97. }
  98. REAL GetDpiX() const
  99. {
  100. return DpiX;
  101. }
  102. REAL GetDpiY() const
  103. {
  104. return DpiY;
  105. }
  106. const ENHMETAHEADER3* GetEmfHeader() const
  107. {
  108. if (Type == MetafileTypeEmf
  109. || Type == MetafileTypeEmfPlusOnly
  110. || Type == MetafileTypeEmfPlusDual)
  111. {
  112. return &EmfHeader;
  113. }
  114. else
  115. {
  116. return NULL;
  117. }
  118. }
  119. UINT GetEmfPlusFlags() const
  120. {
  121. return EmfPlusFlags;
  122. }
  123. UINT GetMetafileSize() const
  124. {
  125. return Size;
  126. }
  127. MetafileType GetType() const
  128. {
  129. return Type;
  130. }
  131. UINT GetVersion() const
  132. {
  133. return Version;
  134. }
  135. const METAHEADER* GetWmfHeader() const
  136. {
  137. if (Type == MetafileTypeWmf || Type == MetafileTypeWmfPlaceable)
  138. {
  139. return &WmfHeader;
  140. }
  141. else
  142. {
  143. return NULL;
  144. }
  145. }
  146. BOOL IsDisplay() const
  147. {
  148. return EmfPlusFlags == GDIP_EMFPLUSFLAGS_DISPLAY;
  149. }
  150. BOOL IsEmf() const
  151. {
  152. return Type == MetafileTypeEmf;
  153. }
  154. BOOL IsEmfOrEmfPlus() const
  155. {
  156. return Type == MetafileTypeEmf
  157. || Type == MetafileTypeEmfPlusOnly
  158. || Type == MetafileTypeEmfPlusDual;
  159. }
  160. BOOL IsEmfPlus() const
  161. {
  162. return Type == MetafileTypeEmfPlusOnly
  163. || Type == MetafileTypeEmfPlusDual;
  164. }
  165. BOOL IsEmfPlusDual() const
  166. {
  167. return Type == MetafileTypeEmfPlusDual;
  168. }
  169. BOOL IsEmfPlusOnly() const
  170. {
  171. return Type == MetafileTypeEmfPlusOnly;
  172. }
  173. BOOL IsWmf() const
  174. {
  175. return Type == MetafileTypeWmf
  176. || Type == MetafileTypeWmfPlaceable;
  177. }
  178. BOOL IsWmfPlaceable() const
  179. {
  180. return Type == MetafileTypeWmfPlaceable;
  181. }
  182. #endif
  183. } MetafileHeader;
  184. #endif /* __GDIPLUS_METAHEADER_H */