Available in LEADTOOLS Imaging Pro, Vector, Document, and Medical Imaging toolkits. |
LBitmapBase::Save
#include "ltwrappr.h"
virtual L_INT LBitmapBase::Save(nFormat, nBitsPerPixel, nQFactor, uFlags, pSaveFileOption=NULL)
virtual L_INT LBitmapBase::Save(pszFile, nFormat, nBitsPerPixel, nQFactor, nPageNumber, uFlags)
virtual L_INT LBitmapBase::Save(pszFile, nFormat, nBitsPerPixel, nQFactor, uFlags, pSaveFileOption=NULL)
virtual L_INT LBitmapBase::Save(nFormat, nBitsPerPixel, nQFactor, nPageNumber, uFlags)
L_TCHAR * pszFile; |
/* output file name */ |
L_INT nFormat; |
/* output file format */ |
L_INT nBitsPerPixel; |
/* Resulting file's pixel depth. */ |
L_INT nQFactor; |
/* quality factor */ |
L_INT nPageNumber; |
/* the page number */ |
L_UINT uFlags; |
/* flag that indicates how to save a new page */ |
pSAVEFILEOPTION pSaveOptions; |
/* pointer to optional extended save options */ |
Saves the class object's bitmap image to a file in any of the supported compressed or uncompressed formats.
Parameter |
Description |
|
pszFile |
Character string containing the output file name. |
|
nFormat |
Output file format. For valid values, refer to Summary of File Formats. |
|
nBitsPerPixel |
Resulting file's pixel depth. Note that not all bits per pixel are available to all file formats. For valid values, refer to Summary of File Formats. If nBitsPerPixel 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 file to FILE_CMP, FILE_JPEG, FILE_JPEG_411, FILE_JPEG_422, FILE_TIF_JPEG, FILE_LEAD1JTIF, FILE_LEAD2JTIF, FILE_FPX_JPEG_QFACTOR, FILE_EXIF_JPEG, and FILE_PNG. Qfactor is a number that determines the degree of loss in the compression process. |
|
|
For possible values, refer to Compression Quality Factors. |
|
nPageNumber |
Represents a page number in a multipage file. This parameter is used only if the uFlags parameter is MULTIPAGE_OPERATION_REPLACE or MULTIPAGE_OPERATION_INSERT. If uFlag is MULTIPAGE_OPERATION_REPLACE, nPageNumber represents the number of the page to replace (the first page is page 1). If uFlags is MULTIPAGE_OPERATION_INSERT, nPageNumber represents the number of the page in front of which the new page will be inserted. For example, if nPageNumber is 1 and uFlags is MULTIPAGE_OPERATION_INSERT, then the page you save will become the first page in the file. |
|
uFlags |
Flag that indicates how to save a new page in a multipage file that supports insert and replace operations. Possible values are: |
|
|
Value |
Meaning |
|
MULTIPAGE_OPERATION_OVERWRITE |
[1] No insert/replace/append is performed. An existing file is overwritten. This is comparable to bMultipage being FALSE in earlier versions. |
|
MULTIPAGE_OPERATION_APPEND |
[2] or [-1] The page is appended if the file exists. |
|
MULTIPAGE_OPERATION_REPLACE |
[3] Replace the page specified in the nPage. |
|
MULTIPAGE_OPERATION_INSERT |
[4] Insert the new page before the page specified in the nPage. |
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
The image will be saved to the file specified by the last call to LBitmapBase::SetFileName or to the file last loaded by LBitmapBase::Load.
If the bitmap is 8 bits per pixel or greater, use the LEAD CMP format or one of the JPEG (JTIF or JFIF) formats to save disk space.
NOTE: 4:1:1 and 4:2:2 formats use subsampling for the color components. In the case of 4:1:1, the color components for 4 pixels is averaged during compression. This will cause a color shift, but the shift is tolerable for low compression ratios. If you have high compression and repeated savings, then the color shift will increase. Due to this characteristic of the JPEG algorithm, the only ways to avoid this are to: (a) use 4:4:4 (which has no subsampling), or (b) avoid repeated load and resave.
If the bitmap is 1-bit per pixel, use the LEAD 1-bit format or a CCITT Group 3 or 4 format to save disk space.
For CCITT Group 3 and 4 formats, the first RGBQUAD structure in the bitmap handle's hPalette field determines the white component of the image. If the rgbRed field is 0, then all 0 bits in the image are assumed to be black. Otherwise, all zero (0) bits in the image are assumed white.
Support for 12 and 16-bit grayscale images is only available in the Document/Medical toolkits.
The following file formats support append operations:
TIFF (most TIFF formats, including JTIF but excluding EXIF)
PCX
FlashPix
AWD
Winfax
GIF
The following file formats support replace operations:
TIFF (most TIFF formats, including JTIF but excluding EXIF)
PCX
The following file formats support insert operations:
TIFF (most TIFF formats, including JTIF but excluding EXIF)
PCX
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.
Required DLLs and Libraries
LTDIS For a listing of the exact DLLs and Libraries needed, based on the toolkit version, refer to Files To Be Included With Your Application. |
See Also
Functions: |
|
Topics: |
|
|
|
|
|
|
|
|
|
|
|
|
Example
For an example of each form of LBitmapBase::Save, refer to LBitmapBase::Load.