Products | Support | Send comments on this topic. | Email a link to this topic. | Back to Getting Started | Help Version 18.0.10.24
LEADTOOLS Raster imaging C++ Class library help

LBitmapBase::Save

Show in webframe

#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 Files To Be Included With Your Application..

nBitsPerPixel

Resulting file's pixel depth. Note that not all bits per pixel are available to all file formats. For valid values, refer to Files To Be Included With Your Application.. 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 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.

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.

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:
leadBitmap.SetDitheringMethod(FLOYD_STEIN_DITHERING);
SAVEFILEOPTION saveOptions = {0};
leadFile.GetDefaultSaveFileOption(&saveOptions, sizeof(SAVEFILEOPTION));
saveOptions.Flags |= ESO_USEDITHERINGMETHOD;
leadFile.Save(FILE_CCITT_GROUP4, 1, 0, 0, &saveOptions);
// or any other Save overloads or methods

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.

Platforms

Win32, x64.

See Also

Functions:

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

 

Files and File Formats

Example

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

Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.