L_CompactFile
#include "l_bitmap.h"
L_INT EXT_FUNCTION L_CompactFile(pszSrcFile, pszDstFile, uPages, pLoadFileOption, pSaveFileOption)
/* name of the source file being compacted */ | |
/* name of the file in which the data will be written */ | |
L_UINT uPages; |
/* number of pages to copy */ |
pLOADFILEOPTION pLoadFileOption; |
/* optional pointer to the LOADFILEOPTION structure */ |
pSAVEFILEOPTION pSaveFileOption; |
/* optional pointer to the SAVEFILEOPTION structure */ |
Compacts TIFF files. It can also be used to copy or extract one or more pages from a TIFF file and copy them without recompression to another TIFF file.
Parameter |
Description |
pszSrcFile |
Character string containing the name of the file being compacted. All the pages will be read from this file. |
pszDstFile |
Character string containing the name of the file in which all the pages will be written. This cannot be NULL. If this is NULL, the function will return an error. The pages can be added to this file using the pSaveFileOption parameter. |
uPages |
Value that represents the number of pages to copy. Use 0 to copy all the pages. If uPages is > 0, only uPages will be copied to pszDstFile. |
pLoadFileOption |
Optional pointer to the LOADFILEOPTION structure, which can be used to specify a starting page. You can also speed up the access to the starting page using the IFD. You can pass NULL, which is equivalent to starting from the first page and to use the default load options. |
pSaveFileOption |
Optional pointer to the SAVEFILEOPTION structure, which can be used to specify where to save the data or how to modify an existing file. You can modify whether the new pages should appended, inserted or whether they should replace existing pages. Pass NULL to use the default save options. |
Returns
SUCCESS |
The function was successful. |
ERROR_COMPACT_ABORTED |
The function encountered an error while reading a page from the source file. Not all the pages have been copied to the destination file. |
< 1 |
An error occurred. Refer to Return Codes. |
Comments
The following members of the LOADFILEOPTION structure are important for this function:
PageNumber: specifies the start page. Page 0 is the first page, page 1 is the second page, etc. The pages will be read starting with this page.
Flags: specifies whether to use the IFD.
IFD: used only if Flags contains the ELO_USEIFD flag. If ELO_USEIFD is not set, the PageNumber references the beginning of the file.
If pSaveFileOption is NULL, then if pszDstFile exists, it will be overwritten regardless of its format. Also, defaults will be used when saving the file (it will be saved in Intel format). Refer to the SAVEFILEOPTION documentation. TIF files are saved in two possible byte orders: Intel or Motorola (see SAVEFILEOPTIONS.Flags and ESO_MOTOROLAORDER flag.
If pSaveFileOption is not NULL, the following members of the SAVEFILEOPTION structure are important for this function:
PageNumber: specifies the start page. This parameter is used as follows:
If ESO_INSERTPAGE is set in Flags, all the pages are inserted before this page.
If ESO_REPLACEPAGE is set in Flags, this page and the remaining uPages – 1 will be replaced.
If none of the above parameters are set, then:
If PageNumber is 0, the file will be overwritten.
If PageNumber is <> 0, the pages will be appended to the end of the file.
IFD: can be used to speed up the file access for TIFF files with many pages. Used only if ESO_USEIFD is set in Flags.
Flags: can be used to specify one or more options:
ESO_NOSUBFILETYPE – if this flag is set, then the TGSUBFILETYPE tag will be stripped from all the pages.
ESO_REPLACEPAGE – if this is set, pages in pszDstFile are replaced starting with page PageNumber.
ESO_INSERTPAGE - if this is set, all the pages are inserted before page PageNumber.
ESO_USEIFD – if this is set, the first page in pszDstFile is at offset IFD. All pages will be relative to that page. (Note that this might not be the first physical page in the file). This is a common technique for manipulating files with thousands of pages.
ESO_MOTOROLAORDER – if this is set and you are creating a new file, the pages will be saved in Motorola byte order. If the flag is not set, the pages will be saved in Inter byte order. If you are modifying an existing file, this flag has no meaning – the pages will be saved in the same byte order used in the file.
Required DLLs and Libraries
LTFIL LFTIF For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
Platforms
Windows 95 / 98 / Me, Windows 2000 / XP.
See Also
Functions: |
L_SaveFile, L_LoadFile, L_FileInfo, L_GetDefaultLoadFileOption, L_GetDefaultSaveFileOption |
Topics: |
|
|
|
|
Example1
/* This example will compact all the pages in a TIFF file. It will create a new file called dstfile.tif */
L_INT nRet;
nRet = L_CompactFile("srcfile.tif", "dstfile.tif", 0, NULL, NULL);
if(nRet != SUCCESS)
MessageBox(NULL, "Error compacting file!", "ERROR", MB_OK);
Example2
/* This example will compact all the pages in a TIFF file. It will append all the pages to an existing file called dstfile.tif */
L_INT nRet;
SAVEFILEOPTION SaveFileOption;
L_GetDefaultSaveFileOption(&SaveFileOption, sizeof(SaveFileOption));
SaveFileOption.PageNumber = 2;
nRet = L_CompactFile("srcfile.tif", "dstfile.tif", 0, NULL, &SaveFileOption);
if(nRet != SUCCESS)
MessageBox(NULL, "Error compacting file!", "ERROR", MB_OK);