LBitmapBase::Save

#include "ltwrappr.h"

virtual L_INT LBitmapBase::Save(nFormat, nBitsPerPixel, nQFactor, uFlags=SAVE_OVERWRITE, pSaveFileOption=NULL)

virtual L_INT LBitmapBase::Save(pszFile, nFormat, nBitsPerPixel, nQFactor, nPageNumber, uFlags)

virtual L_INT LBitmapBase::Save(pszFile, nFormat, nBitsPerPixel, nQFactor, uFlags=MULTIPAGE_OPERATION_OVERWRITE, pSaveFileOption=NULL)

virtual L_INT LBitmapBase::Save(nFormat, nBitsPerPixel, nQFactor, nPageNumber, uFlags)

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

nBitsPerPixel

Resulting file's pixel depth. Note that not all bits per pixel are available to all file formats. For valid values, refer to Formats of Output Files. 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.

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
LTFIL

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

Elements:

LFile::Compact, LBitmapBase::Load, Class Members

Topics:

Raster Image Functions: Saving Files

 

Raster Image Functions: Maintaining File Comments and Tags

 

Raster Image Functions: Compression Functions

 

Raster Image Functions: Loading and Saving Stamp Images

 

Raster Image Functions: Redirecting Input and Output

 

Raster Image Functions: Input and Output

 

Loading and Saving Images

Example

For an example of each form of LBitmapBase::Save, refer to LBitmapBase::Load.