Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.11.1
LEADTOOLS Raster Imaging C DLL Help

L_CompactFile

Show in webframe

#include "l_bitmap.h"

L_LTFIL_API L_INT L_CompactFile(pszSrcFile, pszDstFile, uPages, pLoadFileOption, pSaveFileOption)

L_TCHAR* pszSrcFile;

/* name of the source file being compacted */

L_TCHAR* pszDstFile;

/* 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:

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.

NOTE: To save a region inside a TIFF file, you must have an unlocked  Vector, Document,  or Medical Imaging license.

If pSaveFileOption is not NULL, the following members of the SAVEFILEOPTION structure are important for this function:

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

Win32, x64, Linux.

See Also

Functions:

L_SaveFile, L_LoadFile, L_FileInfo, L_GetDefaultLoadFileOption, L_GetDefaultSaveFileOption

Topics:

Loading and Saving Large TIFF Files

 

Raster Image Functions: Loading Files

 

Raster Image Functions: Saving Files

Example

The first example will compact all the pages in a TIFF file. It will create a new file called dstfile.tif. The second example will compact all the pages in a TIFF file. It will append all the pages to an existing file called dstfile.tif.

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName


 L_INT CompactFileFirstExample(L_VOID)
{
   L_INT nRet;
   nRet = L_CompactFile(MAKE_IMAGE_PATH(TEXT("clean.tif")),MAKE_IMAGE_PATH(TEXT("dstfile.tif")), 0, NULL, NULL);
   if(nRet != SUCCESS)
   {
      MessageBox(NULL, TEXT("Error compacting file!"), TEXT("ERROR"), MB_OK);
      return nRet;
   }
   return SUCCESS;
}

 L_INT CompactFileSecondExample(L_VOID)
{
   L_INT nRet;
   SAVEFILEOPTION SaveFileOption;
   nRet = L_GetDefaultSaveFileOption(&SaveFileOption, sizeof(SaveFileOption));
   if(nRet != SUCCESS)
      return nRet;
   SaveFileOption.PageNumber = 2;

   nRet = L_CompactFile(MAKE_IMAGE_PATH(TEXT("clean.tif")),MAKE_IMAGE_PATH(TEXT("dstfile.tif")), 0, NULL, &SaveFileOption); 
   if(nRet != SUCCESS) 
   {
      MessageBox(NULL, TEXT("Error compacting file!"), TEXT("ERROR"), MB_OK);
      return nRet;
   }
   return SUCCESS; 
}
Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.