I need to save a Multi-page TIFF file using L_SaveFileOffset because I need to make sure no other process including Windows itself can access the file in the middle of saving pages and as far as I know L_SaveFileOffset is the only API for saving in <strong>LeadTools</strong> that allows saving the image using a file handle. The problem is, no matter what I do, only the last page gets saved. Please Help.<br /><br />
<pre>
HANDLE hFile = ::CreateFile(L"ColorMaps.tif", GENERIC_READ | GENERIC_WRITE, FILE_SHARE_READ, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL);
if(NULL != hFile)
{
const wchar_t pathTemplate[] = {L"ColorMap%d.bmp"};
wchar_t tPath[sizeof(pathTemplate) / sizeof(pathTemplate[0])];
FILEINFO PageInfo;
SAVEFILEOPTION so;
LOADFILEOPTION tlo;
int i;
HDC hDc;
BITMAPHANDLE tBmp;
__int64 tSize;
memset(&tlo, 0, sizeof(LOADFILEOPTION));
tlo.uStructSize = sizeof(LOADFILEOPTION);
L_GetDefaultLoadFileOption(&tlo, sizeof(LOADFILEOPTION));
tlo.Flags |= ELO_ROTATED;
hDc = ::GetDC(NULL);
tlo.XResolution = ::GetDeviceCaps(hDc, LOGPIXELSX);
tlo.YResolution = ::GetDeviceCaps(hDc, LOGPIXELSY);
::ReleaseDC(NULL, hDc);
memset(&so, 0, sizeof(SAVEFILEOPTION));
so.uStructSize = sizeof(SAVEFILEOPTION);
so.Flags = ESO_INSERTPAGE;
memset(&tBmp, 0, sizeof(BITMAPHANDLE));
tBmp.uStructSize = sizeof(BITMAPHANDLE);
for(i = 1; i < 7; i++)
{
::StringCbPrintf(tPath, sizeof(tPath), pathTemplate, i);
L_FileInfo(tPath, &PageInfo, sizeof(FILEINFO), 0, &tlo);
L_LoadBitmap(tPath, &tBmp, sizeof(BITMAPHANDLE), 0, ORDER_RGBORGRAY, &tlo, &PageInfo);
if (TOP_LEFT != tBmp.ViewPerspective)
L_ChangeBitmapViewPerspective(NULL, &tBmp, sizeof(BITMAPHANDLE), TOP_LEFT);
L_SaveFileOffset((L_HFILE)hFile, 0, &tSize, &tBmp, FILE_TIF_PACKBITS, PageInfo.BitsPerPixel, 0, SAVEFILE_MULTIPAGE, NULL, NULL, &so);
so.PageNumber = i + 1;
}
::CloseHandle(hFile);
}
</pre>
<br />
The above is just an example and there might be 1000's of pages being saved into the TIFF file.<br />
The problem shows itself if a user opens <strong>Windows Explorer</strong> and navigates to the directory were the file is being saved, you can see that windows is trying to repaint the icon for the file in between each page save and if I use L_SaveBitmap or L_SaveFile, sometimes they return <strong><em>-14</em></strong> because windows is reading the file and <strong>LeadTools</strong> cannot get a lock on it.<br />
P.S. L_SaveFileOffset returns <strong>1</strong> (<em>SUCCESS</em>) for all the pages and I am using <strong>LeadTools Documents imaging version 17.5</strong>.<br />
Thank you