OSDN Git Service

Insert removed author attribution.
[mingw/mingw-org-wsl.git] / include / gdiplus / gdiplusmetaheader.h
1 /**
2  * @file gdiplusmetaheader.h
3  * @copy 2012 MinGW.org project
4  *
5  * Permission is hereby granted, free of charge, to any person obtaining a
6  * copy of this software and associated documentation files (the "Software"),
7  * to deal in the Software without restriction, including without limitation
8  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9  * and/or sell copies of the Software, and to permit persons to whom the
10  * Software is furnished to do so, subject to the following conditions:
11  * 
12  * The above copyright notice and this permission notice (including the next
13  * paragraph) shall be included in all copies or substantial portions of the
14  * Software.
15  * 
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22  * DEALINGS IN THE SOFTWARE.
23  */
24 /* Created by Markus Koenig <markus@stber-koenig.de> */
25 #ifndef __GDIPLUS_METAHEADER_H
26 #define __GDIPLUS_METAHEADER_H
27 #pragma GCC system_header
28 #include <_mingw.h>
29
30 /*
31  * GDI+ metafile header structure
32  */
33
34 /*
35  * FIXME: is 1 the correct value for GDIP_EMFPLUSFLAGS_DISPLAY? This number
36  * has been determined by calling Metafile::GetMetafileHeader() on a EMF+
37  * metafile which was recorded on a display device context (SampleMetafile.emf).
38  */
39 #ifdef __cplusplus
40 const UINT GDIP_EMFPLUSFLAGS_DISPLAY = 1;
41 #else
42 #define GDIP_EMFPLUSFLAGS_DISPLAY ((UINT) 1)
43 #endif
44
45 typedef struct tagENHMETAHEADER3 {
46         DWORD iType;
47         DWORD nSize;
48         RECTL rclBounds;
49         RECTL rclFrame;
50         DWORD dSignature;
51         DWORD nVersion;
52         DWORD nBytes;
53         DWORD nRecords;
54         WORD nHandles;
55         WORD sReserved;
56         DWORD nDescription;
57         DWORD offDescription;
58         DWORD nPalEntries;
59         SIZEL szlDevice;
60         SIZEL szlMillimeters;
61 } ENHMETAHEADER3,*LPENHMETAHEADER3;
62
63 typedef struct PWMFRect16 {
64         INT16 Left;
65         INT16 Top;
66         INT16 Right;
67         INT16 Bottom;
68 } PWMFRect16;
69
70 typedef struct WmfPlaceableFileHeader {
71         UINT32 Key;
72         INT16 Hmf;
73         PWMFRect16 BoundingBox;
74         INT16 Inch;
75         UINT32 Reserved;
76         INT16 Checksum;
77 } WmfPlaceableFileHeader;
78
79 typedef struct MetafileHeader {
80         MetafileType Type;
81         UINT Size;
82         UINT Version;
83         UINT EmfPlusFlags;
84         REAL DpiX;
85         REAL DpiY;
86         INT X;
87         INT Y;
88         INT Width;
89         INT Height;
90         __extension__ union {
91                 METAHEADER WmfHeader;
92                 ENHMETAHEADER3 EmfHeader;
93         };
94         INT EmfPlusHeaderSize;
95         INT LogicalDpiX;
96         INT LogicalDpiY;
97
98         #ifdef __cplusplus
99         public:
100         void GetBounds(Rect *rect) const
101         {
102                 if (rect)
103                 {
104                         rect->X = X;
105                         rect->Y = Y;
106                         rect->Width = Width;
107                         rect->Height = Height;
108                 }
109         }
110         REAL GetDpiX() const
111         {
112                 return DpiX;
113         }
114         REAL GetDpiY() const
115         {
116                 return DpiY;
117         }
118         const ENHMETAHEADER3* GetEmfHeader() const
119         {
120                 if (Type == MetafileTypeEmf
121                                 || Type == MetafileTypeEmfPlusOnly
122                                 || Type == MetafileTypeEmfPlusDual)
123                 {
124                         return &EmfHeader;
125                 }
126                 else
127                 {
128                         return NULL;
129                 }
130         }
131         UINT GetEmfPlusFlags() const
132         {
133                 return EmfPlusFlags;
134         }
135         UINT GetMetafileSize() const
136         {
137                 return Size;
138         }
139         MetafileType GetType() const
140         {
141                 return Type;
142         }
143         UINT GetVersion() const
144         {
145                 return Version;
146         }
147         const METAHEADER* GetWmfHeader() const
148         {
149                 if (Type == MetafileTypeWmf || Type == MetafileTypeWmfPlaceable)
150                 {
151                         return &WmfHeader;
152                 }
153                 else
154                 {
155                         return NULL;
156                 }
157         }
158         BOOL IsDisplay() const
159         {
160                 return EmfPlusFlags == GDIP_EMFPLUSFLAGS_DISPLAY;
161         }
162         BOOL IsEmf() const
163         {
164                 return Type == MetafileTypeEmf;
165         }
166         BOOL IsEmfOrEmfPlus() const
167         {
168                 return Type == MetafileTypeEmf
169                         || Type == MetafileTypeEmfPlusOnly
170                         || Type == MetafileTypeEmfPlusDual;
171         }
172         BOOL IsEmfPlus() const
173         {
174                 return Type == MetafileTypeEmfPlusOnly
175                         || Type == MetafileTypeEmfPlusDual;
176         }
177         BOOL IsEmfPlusDual() const
178         {
179                 return Type == MetafileTypeEmfPlusDual;
180         }
181         BOOL IsEmfPlusOnly() const
182         {
183                 return Type == MetafileTypeEmfPlusOnly;
184         }
185         BOOL IsWmf() const
186         {
187                 return Type == MetafileTypeWmf
188                         || Type == MetafileTypeWmfPlaceable;
189         }
190         BOOL IsWmfPlaceable() const
191         {
192                 return Type == MetafileTypeWmfPlaceable;
193         }
194         #endif
195 } MetafileHeader;
196
197 #endif /* __GDIPLUS_METAHEADER_H */