WriteMarkerAction example for C++ 5.0 and later
void CTutorDlg::OnButtonWritemarker()
{
ILEADRasterIO *pRasterIO=NULL;
CoCreateInstance(CLSID_LEADRasterIO, NULL, CLSCTX_ALL, IID_ILEADRasterIO, (void**)&pRasterIO);
DWORD dwCookie;
CRasterIOSink *pRasterIOSink;
//Instantiate the sink class and hold a pointer to it.
pRasterIOSink = new CRasterIOSink;
pRasterIOSink->m_pDlg = this;
pRasterIOSink->m_pRasterIO = pRasterIO;
//Establish a connection between source and sink.
LPUNKNOWN pUnkSink = pRasterIOSink->GetIDispatch(FALSE);
AfxConnectionAdvise(pRasterIO, DIID__LEADRasterIOEvents, pUnkSink, FALSE, &dwCookie);
// Rotate the file 90 degrees
pRasterIO->TransformFile("c:\\temp\\1.jpg", "c:\\temp\\2.jpg", FILE_TRANSFORM_ROTATE90, 1);
//Terminate a connection between source and sink.
pUnkSink = pRasterIOSink->GetIDispatch(FALSE);
AfxConnectionUnadvise(pRasterIO, DIID__LEADRasterIOEvents, pUnkSink, FALSE, dwCookie);
delete pRasterIOSink;
pRasterIOSink = NULL;
pRasterIO->Release();
}
void CRasterIOSink::OnTransformMarker ( short iMarker, long lSize, ILEADRasterVariant * vData, short iTransform )
{
ILEADRasterVariant * pltRasVar = NULL;
CoCreateInstance(CLSID_LEADRasterVariant, NULL, CLSCTX_ALL,
IID_ILEADRasterVariant, (void **)&pltRasVar);
// I will replace the comment present in the file with my own comment
if(iMarker == 0xFE)
{
pltRasVar->Type = VALUE_STRING;
pltRasVar->StringValue = "My comment";
m_pRasterIO->WriteMarkerAction = WRITEMARKER_IGNORE;
m_pRasterIO->WriteMarker(iMarker, 10,pltRasVar );
}
pltRasVar->Release();
}