Evan Stade | 021997f | 2007-07-24 17:19:15 -0700 | [diff] [blame] | 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 | |
Evan Stade | e91d124 | 2007-07-31 19:15:29 -0700 | [diff] [blame] | 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 | |
Evan Stade | 021997f | 2007-07-24 17:19:15 -0700 | [diff] [blame] | 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 | |
Evan Stade | e91d124 | 2007-07-31 19:15:29 -0700 | [diff] [blame] | 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 | { |
| 81 | METAHEADER WmfHeader; |
| 82 | ENHMETAHEADER3 EmfHeader; |
| 83 | }; |
| 84 | INT EmfPlusHeaderSize; |
| 85 | INT LogicalDpiX; |
| 86 | INT LogicalDpiY; |
| 87 | |
| 88 | public: |
| 89 | MetafileType GetType() const { return Type; } |
| 90 | |
| 91 | UINT GetMetafileSize() const { return Size; } |
| 92 | |
| 93 | UINT GetVersion() const { return Version; } |
| 94 | |
| 95 | UINT GetEmfPlusFlags() const { return EmfPlusFlags; } |
| 96 | |
| 97 | REAL GetDpiX() const { return DpiX; } |
| 98 | |
| 99 | REAL GetDpiY() const { return DpiY; } |
| 100 | |
| 101 | VOID GetBounds (OUT Rect *r) const |
| 102 | { |
| 103 | r->X = X; |
| 104 | r->Y = Y; |
| 105 | r->Width = Width; |
| 106 | r->Height = Height; |
| 107 | } |
| 108 | |
| 109 | BOOL IsWmf() const |
| 110 | { |
| 111 | return ((Type == MetafileTypeWmf) || (Type == MetafileTypeWmfPlaceable)); |
| 112 | } |
| 113 | |
| 114 | BOOL IsWmfPlaceable() const { return (Type == MetafileTypeWmfPlaceable); } |
| 115 | |
| 116 | BOOL IsEmf() const { return (Type == MetafileTypeEmf); } |
| 117 | |
| 118 | BOOL IsEmfOrEmfPlus() const { return (Type >= MetafileTypeEmf); } |
| 119 | |
| 120 | BOOL IsEmfPlus() const { return (Type >= MetafileTypeEmfPlusOnly); } |
| 121 | |
| 122 | BOOL IsEmfPlusDual() const { return (Type == MetafileTypeEmfPlusDual); } |
| 123 | |
| 124 | BOOL IsEmfPlusOnly() const { return (Type == MetafileTypeEmfPlusOnly); } |
| 125 | |
| 126 | BOOL IsDisplay() const |
| 127 | { |
| 128 | return IsEmfPlus() && ((EmfPlusFlags & GDIP_EMFPLUSFLAGS_DISPLAY) != 0); |
| 129 | } |
| 130 | |
| 131 | const METAHEADER * GetWmfHeader() const |
| 132 | { |
| 133 | return IsWmf() ? &WmfHeader : NULL; |
| 134 | } |
| 135 | |
| 136 | const ENHMETAHEADER3 * GetEmfHeader() const |
| 137 | { |
| 138 | return IsEmfOrEmfPlus() ? &EmfHeader : NULL; |
| 139 | } |
| 140 | }; |
| 141 | #else /* end of c++ typedefs */ |
| 142 | |
| 143 | typedef struct MetafileHeader |
| 144 | { |
| 145 | MetafileType Type; |
| 146 | UINT Size; |
| 147 | UINT Version; |
| 148 | UINT EmfPlusFlags; |
| 149 | REAL DpiX; |
| 150 | REAL DpiY; |
| 151 | INT X; |
| 152 | INT Y; |
| 153 | INT Width; |
| 154 | INT Height; |
| 155 | union |
| 156 | { |
| 157 | METAHEADER WmfHeader; |
| 158 | ENHMETAHEADER3 EmfHeader; |
| 159 | } DUMMYUNIONNAME; |
| 160 | INT EmfPlusHeaderSize; |
| 161 | INT LogicalDpiX; |
| 162 | INT LogicalDpiY; |
| 163 | } MetafileHeader; |
| 164 | |
| 165 | #endif /* end of c typedefs */ |
| 166 | |
Evan Stade | 021997f | 2007-07-24 17:19:15 -0700 | [diff] [blame] | 167 | #endif /* _GDIPLUSMETAHEADER_H */ |