2 * @file gdiplusmetafile.h
3 * @copy 2012 MinGW.org project
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:
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
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.
29 * This file is part of the w32api package.
32 * Created by Markus Koenig <markus@stber-koenig.de>
34 * THIS SOFTWARE IS NOT COPYRIGHTED
36 * This source code is offered for use in the public domain. You may
37 * use, modify or distribute it freely.
39 * This code is distributed in the hope that it will be useful but
40 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
41 * DISCLAIMED. This includes but is not limited to warranties of
42 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
46 #ifndef __GDIPLUS_METAFILE_H
47 #define __GDIPLUS_METAFILE_H
48 #pragma GCC system_header
51 #error "A C++ compiler is required to include gdiplusmetafile.h."
54 class Metafile: public Image
57 static UINT EmfToWmfBits(HENHMETAFILE hEmf,
58 UINT cbData16, LPBYTE pData16,
59 INT iMapMode = MM_ANISOTROPIC,
60 EmfToWmfBitsFlags eFlags = EmfToWmfBitsFlagsDefault)
62 return DllExports::GdipEmfToWmfBits(hEmf,
63 cbData16, pData16, iMapMode, eFlags);
65 static Status GetMetafileHeader(const WCHAR *filename,
66 MetafileHeader *header)
68 return DllExports::GdipGetMetafileHeaderFromFile(
71 static Status GetMetafileHeader(IStream *stream, MetafileHeader *header)
73 return DllExports::GdipGetMetafileHeaderFromStream(
76 ////TODO: Metafile::GetMetafileHeader
77 //static Status GetMetafileHeader(HMETAFILE hWmf,
78 // const WmfPlaceableFileHeader *wmfPlaceableFileHeader,
79 // MetafileHeader *header)
81 // // WTF: No flat API to do this.
82 // return NotImplemented;
84 static Status GetMetafileHeader(HENHMETAFILE hEmf,
85 MetafileHeader *header)
87 return DllExports::GdipGetMetafileHeaderFromEmf(hEmf, header);
90 Metafile(HMETAFILE hWmf,
91 const WmfPlaceableFileHeader *wmfPlaceableFileHeader,
92 BOOL deleteWmf = FALSE): Image(NULL, Ok)
94 GpMetafile *nativeMetafile = NULL;
95 lastStatus = DllExports::GdipCreateMetafileFromWmf(
96 hWmf, deleteWmf, wmfPlaceableFileHeader,
98 nativeImage = nativeMetafile;
100 Metafile(HENHMETAFILE hEmf, BOOL deleteEmf = FALSE): Image(NULL, Ok)
102 GpMetafile *nativeMetafile = NULL;
103 lastStatus = DllExports::GdipCreateMetafileFromEmf(
104 hEmf, deleteEmf, &nativeMetafile);
105 nativeImage = nativeMetafile;
107 Metafile(const WCHAR *filename): Image(NULL, Ok)
109 GpMetafile *nativeMetafile = NULL;
110 lastStatus = DllExports::GdipCreateMetafileFromFile(
111 filename, &nativeMetafile);
112 nativeImage = nativeMetafile;
114 Metafile(const WCHAR *filename,
115 const WmfPlaceableFileHeader *wmfPlaceableFileHeader):
118 GpMetafile *nativeMetafile = NULL;
119 lastStatus = DllExports::GdipCreateMetafileFromWmfFile(
120 filename, wmfPlaceableFileHeader,
122 nativeImage = nativeMetafile;
124 Metafile(IStream *stream): Image(NULL, Ok)
126 GpMetafile *nativeMetafile = NULL;
127 lastStatus = DllExports::GdipCreateMetafileFromStream(
128 stream, &nativeMetafile);
129 nativeImage = nativeMetafile;
131 Metafile(HDC referenceHdc, EmfType type = EmfTypeEmfPlusDual,
132 const WCHAR *description = NULL): Image(NULL, Ok)
134 GpMetafile *nativeMetafile = NULL;
135 lastStatus = DllExports::GdipRecordMetafile(
136 referenceHdc, type, NULL, MetafileFrameUnitGdi,
137 description, &nativeMetafile);
138 nativeImage = nativeMetafile;
140 Metafile(HDC referenceHdc, const RectF& frameRect,
141 MetafileFrameUnit frameUnit = MetafileFrameUnitGdi,
142 EmfType type = EmfTypeEmfPlusDual,
143 const WCHAR *description = NULL): Image(NULL, Ok)
145 GpMetafile *nativeMetafile = NULL;
146 lastStatus = DllExports::GdipRecordMetafile(
147 referenceHdc, type, &frameRect, frameUnit,
148 description, &nativeMetafile);
149 nativeImage = nativeMetafile;
151 Metafile(HDC referenceHdc, const Rect& frameRect,
152 MetafileFrameUnit frameUnit = MetafileFrameUnitGdi,
153 EmfType type = EmfTypeEmfPlusDual,
154 const WCHAR *description = NULL): Image(NULL, Ok)
156 GpMetafile *nativeMetafile = NULL;
157 lastStatus = DllExports::GdipRecordMetafileI(
158 referenceHdc, type, &frameRect, frameUnit,
159 description, &nativeMetafile);
160 nativeImage = nativeMetafile;
162 Metafile(const WCHAR *filename, HDC referenceHdc,
163 EmfType type = EmfTypeEmfPlusDual,
164 const WCHAR *description = NULL): Image(NULL, Ok)
166 GpMetafile *nativeMetafile = NULL;
167 lastStatus = DllExports::GdipRecordMetafileFileName(
168 filename, referenceHdc, type, NULL,
169 MetafileFrameUnitGdi, description,
171 nativeImage = nativeMetafile;
173 Metafile(const WCHAR *filename, HDC referenceHdc,
174 const RectF& frameRect,
175 MetafileFrameUnit frameUnit = MetafileFrameUnitGdi,
176 EmfType type = EmfTypeEmfPlusDual,
177 const WCHAR *description = NULL): Image(NULL, Ok)
179 GpMetafile *nativeMetafile = NULL;
180 lastStatus = DllExports::GdipRecordMetafileFileName(
181 filename, referenceHdc, type, &frameRect,
182 frameUnit, description, &nativeMetafile);
183 nativeImage = nativeMetafile;
185 Metafile(const WCHAR *filename, HDC referenceHdc,
186 const Rect& frameRect,
187 MetafileFrameUnit frameUnit = MetafileFrameUnitGdi,
188 EmfType type = EmfTypeEmfPlusDual,
189 const WCHAR *description = NULL): Image(NULL, Ok)
191 GpMetafile *nativeMetafile = NULL;
192 lastStatus = DllExports::GdipRecordMetafileFileNameI(
193 filename, referenceHdc, type, &frameRect,
194 frameUnit, description, &nativeMetafile);
195 nativeImage = nativeMetafile;
197 Metafile(IStream *stream, HDC referenceHdc,
198 EmfType type = EmfTypeEmfPlusDual,
199 const WCHAR *description = NULL): Image(NULL, Ok)
201 GpMetafile *nativeMetafile = NULL;
202 lastStatus = DllExports::GdipRecordMetafileStream(
203 stream, referenceHdc, type, NULL,
204 MetafileFrameUnitGdi, description,
206 nativeImage = nativeMetafile;
208 Metafile(IStream *stream, HDC referenceHdc, const RectF& frameRect,
209 MetafileFrameUnit frameUnit = MetafileFrameUnitGdi,
210 EmfType type = EmfTypeEmfPlusDual,
211 const WCHAR *description = NULL): Image(NULL, Ok)
213 GpMetafile *nativeMetafile = NULL;
214 lastStatus = DllExports::GdipRecordMetafileStream(
215 stream, referenceHdc, type, &frameRect,
216 frameUnit, description, &nativeMetafile);
217 nativeImage = nativeMetafile;
219 Metafile(IStream *stream, HDC referenceHdc, const Rect& frameRect,
220 MetafileFrameUnit frameUnit = MetafileFrameUnitGdi,
221 EmfType type = EmfTypeEmfPlusDual,
222 const WCHAR *description = NULL): Image(NULL, Ok)
224 GpMetafile *nativeMetafile = NULL;
225 lastStatus = DllExports::GdipRecordMetafileStreamI(
226 stream, referenceHdc, type, &frameRect,
227 frameUnit, description, &nativeMetafile);
228 nativeImage = nativeMetafile;
233 virtual Metafile* Clone() const
235 GpImage *cloneImage = NULL;
236 Status status = updateStatus(DllExports::GdipCloneImage(
237 nativeImage, &cloneImage));
239 Metafile *result = new Metafile(cloneImage, lastStatus);
241 DllExports::GdipDisposeImage(cloneImage);
242 lastStatus = OutOfMemory;
250 ////TODO: [GDI+ 1.1] Metafile::ConvertToEmfPlus
251 //Status ConvertToEmfPlus(const Graphics *refGraphics,
252 // BOOL *conversionSuccess = NULL,
253 // EmfType emfType = EmfTypeEmfPlusOnly,
254 // const WCHAR *description = NULL)
256 // // FIXME: can't test GdipConvertToEmfPlus because it isn't exported in 1.0
257 // return updateStatus(DllExports::GdipConvertToEmfPlus(
258 // refGraphics ? refGraphics->nativeGraphics : NULL,
259 // (GpMetafile*) nativeImage,
260 // conversionSuccess, emfType, description, ???));
262 ////TODO: [GDI+ 1.1] Metafile::ConvertToEmfPlus
263 //Status ConvertToEmfPlus(const Graphics *refGraphics,
264 // const WCHAR *filename,
265 // BOOL *conversionSuccess = NULL,
266 // EmfType emfType = EmfTypeEmfPlusOnly,
267 // const WCHAR *description = NULL)
269 // // FIXME: can't test GdipConvertToEmfPlusToFile because it isn't exported in 1.0
270 // return updateStatus(DllExports::GdipConvertToEmfPlusToFile(
271 // refGraphics ? refGraphics->nativeGraphics : NULL,
272 // (GpMetafile*) nativeImage, conversionSuccess,
273 // filename, emfType, description, ???));
275 ////TODO: [GDI+ 1.1] Metafile::ConvertToEmfPlus
276 //Status ConvertToEmfPlus(const Graphics *refGraphics,
278 // BOOL *conversionSuccess = NULL,
279 // EmfType emfType = EmfTypeEmfPlusOnly,
280 // const WCHAR *description = NULL)
282 // // FIXME: can't test GdipConvertToEmfPlusToStream because it isn't exported in 1.0
283 // return updateStatus(DllExports::GdipConvertToEmfPlusToStream(
284 // refGraphics ? refGraphics->nativeGraphics : NULL,
285 // (GpMetafile*) nativeImage, conversionSuccess,
286 // stream, emfType, description, ???));
288 UINT GetDownLevelRasterizationLimit() const
291 updateStatus(DllExports::GdipGetMetafileDownLevelRasterizationLimit(
292 (GpMetafile*) nativeImage, &result));
295 HENHMETAFILE GetHENHMETAFILE()
297 HENHMETAFILE result = NULL;
298 updateStatus(DllExports::GdipGetHemfFromMetafile(
299 (GpMetafile*) nativeImage, &result));
302 Status GetMetafileHeader(MetafileHeader *header) const
304 return updateStatus(DllExports::GdipGetMetafileHeaderFromMetafile(
305 (GpMetafile*) nativeImage, header));
307 Status PlayRecord(EmfPlusRecordType recordType, UINT flags,
308 UINT dataSize, const BYTE *data) const
310 return updateStatus(DllExports::GdipPlayMetafileRecord(
311 (GpMetafile*) nativeImage,
312 recordType, flags, dataSize, data));
314 Status SetDownLevelRasterizationLimit(UINT limitDpi)
316 return updateStatus(DllExports::GdipSetMetafileDownLevelRasterizationLimit(
317 (GpMetafile*) nativeImage, limitDpi));
321 Metafile(GpImage *image, Status status): Image(image, status) {}
322 Metafile(const Metafile&);
323 Metafile& operator=(const Metafile&);
326 #endif /* __GDIPLUS_METAFILE_H */