ReadFileCommentOffset Example for C++ 5.0 and later
/* The following sample will create a file with an offset and will read a comment from the file it just saved: */
ILEADRaster * pRaster;
ILEADRasterVariant * pRasterVar;
void TestReadFileCommentOffset(ILEADRasterIO * pRasterIO)
{
short nRet; /* Return value */
/* Load an existing bitmap */
nRet = pRasterIO->Load(pRaster, TEXT("eagle.cmp"), 0, 1, -1);
if (nRet != 0)
{
MessageBox(NULL, "Load has failed!", "FAILURE", MB_OK);
return;
}
pRasterVar->Type = VALUE_STRING;
pRasterVar->PutStringValue(TEXT("This is a 29-character string"));
/* set and save a comment into a file with an offset */
pRasterIO->put_Comment(CMNT_SZARTIST, pRasterVar);
/* Save the image file with an offset inside the TOFFSET.TST file */
nRet = pRasterIO->SaveOffset(pRaster, TEXT("eagle.cmp"), 30, FILE_TIF, 1, QFACTOR_LEAD_0, SAVE_OVERWRITE);
/* free the bitmap */
pRaster->Free();
/* Notify the user with a message box */
if (nRet != 0)
{
MessageBox(NULL, TEXT("Error saving file"), TEXT("Error"), MB_OK);
return;
}
/***** Now load the file we just saved ****/
/* Get the comment size */
nRet = pRasterIO->ReadFileCommentOffset(TEXT("eagle.cmp"),
30,
pRasterIO->FileSizeWritten,
CMNT_SZARTIST,
pRasterVar);
MessageBox(NULL, pRasterVar->GetStringValue(), "SUCCESS", MB_OK);
return;
}