L_SaveBitmapList

#include "l_bitmap.h"

L_LTFIL_API L_INT L_SaveBitmapList(lpszFile, hList, nFormat, nBits, nQFactor, pSaveOptions)

L_TCHAR* lpszFile;

output file name

HBITMAPLIST hList;

handle to the list of bitmaps

L_INT nFormat;

output file format

L_INT nBits;

resulting file's pixel depth

L_INT nQFactor;

quality factor

pSAVEFILEOPTION pSaveOptions;

pointer to optional extended save options

Saves a list of bitmaps in a multi-page file.

Parameter

Description

lpszFile

Character string containing the output file name.

hList

Handle to the list of bitmaps.

nFormat

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 Formats of Output Files.

 

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

nBits

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 closet BitsPerPixel value supported by that format. For example, if a file format supports 1, 4, and 24 BitsPerPixel, and the pBitmap->BitsPerPixel is 5, the file will be stored as 24 bit. Likewise, if the pBitmap->BitsPerPixel is 2, the file will be stored as 4 bit.

nQFactor

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.

pSaveOptions

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

Returns

SUCCESS

The function was successful.

< 1

An error occurred. Refer to Return Codes.

Comments

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

Note:

More options are available in the SAVEFILEOPTION structure.

This function supports signed data images, but only DICOM and TIFF formats support signed data. This function will return an error code if you attempt to save a signed image to a format other than DICOM or TIFF.

If the bitmap has a region, the region stored in the bitmap will be saved (if the image is saved as one of the TIFF file formats).

You can convert one file format to another when you save a file. You can also use the high-level function, L_FileConvert, to convert any possible format to any other possible format.

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 recommended when converting colored images containing text for document processing such as OCR and Barcode. Dithering causes the resulting text to 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 BITMAPHANDLE.DitheringMethod as illustrated below:

// 'pBitmap' is a colored BITMAPHANDLE 
// Setup FloydStein dithering: 
bitmapHandle.DitheringMethod = FLOYD_STEIN_DITHERING; 
SAVEFILEOPTION saveOptions = {0}; 
L_GetDefaultSaveFileOption(&saveOptions, sizeof(SAVEFILEOPTION)); 
saveOptions.Flags |= ESO_USEDITHERINGMETHOD; 
// Save the bitmap as 1-bpp with auto-dithering: 
L_SaveBitmap(fileName, &bitmapHandle, FILE_CCITT_GROUP4, 1, 0, &saveOptions); 
// or any other L_SaveBitmapXyz or L_SaveFileXyz functions such as: 
// L_SaveFile(fileName, &bitmapHandle, FILE_CCITT_GROUP4, 1, 0, 0, NULL, NULL, &saveOptions) 

Required DLLs and Libraries

LTFIL
File format DLLs

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_LoadBitmapList, L_CreateBitmapList, L_DestroyBitmapList, L_CopyBitmapListItems, L_GetBitmapListCount, L_InsertBitmapListItem, L_RemoveBitmapListItem, L_DeleteBitmapListItems, L_GetBitmapListItem, L_SetBitmapListItem, L_ColorResBitmapList, L_TranslateBitmapColor, L_SetComment, L_DlgSave, L_FileConvertL_AddPageNumbersToBitmapList

Topics:

Raster Image Functions: Playing Animated Images

 

Raster Image Functions: Saving Files

 

Implementing Animation

Raster Image Functions: Creating and Maintaining Lists of Images

For a list of functions that utilize the LOADFILEOPTION or SAVEFILEOPTION structures, refer to Functions Utilizing the LOADFILEOPTION or SAVEFILEOPTION structures.

Example

For complete sample code, refer to the CHILD.C module of the DEMO example. This example saves a list of 8-bit bitmaps as an animated GIF file.

#define MAKE_IMAGE_PATH(pFileName) TEXT("C:\\Users\\Public\\Documents\\LEADTOOLS Images\\")pFileName 
L_INT SaveBitmapListExample(HBITMAPLIST hList, 
pBITMAPHANDLE LeadBitmap ) 
{ 
   L_INT nRet; 
   BITMAPHANDLE TmpBitmap; /* Temporary bitmap handle  */ 
   SAVEFILEOPTION SaveFileOption; /* File options when saving */ 
   /* Get a copy of the first image's bitmap handle */ 
   nRet = L_GetBitmapListItem(hList, 0, &TmpBitmap, sizeof(BITMAPHANDLE)); 
   if(nRet != SUCCESS) 
      return nRet; 
   /* Get the default SAVEFILEOPTION values */ 
   nRet = L_GetDefaultSaveFileOption(&SaveFileOption, sizeof(SAVEFILEOPTION)); 
   if(nRet != SUCCESS) 
      return nRet; 
   /* Use the target bitmap's palette as the global palette */ 
   nRet = L_GetBitmapColors(LeadBitmap, 0, 256, SaveFileOption.GlobalPalette); 
   if(nRet != SUCCESS) 
      return nRet; 
   /* Assign the other SAVEFILEOPTION fields */ 
   SaveFileOption.Flags = ESO_GLOBALBACKGROUND|ESO_GLOBALPALETTE; 
   SaveFileOption.GlobalWidth = TmpBitmap.Width; 
   SaveFileOption.GlobalHeight = TmpBitmap.Height; 
   SaveFileOption.GlobalLoop = 0; 
   SaveFileOption.GlobalBackground = LeadBitmap->Background; 
   /* Save the bitmap list as an animated GIF file */ 
   nRet = L_SaveBitmapList(MAKE_IMAGE_PATH(TEXT("testan.gif")), hList, FILE_GIF, 8, 0, &SaveFileOption); 
   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 API Help