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 #ifndef _GDIPLUSMETAHEADER_H 20 #define _GDIPLUSMETAHEADER_H 21 22 typedef struct 23 { 24 DWORD iType; 25 DWORD nSize; 26 RECTL rclBounds; 27 RECTL rclFrame; 28 DWORD dSignature; 29 DWORD nVersion; 30 DWORD nBytes; 31 DWORD nRecords; 32 WORD nHandles; 33 WORD sReserved; 34 DWORD nDescription; 35 DWORD offDescription; 36 DWORD nPalEntries; 37 SIZEL szlDevice; 38 SIZEL szlMillimeters; 39 } ENHMETAHEADER3; 40 41 #include <pshpack2.h> 42 43 typedef struct 44 { 45 INT16 Left; 46 INT16 Top; 47 INT16 Right; 48 INT16 Bottom; 49 } PWMFRect16; 50 51 typedef struct 52 { 53 UINT32 Key; 54 INT16 Hmf; 55 PWMFRect16 BoundingBox; 56 INT16 Inch; 57 UINT32 Reserved; 58 INT16 Checksum; 59 } WmfPlaceableFileHeader; 60 61 #include <poppack.h> 62 63 #define GDIP_EMFPLUSFLAGS_DISPLAY 0x00000001 64 65 #ifdef __cplusplus 66 class MetafileHeader 67 { 68 public: 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 union { 80 METAHEADER WmfHeader; 81 ENHMETAHEADER3 EmfHeader; 82 }; 83 INT EmfPlusHeaderSize; 84 INT LogicalDpiX; 85 INT LogicalDpiY; 86 87 public: 88 MetafileType 89 GetType() const 90 { 91 return Type; 92 } 93 94 UINT 95 GetMetafileSize() const 96 { 97 return Size; 98 } 99 100 UINT 101 GetVersion() const 102 { 103 return Version; 104 } 105 106 UINT 107 GetEmfPlusFlags() const 108 { 109 return EmfPlusFlags; 110 } 111 112 REAL 113 GetDpiX() const 114 { 115 return DpiX; 116 } 117 118 REAL 119 GetDpiY() const 120 { 121 return DpiY; 122 } 123 124 VOID 125 GetBounds(OUT Rect *r) const 126 { 127 r->X = X; 128 r->Y = Y; 129 r->Width = Width; 130 r->Height = Height; 131 } 132 133 BOOL 134 IsWmf() const 135 { 136 return ((Type == MetafileTypeWmf) || (Type == MetafileTypeWmfPlaceable)); 137 } 138 139 BOOL 140 IsWmfPlaceable() const 141 { 142 return (Type == MetafileTypeWmfPlaceable); 143 } 144 145 BOOL 146 IsEmf() const 147 { 148 return (Type == MetafileTypeEmf); 149 } 150 151 BOOL 152 IsEmfOrEmfPlus() const 153 { 154 return (Type >= MetafileTypeEmf); 155 } 156 157 BOOL 158 IsEmfPlus() const 159 { 160 return (Type >= MetafileTypeEmfPlusOnly); 161 } 162 163 BOOL 164 IsEmfPlusDual() const 165 { 166 return (Type == MetafileTypeEmfPlusDual); 167 } 168 169 BOOL 170 IsEmfPlusOnly() const 171 { 172 return (Type == MetafileTypeEmfPlusOnly); 173 } 174 175 BOOL 176 IsDisplay() const 177 { 178 return IsEmfPlus() && ((EmfPlusFlags & GDIP_EMFPLUSFLAGS_DISPLAY) != 0); 179 } 180 181 const METAHEADER * 182 GetWmfHeader() const 183 { 184 return IsWmf() ? &WmfHeader : NULL; 185 } 186 187 const ENHMETAHEADER3 * 188 GetEmfHeader() const 189 { 190 return IsEmfOrEmfPlus() ? &EmfHeader : NULL; 191 } 192 }; 193 #else /* end of c++ typedefs */ 194 195 typedef struct MetafileHeader 196 { 197 MetafileType Type; 198 UINT Size; 199 UINT Version; 200 UINT EmfPlusFlags; 201 REAL DpiX; 202 REAL DpiY; 203 INT X; 204 INT Y; 205 INT Width; 206 INT Height; 207 union { 208 METAHEADER WmfHeader; 209 ENHMETAHEADER3 EmfHeader; 210 } DUMMYUNIONNAME; 211 INT EmfPlusHeaderSize; 212 INT LogicalDpiX; 213 INT LogicalDpiY; 214 } MetafileHeader; 215 216 #endif /* end of c typedefs */ 217 218 #endif /* _GDIPLUSMETAHEADER_H */ 219