Quantcast
Channel: .NET Framework Class Libraries forum
Viewing all articles
Browse latest Browse all 8156

PlayRecord Callback is not triggered

$
0
0

Hello,

I'm currently exploring "gdiplus" in order to parse the records of an EMF file stored locally on my disk.

I have followed the recommendations I found online, but somehow the callback for playing the records is not triggered.

I am able to read the header, but when I call EnumerateMetafile, the metaCallback is not triggered.


I am dumping my code below and would highly appreciate any feedback.

Thanks!

class EMF2GDI {
public:
static BOOL CALLBACK metaCallback(Gdiplus::EmfPlusRecordType recordType, unsigned int flags, unsigned int dataSize, const unsigned char* pStr, void* callbackData) {
cout << "In callback function...\n";

// Play only EmfPlusRecordTypeFillEllipse records.
if (recordType == EmfPlusRecordTypeFillEllipse) {
// Explicitly cast callbackData as a metafile pointer, and use it to call
// the PlayRecord method.
//pThis->m_pMetafile->PlayRecord(recordType, flags, dataSize, pStr);
static_cast < Gdiplus::Metafile* > (callbackData)->PlayRecord(recordType, flags, dataSize, pStr);

}
return TRUE;
}

VOID EnumerateMetaFile_Click() {
//HDC hdc = CreateCompatibleDC(NULL);
//Gdiplus::Graphics graphics(hdc);

// Create a Metafile object from an existing disk metafile.
// This constructor creates a Metafile::Metafile object for playback
Status status;
Gdiplus::Metafile* pMeta = new Gdiplus::Metafile(L"C:\\Users\\yonatan\\AppData\\Local\\Temp\\16400300003000000.emf");
//use the meta as an argument to the constructor to open for reading
Gdiplus::Graphics g(pMeta);
Gdiplus::MetafileHeader* header = new Gdiplus::MetafileHeader();
status = pMeta->GetMetafileHeader(L"C:\\Users\\yonatan\\AppData\\Local\\Temp\\16400300003000000.emf", header);
BOOL dual = header->IsEmfPlusDual();
BOOL plusOnly = header->IsEmfPlusOnly();

//HENHMETAFILE hEmf = pMeta->GetHENHMETAFILE();
//Gdiplus::Metafile* playbackMeta = new Gdiplus::Metafile(hEmf, TRUE);
//pView->m_pMetafile = playbackMeta;
EMF2GDI* pView = new EMF2GDI();
Gdiplus::Point* point = new Gdiplus::Point(0, 0);

////Gdiplus::Point* pointArray = new Gdiplus::Point[1];
////pointArray[0] = new Gdiplus::Point(0, 0)
Gdiplus::EnumerateMetafileProc* enumMetaCB = new Gdiplus::EnumerateMetafileProc(&metaCallback);
////graphics.EnumerateMetafile(curMetafile, point, 1, EMF2GDI::EnumMetaCB);

g.EnumerateMetafile(pMeta, *point, metaCallback, pMeta);

// Draw pMeta as an image.
//graphics.DrawImage(pMeta, Point(0, 150));
delete pMeta;
}
};


int _tmain(int argc, _TCHAR* argv[]) {

//initialize GDI plus
cout << "Initializing GDI...\n";

//Initializw gdi plus
GdiplusStartupInput gdiplusStartupInput;
ULONG_PTR           gdiplusToken;

GdiplusStartup(&gdiplusToken, &gdiplusStartupInput, NULL);

EMF2GDI emf2gdi;
emf2gdi.EnumerateMetaFile_Click();

//Shut down GdiPlus
GdiplusShutdown(gdiplusToken);

//Adding a return 0 to main will close the console app
//return 0;
}


Viewing all articles
Browse latest Browse all 8156

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>