1 | /*
|
---|
2 | * Copyright (C) 2007 Google (Evan Stade)
|
---|
3 | *
|
---|
4 | * This library is free software; you can redistribute it and/or
|
---|
5 | * modify it under the terms of the GNU Lesser General Public
|
---|
6 | * License as published by the Free Software Foundation; either
|
---|
7 | * version 2.1 of the License, or (at your option) any later version.
|
---|
8 | *
|
---|
9 | * This library is distributed in the hope that it will be useful,
|
---|
10 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
11 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
---|
12 | * Lesser General Public License for more details.
|
---|
13 | *
|
---|
14 | * You should have received a copy of the GNU Lesser General Public
|
---|
15 | * License along with this library; if not, write to the Free Software
|
---|
16 | * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
---|
17 | */
|
---|
18 |
|
---|
19 | /*
|
---|
20 | * Sun LGPL Disclaimer: For the avoidance of doubt, except that if any license choice
|
---|
21 | * other than GPL or LGPL is available it will apply instead, Sun elects to use only
|
---|
22 | * the Lesser General Public License version 2.1 (LGPLv2) at this time for any software where
|
---|
23 | * a choice of LGPL license versions is made available with the language indicating
|
---|
24 | * that LGPLv2 or any later version may be used, or where a choice of which version
|
---|
25 | * of the LGPL is applied is otherwise unspecified.
|
---|
26 | */
|
---|
27 |
|
---|
28 | #ifndef _GDIPLUSMETAHEADER_H
|
---|
29 | #define _GDIPLUSMETAHEADER_H
|
---|
30 |
|
---|
31 | typedef struct
|
---|
32 | {
|
---|
33 | DWORD iType;
|
---|
34 | DWORD nSize;
|
---|
35 | RECTL rclBounds;
|
---|
36 | RECTL rclFrame;
|
---|
37 | DWORD dSignature;
|
---|
38 | DWORD nVersion;
|
---|
39 | DWORD nBytes;
|
---|
40 | DWORD nRecords;
|
---|
41 | WORD nHandles;
|
---|
42 | WORD sReserved;
|
---|
43 | DWORD nDescription;
|
---|
44 | DWORD offDescription;
|
---|
45 | DWORD nPalEntries;
|
---|
46 | SIZEL szlDevice;
|
---|
47 | SIZEL szlMillimeters;
|
---|
48 | } ENHMETAHEADER3;
|
---|
49 |
|
---|
50 | #include <pshpack2.h>
|
---|
51 |
|
---|
52 | typedef struct
|
---|
53 | {
|
---|
54 | INT16 Left;
|
---|
55 | INT16 Top;
|
---|
56 | INT16 Right;
|
---|
57 | INT16 Bottom;
|
---|
58 | } PWMFRect16;
|
---|
59 |
|
---|
60 | typedef struct
|
---|
61 | {
|
---|
62 | UINT32 Key;
|
---|
63 | INT16 Hmf;
|
---|
64 | PWMFRect16 BoundingBox;
|
---|
65 | INT16 Inch;
|
---|
66 | UINT32 Reserved;
|
---|
67 | INT16 Checksum;
|
---|
68 | } WmfPlaceableFileHeader;
|
---|
69 |
|
---|
70 | #include <poppack.h>
|
---|
71 |
|
---|
72 | #define GDIP_EMFPLUSFLAGS_DISPLAY 0x00000001
|
---|
73 |
|
---|
74 | #ifdef __cplusplus
|
---|
75 | class MetafileHeader
|
---|
76 | {
|
---|
77 | public:
|
---|
78 | MetafileType Type;
|
---|
79 | UINT Size;
|
---|
80 | UINT Version;
|
---|
81 | UINT EmfPlusFlags;
|
---|
82 | REAL DpiX;
|
---|
83 | REAL DpiY;
|
---|
84 | INT X;
|
---|
85 | INT Y;
|
---|
86 | INT Width;
|
---|
87 | INT Height;
|
---|
88 | union
|
---|
89 | {
|
---|
90 | METAHEADER WmfHeader;
|
---|
91 | ENHMETAHEADER3 EmfHeader;
|
---|
92 | };
|
---|
93 | INT EmfPlusHeaderSize;
|
---|
94 | INT LogicalDpiX;
|
---|
95 | INT LogicalDpiY;
|
---|
96 |
|
---|
97 | public:
|
---|
98 | MetafileType GetType() const { return Type; }
|
---|
99 |
|
---|
100 | UINT GetMetafileSize() const { return Size; }
|
---|
101 |
|
---|
102 | UINT GetVersion() const { return Version; }
|
---|
103 |
|
---|
104 | UINT GetEmfPlusFlags() const { return EmfPlusFlags; }
|
---|
105 |
|
---|
106 | REAL GetDpiX() const { return DpiX; }
|
---|
107 |
|
---|
108 | REAL GetDpiY() const { return DpiY; }
|
---|
109 |
|
---|
110 | VOID GetBounds (OUT Rect *r) const
|
---|
111 | {
|
---|
112 | r->X = X;
|
---|
113 | r->Y = Y;
|
---|
114 | r->Width = Width;
|
---|
115 | r->Height = Height;
|
---|
116 | }
|
---|
117 |
|
---|
118 | BOOL IsWmf() const
|
---|
119 | {
|
---|
120 | return ((Type == MetafileTypeWmf) || (Type == MetafileTypeWmfPlaceable));
|
---|
121 | }
|
---|
122 |
|
---|
123 | BOOL IsWmfPlaceable() const { return (Type == MetafileTypeWmfPlaceable); }
|
---|
124 |
|
---|
125 | BOOL IsEmf() const { return (Type == MetafileTypeEmf); }
|
---|
126 |
|
---|
127 | BOOL IsEmfOrEmfPlus() const { return (Type >= MetafileTypeEmf); }
|
---|
128 |
|
---|
129 | BOOL IsEmfPlus() const { return (Type >= MetafileTypeEmfPlusOnly); }
|
---|
130 |
|
---|
131 | BOOL IsEmfPlusDual() const { return (Type == MetafileTypeEmfPlusDual); }
|
---|
132 |
|
---|
133 | BOOL IsEmfPlusOnly() const { return (Type == MetafileTypeEmfPlusOnly); }
|
---|
134 |
|
---|
135 | BOOL IsDisplay() const
|
---|
136 | {
|
---|
137 | return IsEmfPlus() && ((EmfPlusFlags & GDIP_EMFPLUSFLAGS_DISPLAY) != 0);
|
---|
138 | }
|
---|
139 |
|
---|
140 | const METAHEADER * GetWmfHeader() const
|
---|
141 | {
|
---|
142 | return IsWmf() ? &WmfHeader : NULL;
|
---|
143 | }
|
---|
144 |
|
---|
145 | const ENHMETAHEADER3 * GetEmfHeader() const
|
---|
146 | {
|
---|
147 | return IsEmfOrEmfPlus() ? &EmfHeader : NULL;
|
---|
148 | }
|
---|
149 | };
|
---|
150 | #else /* end of c++ typedefs */
|
---|
151 |
|
---|
152 | typedef struct MetafileHeader
|
---|
153 | {
|
---|
154 | MetafileType Type;
|
---|
155 | UINT Size;
|
---|
156 | UINT Version;
|
---|
157 | UINT EmfPlusFlags;
|
---|
158 | REAL DpiX;
|
---|
159 | REAL DpiY;
|
---|
160 | INT X;
|
---|
161 | INT Y;
|
---|
162 | INT Width;
|
---|
163 | INT Height;
|
---|
164 | union
|
---|
165 | {
|
---|
166 | METAHEADER WmfHeader;
|
---|
167 | ENHMETAHEADER3 EmfHeader;
|
---|
168 | } DUMMYUNIONNAME;
|
---|
169 | INT EmfPlusHeaderSize;
|
---|
170 | INT LogicalDpiX;
|
---|
171 | INT LogicalDpiY;
|
---|
172 | } MetafileHeader;
|
---|
173 |
|
---|
174 | #endif /* end of c typedefs */
|
---|
175 |
|
---|
176 | #endif /* _GDIPLUSMETAHEADER_H */
|
---|