LSegment::MrcSaveBitmap

#include "ltwrappr.h"

L_INT LSegment::MrcSaveBitmap(pBitmap, pCmpOption, pszFileName, nFormat, pSaveOptions)

Saves an MRC image contained in a bitmap to a file using the LEAD Proprietary T44 format.

Parameters

LBitmapBase * pBitmap

Pointer to an LBitmapBase object that references the bitmap to be saved.

pCOMPRESSIONOPTIONS pCmpOption

Pointer to the COMPRESSIONOPTIONS structure that contains the compression information to use when saving the file.

L_TCHAR * pszFileName

Character string that contains the output file name.

L_INT nFormat

Output file format. Possible values are:

Value Meaning
FILE_LEAD_MRC [314] LEAD Proprietary MRC. The default file extension is *.MRC.
FILE_TIF_LEAD_MRC [315] Tagged Image File with LEAD proprietary MRC. (Supports multi-page). The default file extension is *.TIF.
FILE_PDF_LEAD_MRC [338] PDF compression using MRC segmentation.

pSAVEFILEOPTION pSaveOptions

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

Returns

Value Meaning
SUCCESS The function was successful.
< 1 An error occurred. Refer to Return Codes.

Comments

Use this function to save the bitmap in one of the LEAD Proprietary MRC formats: either as a LEAD proprietary MRC format file (if the nFormat value is FILE_LEAD_MRC), as a TIF file with a LEAD MRC subtype format (if the nFormat value is FILE_TIF_LEAD_MRC or as multiple document PDF using segmentation capabilities (if the nFormat value is FILE_PDF_LEAD_MRC). When an nFormat value of FILE_LEAD_MRC is used, *.MRC is the default file extension. When an nFormat value of FILE_TIF_LEAD_MRC or *.TIF is the default file extension.

When an nFormat value of FILE_PDF_LEAD_MRC, *.PDF is the default file extension.

Use the LSegment::MrcSaveBitmap function to save a file in one of the LEAD proprietary MRC formats or PDF file based on LEAD segmentation technique if you want to:

Please note that the LEAD proprietary MRC and PDF format files are single-page file formats, while the TIF file with a LEAD MRC subtype formats are multi-paged file formats.

Use the LSegment::MrcSaveBitmapT44 function to save a file if it is necessary that the file be readable by any application that supports the T44 standard.

It is best to perform segmentation before calling the LSegment::MrcSaveBitmap function. Segmentation can be performed automatically by calling the LSegment::MrcSegmentBitmap function, or performed manually by calling the LSegment::MrcCreateNewSegment function.. Call the LSegment::MrcStartBitmapSegmentation function before calling any of the segmentation methods. When the LSegment class object is no longer needed, free it by calling the LSegment::MrcStopBitmapSegmentation function. For more information on segmentation, refer to General Segmentation, Auto-Segmentation, and Manual Segmentation.

When using the LSegment::MrcSaveBitmap function, segments can be any of the following types:

SEGTYPE_BACKGROUND

SEGTYPE_ONECOLOR

SEGTYPE_TEXT_1BIT_BW

SEGTYPE_TEXT_1BIT_COLOR

SEGTYPE_TEXT_2BITBW

SEGTYPE_TEXT_2BIT_COLOR

SEGTYPE_GRAYSCALE_2BIT

SEGTYPE_GRAYSCALE_8BIT

SEGTYPE_PICTURE

If the bitmap hasnt been segmented, then the function will automatically segment the bitmap by calling LSegment::MrcSegmentBitmap and then save the image file. The LSegment::MrcSegmentBitmap function maps the text, grayscale and picture segments into layers (mask, background and foreground layers) as defined in the NLS* model of the T.44 standard. A segment is a rectangular area on the bitmap that can be classified as text, grayscale, or picture, depending on the number of colors used in its area. The Mixed Raster Content (MRC) format was developed by the International Telecommunications Union as part of ITU-T Recommendation T.44. For more information on Mixed Raster Content (MRC) formats, refer to General Information.

If the pCmpOption parameter is NULL, then the function will use Fax G4 compression for the mask layer, JPEG compression for the 24 bit image segments and 2 for the quality factor, JPEG compression for the 8 bit grayscale segments and 2 for the quality factor, and JBIG compression for the 2 bit text and 2 bit grayscale segments. For more information, refer to COMPRESSIONOPTIONS. Note that the nGrayscale2BitCoder, the nGrayscale8BitCoder, the nGrayscale8BitQFactor, and the nText2BitCoder members of the COMPRESSIONOPTIONS. structure is used with the FILE_TIF_LEAD_MRC and FILE_PDF_LEAD_MRC formats only.

Control page replacement/insertion operations using some of the member values available in the SAVEFILEOPTION structure.

*NLS (N-Layer stripe) means that each stripe may contain one or more mask layers, foreground layers, and background layers.

Required DLLs and Libraries

See Also

Elements

Topics

Example

The following example demonstrates the use of LSegment::MrcSaveBitmap to save a bitmap.

L_INT LSegment__MrcSaveBitmapExample(LSegment Segment, LBitmapBase & Bitmap, L_TCHAR * pszFileName) 
{ 
   L_INT                nRet; 
   COMPRESSIONOPTIONS   CmpOption; 
   /* Initialize the compression structure */ 
 
   CmpOption.uStructSize = sizeof(COMPRESSIONOPTIONS); 
   CmpOption.nMaskCoder = MRC_MASK_COMPRESSION_FAX_G3_1D; 
   CmpOption.nPictureCoder = MRC_PICTURE_COMPRESSION_JPEG; 
   CmpOption.nPictureQFactor = 10; 
   CmpOption.nGrayscale8BitCoder = MRC_GRAYSCALE_COMPRESSION_GRAYSCALE_CMW_8BIT; 
   CmpOption.nGrayscale8BitFactor = 2; 
   CmpOption.nGrayscale2BitCoder = MRC_GRAYSCALE_COMPRESSION_JBIG_2BIT; 
   CmpOption.nText2BitCoder = MRC_TEXT_COMPRESSION_JBIG_2BIT; 
 
   /* Save the MRC bitmap using the LEAD Proprietary T44 Format */ 
   nRet = Segment.MrcSaveBitmap(&Bitmap, &CmpOption, pszFileName, FILE_LEAD_MRC, NULL); 
   if (nRet != SUCCESS) 
      return nRet; 
 
   return SUCCESS; 
}  

Help Version 20.0.2019.11.25
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2020 LEAD Technologies, Inc. All Rights Reserved.

LEADTOOLS MRC C++ Class Library Help