2005-05-08 18:02:41 +00:00
|
|
|
/*
|
|
|
|
* GdiPlusMetaFile.h
|
|
|
|
*
|
|
|
|
* Windows GDI+
|
|
|
|
*
|
|
|
|
* This file is part of the w32api package.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS NOT COPYRIGHTED
|
|
|
|
*
|
|
|
|
* This source code is offered for use in the public domain. You may
|
|
|
|
* use, modify or distribute it freely.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful but
|
|
|
|
* WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
|
|
|
|
* DISCLAIMED. This includes but is not limited to warranties of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef _GDIPLUSMETAFILE_H
|
|
|
|
#define _GDIPLUSMETAFILE_H
|
|
|
|
|
|
|
|
class Metafile : public Image
|
|
|
|
{
|
2019-12-29 14:21:05 +00:00
|
|
|
public:
|
2020-01-01 08:06:34 +00:00
|
|
|
Metafile(HDC referenceHdc, EmfType type = EmfTypeEmfPlusDual, const WCHAR *description = NULL)
|
2019-12-29 14:21:05 +00:00
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
GpMetafile *metafile = NULL;
|
|
|
|
lastStatus =
|
|
|
|
DllExports::GdipRecordMetafile(referenceHdc, type, NULL, MetafileFrameUnitGdi, description, &metafile);
|
|
|
|
SetNativeImage(metafile);
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Metafile(const WCHAR *filename)
|
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
GpMetafile *metafile = NULL;
|
|
|
|
lastStatus = DllExports::GdipCreateMetafileFromFile(filename, &metafile);
|
|
|
|
SetNativeImage(metafile);
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Metafile(
|
|
|
|
HDC referenceHdc,
|
|
|
|
const RectF &frameRect,
|
2020-01-01 08:06:34 +00:00
|
|
|
MetafileFrameUnit frameUnit = MetafileFrameUnitGdi,
|
|
|
|
EmfType type = EmfTypeEmfPlusDual,
|
|
|
|
const WCHAR *description = NULL)
|
2019-12-29 14:21:05 +00:00
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
GpMetafile *metafile = NULL;
|
|
|
|
lastStatus = DllExports::GdipRecordMetafile(referenceHdc, type, &frameRect, frameUnit, description, &metafile);
|
|
|
|
SetNativeImage(metafile);
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
2020-01-01 08:06:34 +00:00
|
|
|
Metafile(HMETAFILE hWmf, const WmfPlaceableFileHeader *wmfPlaceableFileHeader, BOOL deleteWmf = FALSE)
|
2019-12-29 14:21:05 +00:00
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
GpMetafile *metafile = NULL;
|
|
|
|
lastStatus = DllExports::GdipCreateMetafileFromWmf(hWmf, deleteWmf, wmfPlaceableFileHeader, &metafile);
|
|
|
|
SetNativeImage(metafile);
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Metafile(
|
|
|
|
const WCHAR *fileName,
|
|
|
|
HDC referenceHdc,
|
|
|
|
const Rect &frameRect,
|
2020-01-01 08:06:34 +00:00
|
|
|
MetafileFrameUnit frameUnit = MetafileFrameUnitGdi,
|
|
|
|
EmfType type = EmfTypeEmfPlusDual,
|
|
|
|
const WCHAR *description = NULL)
|
2019-12-29 14:21:05 +00:00
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
GpMetafile *metafile = NULL;
|
|
|
|
lastStatus = DllExports::GdipRecordMetafileFileNameI(
|
|
|
|
fileName, referenceHdc, type, &frameRect, frameUnit, description, &metafile);
|
|
|
|
SetNativeImage(metafile);
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Metafile(
|
|
|
|
IStream *stream,
|
|
|
|
HDC referenceHdc,
|
|
|
|
const RectF &frameRect,
|
2020-01-01 08:06:34 +00:00
|
|
|
MetafileFrameUnit frameUnit = MetafileFrameUnitGdi,
|
|
|
|
EmfType type = EmfTypeEmfPlusDual,
|
|
|
|
const WCHAR *description = NULL)
|
2019-12-29 14:21:05 +00:00
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
GpMetafile *metafile = NULL;
|
|
|
|
lastStatus = DllExports::GdipRecordMetafile(referenceHdc, type, &frameRect, frameUnit, description, &metafile);
|
|
|
|
SetNativeImage(metafile);
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
2020-01-01 08:06:34 +00:00
|
|
|
Metafile(IStream *stream, HDC referenceHdc, EmfType type = EmfTypeEmfPlusDual, const WCHAR *description = NULL)
|
2019-12-29 14:21:05 +00:00
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
GpMetafile *metafile = NULL;
|
|
|
|
lastStatus = DllExports::GdipRecordMetafileStream(
|
|
|
|
stream, referenceHdc, type, NULL, MetafileFrameUnitGdi, description, &metafile);
|
|
|
|
SetNativeImage(metafile);
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Metafile(
|
|
|
|
IStream *stream,
|
|
|
|
HDC referenceHdc,
|
|
|
|
const Rect &frameRect,
|
2020-01-01 08:06:34 +00:00
|
|
|
MetafileFrameUnit frameUnit = MetafileFrameUnitGdi,
|
|
|
|
EmfType type = EmfTypeEmfPlusDual,
|
|
|
|
const WCHAR *description = NULL)
|
2019-12-29 14:21:05 +00:00
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
GpMetafile *metafile = NULL;
|
|
|
|
lastStatus = DllExports::GdipRecordMetafileI(referenceHdc, type, &frameRect, frameUnit, description, &metafile);
|
|
|
|
SetNativeImage(metafile);
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Metafile(
|
|
|
|
const WCHAR *fileName,
|
|
|
|
HDC referenceHdc,
|
|
|
|
const RectF &frameRect,
|
2020-01-01 08:06:34 +00:00
|
|
|
MetafileFrameUnit frameUnit = MetafileFrameUnitGdi,
|
|
|
|
EmfType type = EmfTypeEmfPlusDual,
|
|
|
|
const WCHAR *description = NULL)
|
2019-12-29 14:21:05 +00:00
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
GpMetafile *metafile = NULL;
|
|
|
|
lastStatus = DllExports::GdipRecordMetafileFileName(
|
|
|
|
fileName, referenceHdc, type, &frameRect, frameUnit, description, &metafile);
|
|
|
|
SetNativeImage(metafile);
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
2020-01-01 08:06:34 +00:00
|
|
|
Metafile(
|
|
|
|
const WCHAR *fileName,
|
|
|
|
HDC referenceHdc,
|
|
|
|
EmfType type = EmfTypeEmfPlusDual,
|
|
|
|
const WCHAR *description = NULL)
|
2019-12-29 14:21:05 +00:00
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
GpMetafile *metafile = NULL;
|
|
|
|
lastStatus = DllExports::GdipRecordMetafileFileName(
|
|
|
|
fileName, referenceHdc, type, NULL, MetafileFrameUnitGdi, description, &metafile);
|
|
|
|
SetNativeImage(metafile);
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Metafile(IStream *stream)
|
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
GpMetafile *metafile = NULL;
|
|
|
|
lastStatus = DllExports::GdipCreateMetafileFromStream(stream, &metafile);
|
|
|
|
SetNativeImage(metafile);
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
2020-01-01 08:06:34 +00:00
|
|
|
Metafile(HENHMETAFILE hEmf, BOOL deleteEmf = FALSE)
|
2019-12-29 14:21:05 +00:00
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
GpMetafile *metafile = NULL;
|
|
|
|
lastStatus = DllExports::GdipCreateMetafileFromEmf(hEmf, deleteEmf, &metafile);
|
|
|
|
SetNativeImage(metafile);
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Metafile(
|
|
|
|
HDC referenceHdc,
|
|
|
|
const Rect &frameRect,
|
2020-01-01 08:06:34 +00:00
|
|
|
MetafileFrameUnit frameUnit = MetafileFrameUnitGdi,
|
|
|
|
EmfType type = EmfTypeEmfPlusDual,
|
|
|
|
const WCHAR *description = NULL)
|
2019-12-29 14:21:05 +00:00
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
GpMetafile *metafile = NULL;
|
|
|
|
lastStatus = DllExports::GdipRecordMetafileI(referenceHdc, type, &frameRect, frameUnit, description, &metafile);
|
|
|
|
SetNativeImage(metafile);
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static UINT
|
2020-01-01 08:06:34 +00:00
|
|
|
EmfToWmfBits(
|
|
|
|
HENHMETAFILE hemf,
|
|
|
|
UINT cbData16,
|
|
|
|
LPBYTE pData16,
|
|
|
|
INT iMapMode = MM_ANISOTROPIC,
|
|
|
|
EmfToWmfBitsFlags eFlags = EmfToWmfBitsFlagsDefault)
|
2019-12-29 14:21:05 +00:00
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
return DllExports::GdipEmfToWmfBits(hemf, cbData16, pData16, iMapMode, eFlags);
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
2020-01-01 08:06:34 +00:00
|
|
|
UINT
|
|
|
|
GetDownLevelRasterizationLimit() const
|
2019-12-29 14:21:05 +00:00
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
#if 1
|
|
|
|
return 0; // FIXME
|
|
|
|
#else
|
|
|
|
UINT metafileRasterizationLimitDpi = 0;
|
|
|
|
SetStatus(DllExports::GdipGetMetafileDownLevelRasterizationLimit(
|
|
|
|
GetNativeMetafile(), &metafileRasterizationLimitDpi));
|
|
|
|
return metafileRasterizationLimitDpi;
|
|
|
|
#endif
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
2020-01-01 08:06:34 +00:00
|
|
|
HENHMETAFILE
|
|
|
|
GetHENHMETAFILE() const
|
2019-12-29 14:21:05 +00:00
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
HENHMETAFILE hEmf;
|
|
|
|
SetStatus(DllExports::GdipGetHemfFromMetafile(GetNativeMetafile(), &hEmf));
|
|
|
|
return hEmf;
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static Status
|
|
|
|
GetMetafileHeader(const WCHAR *filename, MetafileHeader *header)
|
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
return DllExports::GdipGetMetafileHeaderFromFile(filename, header);
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static Status
|
2020-01-01 08:06:34 +00:00
|
|
|
GetMetafileHeader(HENHMETAFILE hEmf, MetafileHeader *header)
|
2019-12-29 14:21:05 +00:00
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
return DllExports::GdipGetMetafileHeaderFromEmf(hEmf, header);
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static Status
|
|
|
|
GetMetafileHeader(HMETAFILE hWmf, const WmfPlaceableFileHeader *wmfPlaceableFileHeader, MetafileHeader *header)
|
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
return DllExports::GdipGetMetafileHeaderFromWmf(hWmf, wmfPlaceableFileHeader, header);
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
|
|
|
GetMetafileHeader(MetafileHeader *header) const
|
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
return SetStatus(DllExports::GdipGetMetafileHeaderFromMetafile(GetNativeMetafile(), header));
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static Status
|
|
|
|
GetMetafileHeader(IStream *stream, MetafileHeader *header)
|
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
return DllExports::GdipGetMetafileHeaderFromStream(stream, header);
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
|
|
|
PlayRecord(EmfPlusRecordType recordType, UINT flags, UINT dataSize, const BYTE *data)
|
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
return SetStatus(DllExports::GdipPlayMetafileRecord(GetNativeMetafile(), recordType, flags, dataSize, data));
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Status
|
|
|
|
SetDownLevelRasterizationLimit(UINT metafileRasterizationLimitDpi)
|
|
|
|
{
|
2020-01-01 08:06:34 +00:00
|
|
|
return SetStatus(
|
|
|
|
DllExports::GdipSetMetafileDownLevelRasterizationLimit(GetNativeMetafile(), metafileRasterizationLimitDpi));
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
GpMetafile *
|
|
|
|
GetNativeMetafile() const
|
|
|
|
{
|
|
|
|
return static_cast<GpMetafile *>(nativeImage);
|
2019-12-29 14:21:05 +00:00
|
|
|
}
|
2020-01-01 10:10:47 +00:00
|
|
|
|
|
|
|
// get native
|
|
|
|
friend inline GpMetafile *&
|
|
|
|
getNat(const Metafile *metafile)
|
|
|
|
{
|
|
|
|
return reinterpret_cast<GpMetafile *&>(const_cast<Metafile *>(metafile)->nativeImage);
|
|
|
|
}
|
2005-05-08 18:02:41 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif /* _GDIPLUSMETAFILE_H */
|