#include "ltwrappr.h"

virtual L_INT LBitmapList::Save(lpszFile, nFormat, nBits, nQFactor, pSaveOptions=NULL)

L_TCHAR * lpszFile;

output file name

L_INT nFormat;

output file format

L_INT nBits;

resulting file's pixel depth

L_INT nQFactor;

quality factor


pointer to optional extended save options

Saves the class object's bitmap list in a multi-page file.




Character string containing the output file name.


Output file format. You can save multi-page images in PCX, GIF, and most TIFF file formats (including JTIF, but excluding EXIF). For possible values, refer to Files To Be Included With Your Application.


Single image formats are also valid (although only one image can be stored).


Resulting file's pixel depth. For possible values, refer to Formats of Output Files. If nBits is 0, the file will be stored using the closest BitsPerPixel value supported by that format. For example, if a file format supports 1, 4, and 24 BitsPerPixel, and LBitmapBase::GetBitsPerPixel returns 5, the file will be stored as 24 bit. Likewise, if LBitmapBase::GetBitsPerPixel returns 2, the file will be stored as 4 bit.


This parameter is used when saving an image to file format that supports quality factor (QFactor). QFactor is a number that determines the degree of loss in the compression process.


For possible values, refer to Compression Quality Factors.


Pointer to optional extended save options. Pass NULL to use the default save options.



The function was successful.

< 1

An error occurred. Refer to Return Codes.


Single-image formats are also valid for output, but only the first image in the list is saved.

This function does not support signed data images, unless they are DICOM images. It returns the error code ERROR_SIGNED_DATA_NOT_SUPPORTED if a signed data image that is not a DICOM image is passed to this function.

In LEADTOOLS version 17 and up, when saving a colored image (such as a 24-bits per pixel image) to bitonal (1-bit per pixel), the toolkit will not use any dithering when converting the image data. This is done because dithering is not the recommended when converting colored images containing text for document processing such as OCR and Barcode. The result text will be fuzzy and hard for a recognition engine to process. To save a colored image as bitonal with Floyd-Stein dithering (the behavior of LEADTOOLS 16.5 and earlier) use the ESO_USEDITHERINGMETHOD along with LBitmapBase::SetDitheringMethod as illustrated below:

// 'leadBitmap' is a colored LBitmapBase 
// 'leadFile' is LFile object 
// Setup FloydStein dithering: 
SAVEFILEOPTION saveOptions = {0}; 
leadFile.GetDefaultSaveFileOption(&saveOptions, sizeof(SAVEFILEOPTION)); 
leadFile.Save(FILE_CCITT_GROUP4, 1, 0, 0, &saveOptions); 
// or any other Save overloads or methods 

Required DLLs and Libraries


For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application.


Win32, x64.

See Also


Class Members


Raster Image Functions: Playing Animated Images


Implementing Animation


L_INT LBitmapList__SaveExample(L_TCHAR  * pszFileName) 
   L_INT nRet; 
   LBitmapList BitmapList; 
   LBitmap Bitmap; 
   L_INT nCount, i; 
   BitmapList.Load (pszFileName); 
   nCount = BitmapList.GetItemsCount (); 
   /* Change the hue of each bitmap in the list, 
   and restore the transparent color as the last color in the palette */ 
   for (i = 0; i < nCount; ++i) 
      nRet =BitmapList.GetItem (i, &Bitmap, sizeof(BITMAPHANDLE)); 
      if(nRet !=SUCCESS) 
         return nRet; 
      nRet =Bitmap.ChangeHue(i * 10); 
      if(nRet !=SUCCESS) 
         return nRet; 
      nRet =BitmapList.SetItem (i, &Bitmap); 
      if(nRet !=SUCCESS) 
         return nRet; 
   nRet =BitmapList.Save (pszFileName, FILE_GIF, 8, 0, NULL); 
   if(nRet !=SUCCESS) 
      return nRet; 
   return SUCCESS; 

Help Version 19.0.2017.10.27
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.
LEADTOOLS Raster Imaging C++ Class Library Help