C++ Class Library

The LEADTOOLS C++ Class Library is a wrapper to the LEADTOOLS C API and provides only a subset of the features and functionality otherwise available in the LEADTOOLS C API. For more information about the full feature set of the LEADTOOLS C API, refer to LEADTOOLS C API Introduction.

Is this page helpful?

In this page

LFile::Compact

Summary

Compacts TIFF / BigTIFF files. It can also be used to copy or extract one or more pages from a TIFF / BigTIFF file and copy them without recompression to another TIFF / BigTIFF file.

Syntax

#include "ltwrappr.h"

L_INT LFile::Compact(pszDstFile, uPages, pLoadFileOption, pSaveFileOption)

Parameters

L_TCHAR * pszDstFile

Character string that contains 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.

L_UINT uPages

Number of pages to copy. Use 0 to copy all the pages. If uPages is > 0, only uPages will be copied to pszDstFile.

pLOADFILEOPTION 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 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

Value Meaning
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.
ERROR_TAG_VALUE_TOO_BIG This error can occur while converting BigTIFF files to regular TIFF files when the source file contains a 64-bit integer value that cannot be converted into a 32-bit integer value due to overflow. This error can occur because TIFF files do not support 64-bit integer values.
< 1 An error occurred. Refer to Return Codes.

Comments

This function can also be used to convert a TIFF file to BigTIFF and vice versa (BigTIFF -> TIFF).

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.

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

Flags: can be used to specify one or more options:

Flags2: Can be used to specify one or more of the following options:

Required DLLs and Libraries

Platforms

Win32, x64.

See Also

Functions

Topics

Example

Copied to clipboard
// Example 1 
L_INT LFile__CompactExample_1()  
{ 
   /* This example will compact all the pages in a TIFF file. */ 
   /* It will create a new file called dstfile.tif */ 
 
   LFile File; 
   L_INT nRet = 0 ; 
 
   File.SetFileName(MAKE_IMAGE_PATH(TEXT("clean.tif"))) ; 
 
   nRet = File.Compact(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; 
} 
 
// Example 2 
L_INT LFile__CompactExample_2()  
{ 
   /* This example will compact all the pages in a TIFF file.*/ 
   /* It will append all the pages to an existing file called dstfile.tif */ 
   LFile File; 
   SAVEFILEOPTION SaveFileOption; 
   L_INT nRet = 0 ; 
 
   File.SetFileName(MAKE_IMAGE_PATH(TEXT("clean.tif"))) ; 
 
   File.GetDefaultSaveFileOption(&SaveFileOption, sizeof(SaveFileOption)); 
   SaveFileOption.PageNumber = 2; 
 
   nRet = File.Compact(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; 
} 
Help Version 23.0.2024.2.29
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2024 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS Raster Imaging C++ Class Library Help
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.