#include
#include
#include
#include
#include
#include
#pragma comment (lib,"Shlwapi.lib")
#pragma comment(lib,"gdiplus.lib")
#pragma comment(lib, "shell32.lib")
using namespace Gdiplus;
int main(int argc, char **argv)
{
static HMETAFILE hmf;
static int cxClient, cyClient;
HBRUSH hBrush;
HDC hdcMeta;
METAFILEPICT mp;
HDC hDC;
BYTE\* buffer;
GdiplusStartupInput gdiplusStartupInput;
ULONG\_PTR gdiplusToken;
GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);
hdcMeta = CreateMetaFile("12\_.WMF");
hBrush = CreateSolidBrush(RGB(, , ));
Rectangle(hdcMeta, , , , );
MoveToEx(hdcMeta, , , NULL);
LineTo(hdcMeta, , );
MoveToEx(hdcMeta, , , NULL);
LineTo(hdcMeta, , );
SelectObject(hdcMeta, hBrush);
Ellipse(hdcMeta, , , , );
hmf = CloseMetaFile(hdcMeta);
UINT nSize = GetMetaFileBitsEx(hmf, 0, NULL);
buffer = (BYTE\*)malloc(nSize);int err\_1 = GetLastError();
UINT bytesCopy = GetMetaFileBitsEx(hmf, nSize, buffer);
HENHMETAFILE hEMF = SetWinMetaFileBits(nSize, buffer, NULL, NULL);
int err\_2 = GetLastError();
HENHMETAFILE newHEMF = CopyEnhMetaFile(hEMF, "new EMF.emf");
DeleteMetaFile(hmf);
GdiplusShutdown(gdiplusToken);
return ;
}
GetMetaFileBitsEx需要调用两次,第二次调用是为了填充buffer缓冲区
手机扫一扫
移动阅读更方便
你可能感兴趣的文章