Hmm... there is an Exporting Graphic Files section in the SDK help file. If it's not in your version, redownload the SDK.
There is no Export example though, here is one. Note: I didn't try to compile this code, hopefully it works - let me know if there are any error.
Code:
// Export a surface as image file
//
// Note: fileName is overwritten by this function, it should contain at least MAX_PATH characters)
//
void ExportBitmapFile(LPRH rhPtr, LPSURFACE psf, LPSTR fileName)
{
DWORD dwFilterID = 0;
CImageFilterMgr pMgr = rhPtr->rh4.rh4Mv->mvImgFilterMgr;
OPENFILENAME ofn;
char szFileName[_MAX_PATH];
char szFileTitle[_MAX_PATH];
memset((LPVOID)&ofn, 0, sizeof(OPENFILENAME));
ofn.lStructSize = sizeof(OPENFILENAME);
szFileName[0] = 0;
szFileTitle[0] = 0;
ofn.hwndOwner = rhPtr->rhHMainWin;
ofn.lpstrFile = szFileName;
ofn.nMaxFile = sizeof(szFileName);
ofn.nFilterIndex = 1;
ofn.lpstrFileTitle = (LPTSTR)szFileTitle;
ofn.nMaxFileTitle = sizeof(szFileTitle);
ofn.Flags = OFN_PATHMUSTEXIST | OFN_OVERWRITEPROMPT | OFN_HIDEREADONLY | OFN_EXPLORER | OFN_NOCHANGEDIR;
// setup initial file name
strcpy(szFileName, (LPCSTR)fileName);
// Open selector and choose picture filename and format
if ( ChoosePicture(&ofn, FALSE, pMgr, &dwFilterID, PICSEL_IMAGES) )
{
// Return filename
fileName = ofn.lpstrFile;
// Export image
if ( !ExportImage(pMgr, fileName, psf, dwFilterID) )
{
// Error
}
}
}
PS: if you want to force the filter ID (= file format) and/or don't want a file selector, remove the call to ChoosePicture and use one of the predefined filters ID's (FILTERID_BMP, FILTERID_PNG, FILTERID_JPEG).