#include "l_bitmap.h"
L_LTFIL_API L_INT L_SaveBitmapList(lpszFile, hList, nFormat, nBits, nQFactor, pSaveOptions)
Saves a list of bitmaps in a multipage file.
Character string containing the output file name.
Handle to the list of bitmaps.
Output file format. You can save multipage 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).
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.
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.
Value | Meaning |
---|---|
SUCCESS | 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.
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
Win32, x64, Linux.
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.
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 Collections
Raster .NET | C API | C++ Class Library | HTML5 JavaScript
Document .NET | C API | C++ Class Library | HTML5 JavaScript
Medical .NET | C API | C++ Class Library | HTML5 JavaScript
Medical Web Viewer .NET
Multimedia
Direct Show .NET | C API | Filters
Media Foundation .NET | C API | Transforms
Supported Platforms
.NET, Java, Android, and iOS/macOS Assemblies
Imaging, Medical, and Document
C API/C++ Class Libraries
Imaging, Medical, and Document
HTML5 JavaScript Libraries
Imaging, Medical, and Document