Introduction

The LEADTOOLS Class Library provides C++ classes to let you incorporate image compression, file format support, and image processing into your Windows applications.

Raster Content format was defined for use for color and grayscale fax as part of the RFC-2301, File Format for Internet Fax. The Mixed Raster Content mode (T.44) enables different coding methods and resolutions to be used within a single page by defining a 3-layer image model for structuring and combining the scanned image data. The image is segmented and each segment assigned a type based on the number of colors used in that segment. Segments can be combined and compressed using different compression schemes to create a file that balances quality with compression.

This help file contains only the documentation for the functions in the LEADTOOLS MRC Class Library.

The Class Library comes in a WIN32 edition and supports development of software applications for any of the following environments:

Windows 3.x NT
Windows 4.x NT
Windows 95

Windows 98

Windows 2000

Windows ME
Windows XP

LEADTOOLS support for Mixed Raster Content format, defined for use for color and grayscale fax as part of the T44 standard, is provided by the LSegment class. The LSegment class is derived from LBase and provides the ability to work with Mixed Raster Content files. The class enables the user to produce MRC images, save to MRC files, and load from MRC files. This help file documents this class.

Introduction To Image Processing with LEADTOOLS

Compression Using LEAD and JPEG Formats

Summary of All Supported Image File Formats

Compression Quality Factors

Please note that due to the large size of the PDF files that contain the LEADTOOLS manuals, these files are no longer included in the setup. Instead, these PDF files can be downloaded from our website at http://support.leadtools.com/SupportPortal/DesktopDefault.aspx?tabindex=3&tabid=27.


Compression Using LEAD and JPEG Formats

Compression of color and grayscale graphic image files is useful because the files are big. They can range from 100 kilobytes to more than 200 megabytes. Compressing the image files does the following:

Dramatically decreases the storage requirements

Improves the input and output speed within a system

Improves the transmission speed over networks or phone lines

By incorporating the LEAD and JPEG image compression, you can develop applications that would be impractical otherwise. Image files can be reduced to 200 times smaller than their original size.

The LEAD CMP compression format was created by LEAD Technologies, Inc., and it delivers a much smaller file size and better image quality than other compression techniques, including JPEG.

LEAD's CMP file format allows for decompression to a 24-bit medium at 24-bit color and to an 8-bit medium at 8-bit color without sacrificing image quality. This eliminates the need to convert all images to 8 bits in order to support the low end users or to save one 8-bit file and one 24-bit file. The result is one much smaller file size that can be viewed on a 24-bit video card at 24-bit true color, as well as on an 8-bit VGA card at 256 colors.

LEAD's CMW format uses Wavelet CMP compression. Currently, 24 color images and 8, 12 and 16-bit grayscale images are supported in this format. (This is available only in the LEADTOOLS CMW Plug in. 12 and 16-bit formats also require the Medical capabilities)

Summary of All Supported Image File Formats describes the LEAD and JPEG compression formats, in addition to other formats that LEADTOOLS supports.

The amount of compression is controllable, allowing the compressed image quality to match the needs of your application. Compression Quality Factors describes how the quality factors are used.

JPEG Compliant

LEADTOOLS Class Library is fully JPEG compliant. Any file using compression that is compliant with the JPEG Interchange File Format can be viewed and converted.

However, some images that are not fully compliant with the JPEG specification will be displayed upside-down. (The JPEG Interchange File Format specifies that all images must be stored top-down.) You can change the orientation of an image by modifying the ViewPerspective flag in the LEAD bitmap handle.

JPEG 2000 Compliant

LEADTOOLS Class Library can load and save JPEG 2000 files. You can load 24-48 bit color images (images with 25-47 bits/pixel will be loaded as 48-bit). You can load 8-16 bit grayscale images. Images with 9-11 bits/pixel will be loaded as 12-bit while images with 13-15 bit are loaded as 16 bits/pixel.

You can save 24 and 48-bit color images and 8, 12 and 16-bit grayscale images.

LEADTOOLS supports JPEG2000 stream (J2K) and JP2 format files. LEADTOOLS supports the mandatory boxes of the JP2 format only.

4 and 1-bit Images

JPEG and LEAD CMP compression are intended for use with high resolution images, and they are impractical for use with 4- or 1-bit images.

You can use the CCITT, LEAD 1-bit, RLE, LZW, and ZIPLib compression methods available in many of LEADTOOLS supported formats.

8 and 24-bit Images

Using JPEG, JPEG2000 and LEAD CMP or CMW compression, color images are 24 bits per pixel, and grayscale images are 8 bits per pixel. Therefore, to compress an 8-bit color image, the internal JPEG, JPEG2000 and LEAD CMP or CMW compression functions must convert the 8-bit data into raw RGB 24-bit before compressing it as a color image.

Compressing the original 24-bit image will result in a smaller file size and higher quality than compressing an optimized 8-bit color image.

LEADTOOLS functions compress 8-bit grayscale as 8-bit grayscale JPEG or CMP images.

You can use RLE, LZW and ZIPLib (PNG) compression methods available in many of LEADTOOLS supported formats.


Compression Quality Factors

You can specify a quality factor when saving an image file to LEAD, JFIF, LEAD2JFIF, LEAD2JFIF, JTIF, LEAD1JTIF, and LEAD2JTIF. The quality factor (Q factor) is a number that determines the degree of loss in the compression process. You can set a value from 2 to 255, where 2 is the highest quality and 255 is the most compression.

For JFIF and JTIF compression only, you can also use a factor of 0 to produce lossless JPEG files

For LEAD CMP compression only, you can also use one of the following enhanced options:

Q Factor | Predefined options for LEAD only
PQ1 | Perfect quality 1 This option compresses all colors of a 24-bit file and maintains the quality of the original image at a smaller file size. As the name suggests, there is no visual loss of color at this setting.
PQ2 | Perfect quality 2 This will produce a smaller file size than PQ1 while maintaining similar quality.
QFS | Quality far more important than size This option removes colors not noticed by the human eye. Most viewers cannot tell the difference between an image compressed at this level and the original image.
QMS | Quality more important than size While more colors are removed, most of them are colors or shades that are close to one another. The compressed image will appear very much like the original image. It will take some study to see the difference.
QS | Quality and size equally important This option provides the highest compression while maintaining good image quality. Try this option first, then move up or down the list accordingly to obtain acceptable compression size and image quality.
SQS | Size more important that quality (sharp) This option is recommended for images that have sharp edges. For example, an image that has a text overlay or an image with many straight lines. While it creates a larger file than the next option, it retains better edges.
SQT | Size more important than quality (less tiling) This option produces less tiling in the image than the previous options. However, it may distort text or straight lines. It is a good option for image database applications.
MCQ | Maximum compression keeping quality This option provides maximum compression while maintaining as high as possible image quality.
MC | Maximum compression This option gives maximum compression. It is equivalent to a Q factor of 255.

For the PNG format, the qFactor can be a value between 0 and 9. 0 = (default compression), 1 (fastest compression) ... 9 (highest compression ratio)


Compression Quality Factors in the LEADTOOLS MRC Class

It is possible to set one or more quality factors when saving an image file to the LEAD MRC, MRC, TIF LEAD MRC, or TIF MRC format. The quality factor (Q factor) is a number that determines the degree of loss in the compression process. Possible values range from 2 to 255, where 2 is the highest quality and 255 is the most compression. These values are set using the members of the COMPRESSIONOPTIONS structure.

When saving a file that has 8-bit grayscale segments in the LEAD MRC or TIF LEAD MRC format (using the LSegment::MrcSaveBitmap function), use a COMPRESSIONOPTIONS.nGrayscale8BitQFactor property of 0 to produce lossless CMW or lossless JPEG files when selecting those as the nGrayscale8BitCoder. Otherwise, set the nGrayscale8BitQFactor property to a value from 2 to 255, where 2 is the highest quality and 255 the most compression.

When saving a file in the standard MRC or TIF MRC format (using the LSegment::MrcSaveBitmapT44 function), the only valid picture compression (COMPRESSIONOPTIONS.nPictureCoder value) is MRC_PICTURE_COMPRESSION_JPEG. Set the quality factor using the nPictureQFactor member; setting a value from 2 to 255, where 2 is the highest quality and 255 the most compression.


Example Programs

The following example programs are in separate EXAMPLES subdirectories (such as C:\LEAD14\EXAMPLES\CLASSLIB\MSVC5\SEGDEM). The executable files for these examples were compiled with Document/Medical capabilities of the toolkit. To get Document/Medical capabilities, you must buy the LEADTOOLS Document/Medical editions toolkit. Otherwise, if you recompile the examples, the resulting executable files will not have the Document/Medical capabilities.

Note:

You can run the example programs on your system by clicking the appropriate buttons in online help. If you try to run an example program that is not on your system, an error message will appear.

SEGDEM

SEGDEM Demo demonstrates the LEADTOOLS bitmap segmentation.


Version History

Current version: | 14.5
Last update: | October 20, 2005

Changes from Version 14 to Version 14.5

Changes from Version 13 to Version 14

Version 13


Changes from Version 14 to Version 14.5

Version 14.5 of the LEADTOOLS Mixed Raster Contents Class Library has not changed from Version 14.

New functions

LSegment::MrcSaveBitmapList

LSegment::MrcSegmentBitmapExt

LPDFCompressor::Free

LPDFCompressor::Init

LPDFCompressor::InsertMRC

LPDFCompressor::InsertNormal

LPDFCompressor::Write

LPDFCompressor::ImageCallBack

New structure

SEGMENTEXTOPTIONS


Changes from Version 13 to Version 14

Version 14 of the LEADTOOLS Mixed Raster Contents Class Library has changed from Version 13 as follows:

LEADTOOLS Mixed Raster Contents Class Library now supports UNICODE.

Changed functions

The following functions have been changed from the previous version of LEADTOOLS:

LSegment::MrcLoadBitmap takes a new parameter uStructSize.

LSegment::MrcSegmentBitmap has different parameters.

LSegment::MrcEnumSegments has different parameters.

LSegment::MrcSaveBitmap has different parameters.

LSegment::MrcSaveBitmapT44 has different parameters.

LSegment::MrcEnumSegmentsCallBack has different parameters.

Deleted functions

LSegment::MrcEndBitmapSegmentation has been changed to LSegment::MrcStopBitmapSegmentation.

LSegment::MrcSetStripeSegment has been changed to LSegment::MrcCreateNewSegment.

LSegment::MrcUpdateSegmentData has been changed to LSegment::MrcSetSegmentData.

LSegment::MrcSetNewStripe

LSegment::MrcSetStripeMaxHeight

LSegment::MrcSegmentBitmapCallBack

The rest of this topic lists the new functions:

LSegment::MrcCopySegmentationHandle

LSegment::MrcCreateNewSegment

LSegment::MrcLoadSegmentation

LSegment::MrcSaveSegmentation

LSegment::MrcSetSegmentData

LSegment::MrcStopBitmapSegmentation


Version 13

Version 13 is the first version of the LEADTOOLS MRC Class Library.

The rest of this topic lists the new functions.

LSegment::LSegment

LSegment::~LSegment

LSegment::MrcStartBitmapSegmentation

LSegment::MrcEndBitmapSegmentation

LSegment::MrcSetStripeMaxHeight

LSegment::MrcSegmentBitmap

LSegment::MrcSegmentBitmapCallBack

LSegment::MrcEnumSegments

LSegment::MrcEnumSegmentsCallBack

LSegment::MrcDeleteSegment

LSegment::MrcUpdateSegmentData

LSegment::MrcSetNewStripe

LSegment::MrcSetStripeSegment

LSegment::MrcGetPagesCount

LSegment::MrcSaveBitmap

LSegment::MrcSaveBitmapT44

LSegment::MrcLoadBitmap


Copyright notice

Copyright Notices

©Copyright LEAD Technologies, Inc. 1991-2005. ALL RIGHTS RESERVED

Portions of the PCDLIB32.DLL, PCDLIB.DLL, LFFPX7.DLL, LFKODAK.DLL, EKFPIXJPEG140.DLL, PDC_SDK.DLL, PROFIRE.DLL, DC120V154_32.DLL, LFDCR14N.DLL, DCSPROBACK.DLL, DCSPRO3SLR.DLL, LFDCS14N.DLL, and LFKDC14N.DLL files contain material that is ©Copyright Eastman Kodak Company, 1996-2001. This software is based in part on the work of the Independent JPEG Group.

Portions of the LFCRW14N.DLL, LTCMP14.DLL, CDSDK.reg, CDSDK.dll, CDRAPCLS.dll, czs_ui.dll, deimg.dll, deImg010.dll, deImg110.dll, deImg153.dll, deimg301.dll, deimg401.dll, deImg404.dll, deimg602.dll, Deimg603.dll, DeImgd60.dll, pscAdimg.dll, pscCllct.dll, pscCStUI.dll, pscDcd.dll, pscDevUI.dll, pscDvlp.dll, Pscl2STI.dll, pscll.dll, pscParse.dll, pscSetup.dll, psdkdll.dll, psdkReg.dll, psParse.dll. file contain material that is © Canon, Inc. 2002

Portions of the LFFPX7.DLL and LFKODAK.DLL files contain material that is ©Copyright Hewlett Packard, 1996.

Portions of the OCR/ICR/OMR Features and the help file for the OCR/ICR/OMR Features are ©Copyright Scansoft, Inc. 1995-2003. ALL RIGHTS RESERVED

Portions of the Barcode Modules contain material that is ©Copyright Axtel Inc., 1999.

Portions of the LEADTOOLS PDF Plug in and the LEADTOOLS Vector Imaging Pro are ©Copyright 1996, 2000 Artifex Software Inc. All rights reserved.

File filters for decoding MrSID ® and DjVu ® formats are provided under a license from Lizardtech, Inc.

The "FlashPix" format uses Microsoft's OLE structured storage.

Portions of the DICOM help files in Medical Imaging product line are reprinted with permission from the National Electrical Manufacturers Association ©Copyright 1998 by the National Electrical Manufacturers Association. All rights including translation into other languages, reserved under the Universal Copyright Convention, the Berne Convention or the Protection of Literacy and Artistic Works, and the International and Pan American Copyright Conventions.

Portions of LEADTOOLS Data Security Add On contain software developed by the OpenSSL Project for use in the OpenSSL Toolkit (http://www.openssl.org/), including cryptographic software written by Eric Young (eay@cryptsoft.com) and by Tim Hudson (tjh@cryptsoft.com). Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) All rights reserved. Copyright Tim Hudson 1995-1998 (tjh@cryptsoft.com) All rights reserved.

Portions of LEADTOOLS Data Security Add On contain software based on the MD5 Message Digest Algorithm developed by RSA Data Security, Inc.. Copyright (c) 1991-92 RSA Data Security, Inc. All Rights Reserved.

Portions hereof licensed under US patent 5,327,254 and foreign counterparts.

Portions of the LEADTOOLS ICC Profiles material is © Copyright 2004, International Color Consortium.

Trademarks

LEAD® and LEADTOOLS® are registered trademarks of LEAD Technologies, Inc.
Microsoft, Windows, Windows NT, Visual Basic, Visual FoxPro, and Microsoft Access are either trademarks or registered trademarks of the Microsoft Corporation.
OS/2® is a registered trademark of International Business Machines Corporation.

TextBridge®OCR is a registered trademark of Scansoft, Inc.

ISIS® is a registered trademark of Pixel Translations, Inc.

ScanAhead™ is a trademark of Pixel Translations, Inc.

FlashPix™ is a trademark of Eastman Kodak Company.

All other brand or product names used in this online help are trademarks of their respective holders.

Address and Contact Information

LEAD Technologies, Inc.
Suite 400
1201 Greenwood Cliff
Charlotte, NC 28204

(704) 332-5532
FAX: (704) 372-8161
E-mail: support@leadtools.com
Technical support: (704) 372-9681 or support@leadtools.com
Home page: http://www.leadtools.com


Programming with LEADTOOLS

The following topics provide a systematic approach to understanding how to program with the LEADTOOLS MRC Class Library.

Working with the LEADTOOLS MRC Module

General Information

Loading Capabilities

Saving Capabilities

General Segmentation

Auto-Segmentation

Manual Segmentation

Example and Summary

Working with the PDF Compressor

Creating a Compressed PDF File

Saving PDF Files with MRC Segmentation


General Information

The Mixed Raster Content (MRC) format was developed by the International Telecommunications Union as part of ITU-T Recommendation T.44, and is defined in the proposed standard, RFC-2301, File Format for Internet Fax. The MRC model divides a page into strips and up to 3 layers: consisting of Mask, Foreground and Background layers. Each layer can be coded and compressed independently. Subsequently, these layers can be uncompressed and combined to restore the original image.

The advantage of the MRC model is that optimal compression methods can be selected for the various image and text components of documents, resulting in both high compression factors and high detail retention. Image and text components may be mixed on the same page.

The MRC compression breaks an image into three kinds of layers: foreground, background, and mask layers, each of which is compressed separately. These layers can be uncompressed and combined to restore the original image.

A foreground layer contains color data for the text and line art, and may also contain photographic or continuous tone color data. The background layer generally contains low-resolution color image data, such as a background image, a wash or other pattern that would have text overlaid on it. The mask layer or the selector layer that controls the process of image LEADTOOLS offers the LEADTOOLS MRC (Mixed Raster Content) API module to handle mixed raster content files, expanding LEADTOOLS input/output functionality by adding support for color documents which contain mixed image and text components.

LEADTOOLS also provides support for PDF compression with MRC segmentation. This compression is used to break down a page/image into smaller segments, saving each segment using compression appropriate for that segment. Thus, one page of a PDF file may have an image JPEG compressed, some text JBIG2 compressed, and another area CCITT compressed. This whole process works to provide a PDF file with better compression and better quality than just a standard Raster PDF file.

regeneration contains binary image data that is high spatial resolution, such as text and line art. This layer is used for drawing the corresponding foreground layer where the selector value is 1 and drawing the corresponding background layer where the selector value is 0. (For example: a high-resolution color font can be represented using significantly less space, since the color information is stored at a lower resolution.)

Note:

The characteristics of individual images differ greatly and not every image compresses well as mixed raster content.


Loading Capabilities

To load a Mixed Raster Content (MRC) bitmap call the LSegment::MrcLoadBitmap function. This function loads a single page from a MRC file. When loading from a multi-page document, specify the page number as one of the input parameters. To get the total pages in the MRC file call the LSegment::MrcGetPagesCount function.


Saving Capabilities

A file can be saved using the LEAD Proprietary MRC Format, the Standard MRC format, or PDF format with MRC segmentation. To save the bitmap in the LEAD Proprietary MRC, MRC TIF, or in PDF format, call the LSegment::MrcSaveBitmap function, or call LSegment::MrcSaveBitmapList to save a multi-page file. To save the bitmap in Standard MRC or in the TIF format, call the LSegment::MrcSaveBitmapT44 function.

The LEAD proprietary MRC formats used by the LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList function differ from the Standard MRC format used by the LSegment::MrcSaveBitmapT44 function in the following ways:

when using the LEAD Proprietary MRC formats, segments can be 1-bit black and white, 1-bit color, 2-bit color, 2-bit grayscale, 8-bit grayscale, or picture. When using the standard MRC format, segments can be 1-bit black and white, 1-bit color, or picture.

while any application that supports the T44 standard can open a file saved in those formats, only an application with LEADMrc support can open a file saved in one of the LEAD proprietary MRC formats.

saving a given bitmap in one of the LEAD proprietary MRC formats creates a smaller file than saving the same bitmap in the Standard MRC format.

saving a given bitmap in one of the LEAD proprietary MRC formats creates a higher quality file than saving the same bitmap in the Standard MRC format.

when saving a multipaged file as a Standard MRC format (MRC), only one page can be saved. The LEAD Proprietary MRC formats (LEAD-MRC and LEAD-MRC2) are single page file formats.

Note:

The characteristics of individual images differ greatly and not every image compresses well as mixed raster content.

The LEADTOOLS implementation of the MRC model involves dividing an object into segments. 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. Segmentation can be performed automatically, manually, or internally. Different types of compression are available, depending upon which save method is being used as well as which segment type is being compressed.

All save functions use the COMPRESSIONOPTIONS structure to specify the compression and quality factor information for the file. The following members of this structure are used to specify compression and quality characteristics to be used when saving an MRC file:

nMaskCoder

nPictureCoder

nPictureQFactor

In addition, when saving a bitmap in one of the LEAD Proprietary MRC formats, the following members of the COMPRESSIONOPTIONS structure can be used to specify compression and quality for the additional segment types available to that format:

nGrayscale2BitCoder

nGrayscale8BitCoder

nGrayscale8BitQFactor

nText2BitCoder

LSegment::MrcSaveBitmap and LSegment::MrcSaveBitmapList use the COMPRESSIONOPTIONS structure to specify the compression and quality factor information for the PDF file. The following members of this structure are used to specify compression and quality characteristics to be used when saving an PDF file:

nMaskCoder

nPictureCoder

nPictureQFactor

nText2BitCoder

With LEADTOOLS it is easy to handle the segmentation process, whether
 performing segmentation automatically using the LSegment::MrcSegmentBitmap
 or the LSegment::MrcSegmentBitmapExt
 function or manually using the LSegment::MrcCreateNewSegment
 function.


General Segmentation

With LEADTOOLS it is easy to handle the segmentation process, whether performing segmentation automatically or manually. A segment is a rectangular area on the bitmap. A segment's type depends on the content of its area. The segmentation process classifies the segments of a bitmap as background, text, grayscale or picture. Call the LSegment::MrcStartBitmapSegmentation function to initialize the segmentation process, before calling any of the segmentation methods. When the LSegment class object is no longer needed, free it by calling the LSegment::MrcStopBitmapSegmentation function.

Each call to the LSegment::MrcStartBitmapSegmentation function requires a corresponding call to the LSegment::MrcStopBitmapSegmentation function.


Auto-Segmentation

Calling the LSegment::MrcSegmentBitmap function will perform automatic segmentation using the LEADTOOLS MRC engine. LEADTOOLS segments the bitmap, classifying the segments as background, text, grayscale or picture. Use the SEGMENTATIONOPTIONS structure to control the segmentation process.

It is also possible to use the LSegment::MrcSegmentBitmapExt function to perform automatic segmentation.

To enumerate the segments, call LSegment::MrcEnumSegments. This function provides the segment coordinates, types and their IDs. To modify a segment type or its coordinates, use the LSegment::MrcSetSegmentData function. This function will update only one segment’s data each time it is called. To delete a segment, call the LSegment::MrcDeleteSegment function. To combine two segments, call the LSegment::MrcCombineSegments function. To copy the segmentation handle and data, call the LSegment::MrcCopySegmentationHandle function.

Save the segmentation handle and data to a file by calling the LSegment::MrcSaveSegmentation function. To load the saved segmentation handle and data from a file, call the LSegment::MrcLoadSegmentation function.


Manual Segmentation

To use manual segmentation, call the LSegment::MrcCreateNewSegment function to add a new segment and customize the segment coordinates and type. To modify a segment type or its coordinates, use the LSegment::MrcSetSegmentData function. This function will update only one segment’s data each time it is called. To delete a segment, call the LSegment::MrcDeleteSegment function.

Save the segmentation handle and data to a file by calling the LSegment::MrcSaveSegmentation function. To load the saved segmentation handle and data from a file, call the LSegment::MrcLoadSegmentation function.


Example and Summary

A scenario for using the above functions in order to save a page as MRC or PDF is as follows:

1. | Start up the segmentation process by calling LSegment::MrcStartBitmapSegmentation.
2. | Segment the page by calling LSegment::MrcSegmentBitmapExt.
3. | Change some properties of the segments by calling LSegment::MrcSetSegmentData and LSegment::MrcEnumSegments.
4. | Delete some segments by calling LSegment::MrcDeleteSegment and LSegment::MrcEnumSegments.
5. | Combine segments by calling LSegment::MrcCombineSegments and LSegment::MrcEnumSegments.
6. | Copy the segmentation handle and data to another handle by calling LSegment::MrcCopySegmentationHandle.
7. | Call LSegment::MrcSaveSegmentation to save the resulting segments to a file. To load segments that have bee saved to a file, call LSegment::MrcLoadSegmentation.
8. | Call LSegment::MrcSaveBitmapT44 to save the page as a Standard T44 file OR Call LSegment::MrcSaveBitmap to save the page using LEAD Proprietary T44 Format.
9. | Call LSegment::MrcSaveBitmapList to save a multi page file using Standard T44 format, LEAD Proprietary T44 format or PDF format.
10. | End the segmentation process by calling LSegment::MrcStopBitmapSegmentation.

The functionality provided by this module can be broken into the following categories:

1. | Start up and end the segmentation process:
 | LSegment::MrcStartBitmapSegmentation
 | LSegment::MrcSegmentBitmapExt
2. | Automatic segmentation of a page:
 | LSegment::MrcSegmentBitmap
3. | Manual segmentation of a page:
 | LSegment::MrcCreateNewSegment
4. | Manipulating segments:
 | LSegment::MrcSetSegmentData
 | LSegment::MrcCombineSegments
 | LSegment::MrcCopySegmentationHandle
 | LSegment::MrcDeleteSegment
 | LSegment::MrcEnumSegments
 | LSegment::MrcLoadSegmentation
 | LSegment::MrcSaveSegmentation
5. | Saving a page as MRC or PDF:
 | LSegment::MrcSaveBitmapT44
 | LSegment::MrcSaveBitmap
6. | Saving multiple pages as MRC or PDF:
 | LSegment::MrcSaveBitmapList
7. | Loading an MRC file:
 | LSegment::MrcLoadBitmap
 | LSegment::MrcGetPagesCount


Working with the LEADTOOLS Mixed Raster Content Class

Working with the LEADTOOLS Mixed Raster Content (MRC) Class Library

LEADTOOLS offers the LEADTOOLS Mixed Raster Content (MRC) Class Library to handle mixed raster content files. This class library enhances LEADTOOLS input/output functionality by adding support for color documents containing mixed image and text components. The Mixed Raster Content (MRC) format was developed by the International Telecommunications Union as part of ITU-T Recommendation T.44, and is defined in the proposed standard, RFC-2301, File Format for Internet Fax. The MRC model divides a page into strips and up to 3 layers: consisting of Mask, Foreground and Background layers. Each layer can be coded and compressed independently. Subsequently, these layers can be uncompressed and combined to restore the original image.

The LEADTOOLS implementation of the MRC model involves dividing an object into segments. 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.

LEADTOOLS offers several functions for saving files: the LSegment::MrcSaveBitmap, LSegment::MrcSaveBitmapT44 and LSegment::MrcSaveBitmapList functions. With these functions it is possible to save an MRC bitmap in any of the following modes:

MRC: This mode uses the Standard MRC file format. The default extension is *.MRC. Please note that multipage files using this format can be loaded, but only one page can be saved. Use the LSegment::MrcSaveBitmapT44 function to save a file in this format.

LEAD MRC: This mode uses the LEAD proprietary MRC file format. The default extension is *.MRC. Please note that this is a single page file format. Use the LSegment::MrcSaveBitmap function to save a file in this format.

TIF-MRC: This mode uses the Tagged Image Format and the Standard MRC format as a subtype. The default extension is *.TIF. Multipage files using this format can be loaded and can also be saved. Use the LSegment::MrcSaveBitmapT44 function to save a file in this format.

TIF-LEAD-MRC: This mode uses the Tagged Image Format and the LEAD proprietary MRC format as a subtype. The default extension is *.TIF. Multipage files using this format can be loaded and can also be saved. Use the LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList function to save a file in this format.

The Standard MRC format file uses two different segment types: 1-bit Text and picture. The 1-bit text segments can be compressed using Fax G3 1D, Fax G3 2D, Fax G4 or JBIG compression and picture segments can be compressed using JPEG compression. Some of these compression schemes use a quality factor that allows the amount of compression to be controlled.

The LEAD proprietary MRC formats use the following segment types: 1-bit text, 2-bit text, 2-bit picture grayscale, 8-bit grayscale, and picture. The 1-bit text segments can be compressed using Fax G3 1D, Fax G3 2D, Fax G4 or JBIG compression. The 2 bit grayscale segments can be compressed using JBIG compression. The 8-bit grayscale segments can be compressed using JPEG, LEAD CMP or LEAD CMW compression, and pictures can be compressed using JPEG, LEAD CMP or LEAD CMW compression. Some of these compression schemes use a quality factor that allows the amount of compression to be controlled.


Creating a Compressed PDF File

The PDF Plug-in also provides support for the PDF Compressor. Through MRC segmentation, this compressor can be used to break down a page/image into smaller segments, saving each segment using compression appropriate for that segment. Thus, one page of a PDF file may have an image JPEG compressed, some text JBIG2 compressed, and another area CCITT compressed. This whole process works to provide a PDF file with better compression and better quality than just a standard Raster PDF file.

The PDF Compressor is initialized by calling LPDFCompressor::Init. In addition to initializing the compressor, this function also creates an empty PDF file in memory. With a new PDF file created, the user may insert data to that new file. The user has the option of inserting material that has or has not been segmented using MRC Segmentation.

To insert data in the new PDF file that is MRC segmented, call LPDFCompressor::InsertMRC. This function will use MRC segmentation to segment the data, and will compress each segment using the most suitable compression, based on input and output profiles. Those profiles are provided in the imageQuality and outputQuality members of the PDFCOMPOPTIONS structure.

To insert data that is not MRC segmented in the new PDF file, call LPDFCompressor::InsertNormal. This function compresses the input image as one image and inserts it in the PDF file in memory.

The user can also insert user-defined segments into a PDF file. This is done using the LPDFCompressor::InsertSegments function, which applies a specific set of segments to a bitmap, then compresses and inserts the resulting image into the PDF file in memory.

Any time MRC segmented data is inserted using LPDFCompressor::InsertMRC, or anytime an image is inserted by calling LPDFCompressor::InsertNormal, the LPDFCompressor::ImageCallback is called, if LBase::EnableCallBack was called previously with bEnable set to TRUE. This callback function allows the user to accept the insertion of the segment and continue to the next segment, or reject the insertion of the current segment and continue to the next segment. Within the LPDFCompressor::ImageCallBack function, the user should return SUCCESS to add the current segment and continue with the process, or FAILURE, to not add this segment and proceed with the next one.

Before inserting images or segments into a PDF file, the user should set the compression type. The LPDFCompressor::SetCompression function lets the user specify the type of compression to use for 1-bit, 2-bit and picture segments. This function must be called before inserting a compressed image into the PDF file using LPDFCompressor::InsertNormal, before inserting an MRC segment using LPDFCompressor::InsertMRC, or before inserting a user-defined segment using LPDFCompressor::InsertSegments. If the user does not call LPDFCompressor::SetCompression before using these functions, then the default compression types are used.

After all data has been written to the file in memory, the file in memory should be written to a file on disk using LPDFCompressor::Write. Once the file has been written to disk somewhere, the user must free all associated memory by calling LPDFCompressor::Free. Please note that if LPDFCompressor::Free is called before the file in memory has been written to a file on disk, the PDF file in memory will be destroyed and all the data in that file will be lost. This should be the last function called when working with the PDF compressor.


Saving PDF Files with MRC Segmentation

The LEADTOOLS Class Library provides support for PDF compression with MRC segmentation. The MRC segmentation can be used to break down a page/image into smaller segments, saving each segment using compression appropriate for that segment. Thus, one page of a PDF file may have an image JPEG compressed, some text JBIG2 compressed, and another area CCITT compressed. This whole process works to provide a PDF file with better compression and better quality than just a standard Raster PDF file.

The Standard PDF format uses three different segment types: 1-bit Text, 2-bit Text and picture. The 1-bit text segments can be compressed using ZIP, LZW, Fax G3 1D, Fax G3 2D, Fax G4 or JBIG2 compression. The 2 bit grayscale segments can be compressed using ZIP or LZW compression and picture segments can be compressed using ZIP, LZW, or JPEG compression. Some of these compression schemes use a quality factor that allows the amount of compression to be controlled.

Following segmentation, the PDF file can be saved, as either a single or multi-page file, using the LSegment::MrcSaveBitmap, or LSegment::MrcSaveBitmapList functions. The default extension when saving PDF files is *.PDF.


Files To Be Included With Your Application

Note: | You may not copy or redistribute any of the following files without obtaining the proper license. In some cases, the license is included with your initial purchase of LEADTOOLS. In other cases, you must obtain a license from a third party or enter into a royalty agreement with LEAD to obtain the proper license. For these special licensing situations, see the notes below accompanying the specific file.
Note: | You may not distribute the header files with your application, and you may not provide software development capabilities in your application.

The following table summarizes the files you must include on your distribution diskettes to support the LEADTOOLS functions. These files are referred to as "Redistributables" in the License Agreement.

Please note that LTKRN and LTWVC is required for ALL Class library applications. For more information on LTKRN, LTWVC and other files for the Main Class Library, refer to Files To Be Included With Your Application .

Note: All Unicode versions of LEADTOOLS require Microsoft Unicode Layer for Windows (UNICOWS.DLL) in order to function on Windows 95/98/Me. You can obtain MSUL from: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnanchor/html/anch_mslu.asp.

Redistributables: | Explanation: | If you are using a standard release without Unicode, the files to use are: | If you are using a standard release with Unicode, the files to use are: | If you are using an evaluation release without Unicode, the files to use are: | If you are using an evaluation release with Unicode, the files to use are:
LTSGM | T44 Support. The header file is LTSGM.H. | DLL: LTSGM14N.DLL Library: LTSGM_N.LIB | DLL: LTSGM14NU.DLL Library: LTSGM_NU.LIB | DLL: LTSGM14E.DLL Library: LTSGM_E.LIB | DLL: LTSGM14EU.DLL Library: LTSGM_EU.LIB


Installation Directory

The installation procedure creates a directory tree for the LEADTOOLS files, and adds the demonstration programs and online help to your desktop. You specify the root directory during installation.

Please note that due to the large size of the PDF files that contain the LEADTOOLS manuals, these files are no longer included in the setup. Instead, these PDF files can be downloaded from our website at http://support.leadtools.com/SupportPortal/DesktopDefault.aspx?tabindex=3&tabid=27.

The following is a list of the subdirectories in the root directory:

ACROBAT | LEADTOOLS manuals in the PDF format, which you can view and print using Adobe Acrobat. These files are optional and are available when installing from the CD-ROM.
BIN | Executable files for the demonstration programs.
HELP | Online help files.
IMAGES | Sample images and databases containing images.
EXAMPLES\DLL | One subdirectory for each example API program.
EXAMPLES\OCX | One subdirectory for each example ActiveX program.
EXAMPLES\COM | One subdirectory for each example COM program.
EXAMPLES\CLASSLIB | One subdirectory for each example Class Library program.
EXAMPLES\RES | Resource files for the example programs.
INCLUDE | Header files, BAS files, and the ActiveX's MFC interface files for versions of Visual C++ earlier than 4.0.
INCLUDE\CLASSLIB | Header files for the Class Library
LIB | Library files.
REDIST | Redistributable files. These are copies of the LEADTOOLS files and other files that you may need to distribute with your application. For exact information about required files, refer to Files To Be Included With Your Application.


Classes

The following classes are provided by the LEADTOOLS MRC Class Library:

LPDFCompressor

LSegment


LPDFCompressor

Description

The LPDFCompressor class is derived from LBase, and provides support for the PDF Compressor. PDF documents can be created in memory and then saved to a file, with or without using segmentation. Through MRC segmentation, this compressor can be used to break down a page/image into smaller segments, saving each segment using compression appropriate for that segment. This whole process works to provide a PDF file with better compression and better quality than just a standard Raster PDF file.

Required Libraries

The following library should be loaded using LBase::LoadLibraries before using the class.

LTSGM

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

Class Members, Class Hierarchy Chart , Parent class


LPDFCompressor::Class Members

Constructors / Destructors

Initializing and Freeing the Compressor

Inserting Images / Pages

Saving a PDF File on Disk

Setting Compresstion Type

Return to LPDFCompressor

Constructors / Destructors

LPDFCompressor::LPDFCompressor

LPDFCompressor::~LPDFCompressor

Initializing and Freeing the Compressor

LPDFCompressor::Free

LPDFCompressor::Init

Inserting Images /Pages

LPDFCompressor::InsertMRC

LPDFCompressor::InsertNormal

LPDFCompressor::InsertSegments

LPDFCompressor::ImageCallBack

Saving a PDF File on Disk

LPDFCompressor::Write

Setting Compression Type

LPDFCompressor::SetCompression


LSegment

Description

The LSegment class is derived from LBase and provides the ability to work with Mixed Raster Content files. The class enables the user to produce MRC images, save to MRC files, and load from MRC files.

Required Libraries

The following library should be loaded using LBase::LoadLibraries before using the class.

LTSGM

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

Class Members, Class Hierarchy Chart , Parent class


LSegment::Class Members

Constructors / Destructors

Initializing / Ending Segmentation

Automatic Segmentation

Manual Segmentation

Manipulating Segments (Automatic Segmentation)

Saving an MRC Image

Loading an MRC Image

Callbacks

Return to LSegment

Constructors / Destructors

LSegment::LSegment

LSegment::~LSegment

Initializing / Ending Segmentation

LSegment::MrcStartBitmapSegmentation

LSegment::MrcStopBitmapSegmentation

Automatic Segmentation

LSegment::MrcSegmentBitmap

LSegment::MrcSegmentBitmapExt

Manual Segmentation

LSegment::MrcCreateNewSegment

Manipulating Segments

LSegment::MrcCombineSegments

LSegment::MrcCopySegmentationHandle

LSegment::MrcDeleteSegment

LSegment::MrcEnumSegments

LSegment::MrcGetHandle

LSegment::MrcLoadSegmentation

LSegment::MrcSaveSegmentation

LSegment::MrcSetSegmentData

Saving an MRC Image

LSegment::MrcSaveBitmap

LSegment::MrcSaveBitmapT44

LSegment::MrcSaveBitmapList

Loading an MRC Image

LSegment::MrcLoadBitmap

LSegment::MrcGetPagesCount

Callbacks

LSegment::MrcEnumSegmentsCallBack


Technical Support

As a registered user, free technical support is available. You must register your software to receive any technical support. Technical support is available 9 a.m. through 6 p.m. Eastern Standard Time. If you are calling by phone, please be at your computer. You can also contact us through the following methods:

Phone: | (704) 372-9681
E-mail: | support@leadtools.com
FAX: | (704) 372-8161
Home page: | http://www.leadtools.com
FTP: | ftp.leadtools.com

You can also contact LEAD by mail at:

LEAD Technologies, Inc.
Atten: Technical Support
Suite 400
1201 Greenwood Cliff
Charlotte, NC 28204

Before calling technical support, please look in the online documentation and the example programs for an answer to your question.


Class Library Function Groups

MRC Functions

LSegment::Class Members

PDF Compressor Functions

LPDFCompressor::Class Members


Data Types

Basic Data Types and Keywords

LEADTOOLS Basic Data Types

Keywords Used in Declarations

Window Structures

T44 Structures

SEGMENTDATA

MINSEGMENT

COMPRESSIONOPTIONS

SEGMENTATIONOPTIONS

SEGMENTEXTOPTIONS

PDF Compressor Structures

PDFCOMPRESSION

PDFCOMPOPTIONS

SEGMENTINFO

PDFCOMP_1BITCOMPTYPE

PDFCOMP_2BITCOMPTYPE

PDFCOMP_PICTURECOMPTYPE

PDFCOMP_OUTPUTQUALITY

PDFCOMP_IMAGEQUALITY


LEADTOOLS Basic Data Types

LEADTOOLS has defined the following basic data types for portability:

Data Type | Definition and Usage
L_BITFIELD | Defined as L_UINT; used as a bit field.
L_BOOL | Defined as L_UINT; used as a boolean value.
L_CHAR | Defined as char; used as a signed 8-bit integer.
L_DOUBLE | Defined as double; used as a double precision floating point number.
L_FLOAT | Defined as float; used as a floating point number.
L_INT | Defined as int; used as a signed integer, 16-bits or larger.
L_INT16 | Defined as short; used as a signed 16-bit integer.
L_INT32 | Defined as long; used as a signed 32-bit integer.
L_UCHAR | Defined as unsigned char; used as an unsigned 8-bit integer.
L_UINT | Defined as unsigned; used as an unsigned integer, 16-bits or larger.
L_UINT16 | Defined as unsigned short; used as an unsigned 16-bit integer.
L_UINT32 | Defined as unsigned long; used as an unsigned 32-bit integer.
L_VOID | Defined as void; used as a void.
L_COMP | Defined as L_UINT; used as a handle to a computer
L_MEDIA | Defined as L_VOID L_FAR *; used as a void pointer
L_TCHAR | Defined as either char or TCHAR. If FOR_UNICODE is defined, then L_TCHAR will be defined as TCHAR.


Keywords Used in Declarations

LEADTOOLS uses the following keywords in declarations of functions, structures, and datatypes:

Keyword | Definition and Usage
L_FAR | Defined as nothing; used as a placeholder.
L_HUGE | Defined as nothing; used as a placeholder.
L_EXPORT | Defined as nothing; used as a placeholder.
L_PASCAL | Defined as nothing; used as a placeholder.
EXT_FUNCTION | Defined as WINAPI; used as an attribute for all toolkit functions.
pEXT_FUNCTION | Defined as EXT_FUNCTION L_FAR *; used as an attribute when defining pointers to toolkit functions.
EXT_CALLBACK | Defined as _cdecl L_FAR; used as an attribute for all toolkit callback functions.
pEXT_CALLBACK | Defined as EXT_CALLBACK L_FAR *; used as an attribute when defining pointers to toolkit callback functions.


COMPRESSIONOPTIONS (Document/Medical only)

typedef struct _tagCOMPRESSIONOPTIONS
{
L_UINT uStructSize;
L_INT nMaskCoder;
L_INT nPictureCoder;
L_INT nPictureQFactor;
L_INT nGrayscale2BitCoder;
L_INT nGrayscale8BitCoder;
L_INT nGrayscale8BitFactor;
L_INT nText2BitCoder;
} COMPRESSIONOPTIONS, L_FAR * pCOMPRESSIONOPTIONS;

The COMPRESSIONOPTIONS structure contains compression information used with picture segments.

Member | Description
uStructSize | Size of this structure in bytes, for versioning. Use the sizeof() macro to calculate this value.
nMaskCoder | Flag that indicates the mask compression. Possible values are:
 | Value | Meaning
 | MRC_MASK_COMPRESSION_JBIG | [0x00] JBIG compression. This flag is used only if FILE_LEAD_MRC, FILE_TIF_LEAD_MRC, FILE_MRC, or FILE_TIF_MRC is set in the nFormat of either LSegment::MrcSaveBitmap, LSegment::MrcSaveBitmapT44 or LSegment::MrcSaveBitmapList.
 | MRC_MASK_COMPRESSION_FAX_G4 | [0x01] Fax group 4 compression. This flag is used only if FILE_LEAD_MRC, FILE_TIF_LEAD_MRC, FILE_MRC, or FILE_TIF_MRC is set in the nFormat of either LSegment::MrcSaveBitmap, LSegment::MrcSaveBitmapT44 or LSegment::MrcSaveBitmapList.
 | MRC_MASK_COMPRESSION_FAX_G3_1D | [0x02] Fax group 3 (1D) compression. This flag is used only if FILE_LEAD_MRC, FILE_TIF_LEAD_MRC, FILE_ MRC, or FILE_TIF_MRC is set in the nFormat of either LSegment::MrcSaveBitmap, LSegment::MrcSaveBitmapT44 or LSegment::MrcSaveBitmapList.
 | MRC_MASK_COMPRESSION_FAX_G3_2D | [0x03] Fax group 3 (2D) compression. This flag is used only if FILE_LEAD_MRC, FILE_TIF_LEAD_MRC, FILE_ MRC, or FILE_TIF_MRC is set in the nFormat of either LSegment::MrcSaveBitmap, LSegment::MrcSaveBitmapT44 or LSegment::MrcSaveBitmapList.
 | MRC_PDF_ONEBIT_COMPRESSION_ZIP | [0x04] ZIP compression. This flag is used only if FILE_PDF_LEAD_MRC is set in the nFormat of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.
 | MRC_PDF_ONEBIT_COMPRESSION_LZW | [0x05] LZW compression. This flag is used only if FILE_PDF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.
 | MRC_PDF_ONEBIT_COMPRESSION_CCITT_G3_1D | [0x06] Fax group 3 (1D) compression. This flag is used only if FILE_PDF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.
 | MRC_PDF_ONEBIT_COMPRESSION_CCITT_G3_2D | [0x07] Fax group 3 (2D) compression. This flag is used only if FILE_PDF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.
 | MRC_PDF_ONEBIT_COMPRESSION_CCITT_G4 | [0x08] Fax group 4 compression. This flag is used only if FILE_PDF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.
 | MRC_PDF_ONEBIT_COMPRESSION_JBIG2 | [0x09] JBIG2 compression. This flag is used only if FILE_PDF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.

nPictureCoder | Flag that indicates the background (picture) compression type. Possible values are:
 | Value | Meaning
 | MRC_PICTURE_COMPRESSION_CMW | [0x00] LEAD Wavelet (CMW) compression. This flag is used only if FILE_LEAD_MRC or FILE_TIF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.
 | MRC_PICTURE_COMPRESSION_LOSSLESS_CMW | [0x01] LEAD Wavelet lossless compression. This flag is used only if FILE_LEAD_MRC or FILE_TIF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.
 | MRC_PICTURE_COMPRESSION_CMP | [0x02] LEAD CMP compression. This flag is used only if FILE_LEAD_MRC or FILE_TIF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.
 | MRC_PICTURE_COMPRESSION_JPEG | [0x03] JPEG Compression. This flag is used only if FILE_LEAD_MRC, FILE_TIF_LEAD_MRC, FILE_MRC, or FILE_TIF_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap, LSegment::MrcSaveBitmapT44 or LSegment::MrcSaveBitmapList.
 | MRC_PICTURE_COMPRESSION_LOSSLESS_JPEG | [0x04] JPEG Lossless Compression. This flag is used only if FILE_LEAD_MRC, or FILE_TIF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap, LSegment::MrcSaveBitmapT44 or LSegment::MrcSaveBitmapList.
 | MRC_PICTURE_COMPRESSION_JPEG_YUV422 | [0x05] JPEG Compression with YUV 4:2:2 color space. This flag is used only if FILE_LEAD_MRC, or FILE_TIF_LEAD_MRC, is set in the nFormat parameter of either LSegment::MrcSaveBitmap, or LSegment::MrcSaveBitmapList.
 | MRC_PICTURE_COMPRESSION_JPEG_YUV411 | [0x06] JPEG Compression with YUV 4:1:1 color space. This flag is used only if FILE_LEAD_MRC, or FILE_TIF_LEAD_MRC, is set in the nFormat parameter of either LSegment::MrcSaveBitmap, or LSegment::MrcSaveBitmapList.
 | MRC_PICTURE_COMPRESSION_JPEG_PROGRESSIVE | [0x07] JPEG Progressive Compression. This flag is used only if FILE_LEAD_MRC, or FILE_TIF_LEAD_MRC, is set in the nFormat parameter of either LSegment::MrcSaveBitmap, or LSegment::MrcSaveBitmapList.
 | MRC_PICTURE_COMPRESSION_JPEG_PROGRESSIVE_YUV422 | [0x08] JPEG Progressive Compression. This flag is used only if FILE_LEAD_MRC, or FILE_TIF_LEAD_MRC, is set in the nFormat parameter of either LSegment::MrcSaveBitmap, or LSegment::MrcSaveBitmapList.
 | MRC_PICTURE_COMPRESSION_JPEG_PROGRESSIVE_YUV411 | [0x09] JPEG Progressive Compression. This flag is used only if FILE_LEAD_MRC, or FILE_TIF_LEAD_MRC, is set in the nFormat parameter of either LSegment::MrcSaveBitmap, or LSegment::MrcSaveBitmapList.
 | MRC_PDF_PICTURE_COMPRESSION_JPEG | [0x05] JPEG Compression. This flag is used only if FILE_PDF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.
 | MRC_PDF_PICTURE_COMPRESSION_YUV422 | [0x0B] JPEG Compression with YUV 4:2:2 color space. This flag is used only if FILE_PDF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.
 | MRC_PDF_PICTURE_COMPRESSION_YUV411 | [0x0C] JPEG Compression with YUV 4:1:1 color space. This flag is used only if FILE_PDF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.
 | MRC_PDF_PICTURE_COMPRESSION_PROGRESSIVE | [0x0D] JPEG Progressive Compression. This flag is used only if FILE_PDF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.
 | MRC_PDF_PICTURE_COMPRESSION_PROGRESSIVE_YUV422 | [0x0E] JPEG Progressive Compression with YUV 4:2:2 color space. This flag is used only if FILE_PDF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.
 | MRC_PDF_PICTURE_COMPRESSION_PROGRESSIVE_YUV411 | [0x0F] JPEG Compression with YUV 4:1:1 color space. This flag is used only if FILE_PDF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.
 | MRC_PDF_PICTURE_COMPRESSION_ZIP | [0x06] ZIP Compression. This flag is used only if FILE_PDF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.
 | MRC_PDF_PICTURE_COMPRESSION_LZW | [0x07] LZW Compression. This flag is used only if FILE_PDF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.

nPictureQFactor

Compression quality for JPEG, CMP and CMW compression for colored images. Possible values are between 2 and 255, where 2 is the highest quality and 255 is the most compression.

nGrayscale2BitCoder

Flag that indicates the background (grayscale 8 bit) compression type. This value is valid only when saving in LEAD Proprietary T44 format using the LSegment::MrcSaveBitmap function.

(when using the LSegment::MrcSaveBitmapT44 function, all 2-bit grayscale segments are treated as picture segments). This member is used only if FILE_LEAD_MRC or FILE_TIF_LEAD_MRC is set. in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapT44. Possible values are:

Value

Meaning

MRC_GRAYSCALE_COMPRESSION_JBIG_2BIT

[0x00] 2 bpp grayscale JBIG compression.

nGrayscale8BitCoder | Flag that indicates the background (grayscale 8 bit) compression type. This value is valid only when saving in LEAD Proprietary T44 format using the LSegment::MrcSaveBitmap function.(when using the LSegment::MrcSaveBitmapT44 function, all 8-bit grayscale segments are treated as picture segments). This member is used only if FILE_LEAD_MRC or FILE_TIF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList. Possible values are:
 | Value | Meaning
 | MRC_GRAYSCALE_COMPRESSION_LOSSLESS_CMW_8BIT | [0x00] 8 bpp Lossless grayscale LEAD CMW compression.
 | MRC_GRAYSCALE_COMPRESSION_GRAYSCALE_CMW_8BIT | [0x01] 8 bpp grayscale LEAD CMW compression.
 | MRC_GRAYSCALE_COMPRESSION_GRAYSCALE_CMP_8BIT | [0x02] 8 bpp grayscale LEAD CMP compression.
 | MRC_GRAYSCALE_COMPRESSION_LOSSLESS_JPEG_8BIT | [0x03] 8 bpp Lossless grayscale JPEG compression.
 | MRC_GRAYSCALE_COMPRESSION_GRAYSCALE_JPEG_8BIT | [0x04] 8 bpp grayscale JPEG compression.
 | MRC_GRAYSCALE_COMPRESSION_JPEG_PROGRESSIVE | [0x05] 8 bpp grayscale JPEG progressive compression.

nGrayscale8BitFactor | Compression quality for JPEG, CMP and CMW compression for 8-bit grayscale images. This value is valid only when saving in LEAD Proprietary T44 format using the LSegment::MrcSaveBitmap function (when using the LSegment::MrcSaveBitmapT44 function, all 8-bit grayscale segments are treated as picture segments). Possible values are between 2 and 255, where 2 are the highest quality and 255 is the most compression. If the nPictureCoder is CMW or JPEG lossless compression, the nGrayscaleFactor should be 0. This member is used only if FILE_LEAD_MRC or FILE_TIF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapT44.
nText2BitCoder | Flag that indicates the text 2-bit compression type. This value is valid only when saving in LEAD Proprietary T44 format using the LSegment::MrcSaveBitmap function. This member is used only if FILE_LEAD_MRC, FILE_TIF_LEAD_MRC, or FILE_PDF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList. Possible values are:
 | Value | Meaning
 | MRC_TEXT_COMPRESSION_JBIG_2BIT | [0x00] 2 bpp JBIG compression. This flag is used only if FILE_LEAD_MRC or FILE_TIF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.
 | MRC_TEXT_COMPRESSION_GIF_2BIT | [0x00] 2 bpp GIF compression. This flag is used only if FILE_LEAD_MRC or FILE_TIF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.
 | MRC_PDF_TEXT_COMPRESSION_ZIP | [0x02] ZIP compression. This flag is used only if FILE_PDF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.
 | MRC_PDF_TEXT_COMPRESSION_LZW | [0x03] LZW compression. This flag is used only if FILE_PDF_LEAD_MRC is set in the nFormat parameter of either LSegment::MrcSaveBitmap or LSegment::MrcSaveBitmapList.

Comments

pCOMPRESSIONOPTIONS is a pointer to a COMPRESSIONOPTIONS structure. Where the message parameter type is pCOMPRESSIONOPTIONS, you can declare a COMPRESSIONOPTIONS variable, update the structure's fields, and pass the variable's address in the parameter. Declaring a pCOMPRESSIONOPTIONS variable is necessary only if your program requires a pointer.

When saving in standard T44 format using the LSegment::MrcSaveBitmapT44 function, the only valid background compression is JPEG.

COMPRESSIONOPTIONS is used with the LSegment::MrcSaveBitmap and LSegment::MrcSaveBitmapT44 functions.


HSEGMENTATION (Document/Medical only)

LEADTOOLS has defined the following data types for referencing a list of bitmap segments:

Data Type | Definition and Usage
HSEGMENTATION | Defined as HANDLE; used as a handle to a list of bitmap segments.
pHSEGMENTATION | Defined as HSEGMENTATION L_FAR *; used as a pointer to an HSEGMENTATION variable.


MINSEGMENT (Document/Medical only)

typedef struct _MINSEG
{
L_UINT uStructSize;
L_INT nMinWidth;
L_INT nMinHeight;
} MINSEGMENT, L_FAR * pMINSEGMENT;

The MINSEGMENT structure contains the minimum segment width and height.

Member | Description
uStructSize | Size of this structure in bytes, for versioning. Use the sizeof() macro to calculate this value.
nMinWidth | Minimum segment width, in pixels. Minimum value is 10.
nMinHeight | Minimum segment height, in pixels. Minimum value is 10.

Comments

Please note that the LSegment::MrcSegmentBitmap function will be removed in Version 15. It is being replaced with the LSegment::MrcSegmentBitmapExt function.

pMINSEGMENT is a pointer to a MINSEGMENT structure. Where the message parameter type is pMINSEGMENT, you can declare a MINSEGMENT variable, update the structure's fields, and pass the variable's address in the parameter. Declaring a pMINSEGMENT variable is necessary only if your program requires a pointer.

MINSEGMENT is used with the LSegment::MrcSegmentBitmap function.


SEGMENTATIONOPTIONS (Document/Medical only)

typedef struct _tagSEGMENTATIONOPTIONS
{
L_UINT uStructSize;
L_UINT16 uSensitivity;
L_UINT16 uCombineFlags;
L_UINT16 uCombineFactor;
L_UINT16 uImageType;
} SEGMENTATIONOPTIONS, L_FAR * pSEGMENTATIONOPTIONS;

The SEGMENTATIONOPTIONS structure contains segmentation options to control the auto segmentation process using LSegment::MrcSegmentBitmap.

Member

Description

uStructSize

Size of this structure in bytes, for versioning. Use the sizeof() macro to calculate this value.

uSensitivity

Threshold value that determines the segment's type. Possible values are between 1 and 100. This is a control parameter used by the MRC engine to determine whether a certain segment should be considered as text, grayscale or an image. Higher values mean more segments are considered as text. Lower values mean more segments are considered as images.

uCombineFlags

Flag that indicates how segments will be combined. Possible values are:

Value

Meaning

COMBINE_FORCESIMILAR

[0x01] Always combine similar segments.

COMBINE_TRY

[0x02] Use the uCombineFactor value to determine similarity, and combine similar segments.

For the COMBINE_FORCESIMILAR value, the following types are considered similar and could therefore be combined:

SEGTYPE_ONECOLOR, SEGTYPE_BACKGROUND, SEGTYPE_TEXT_1BIT_BW, SEGTYPE_TEXT_2BITBW, SEGTYPE_TEXT_1BIT_COLOR, SEGTYPE_TEXT_2BIT_COLOR, or SEGTYPE_GRAYSCALE_2BIT

These types are considered similar and therefore could be combined:

SEGTYPE_GRAYSCALE_2BIT or SEGTYPE_GRAYSCALE_8BIT

These types are considered similar and therefore could be combined:

SEGTYPE_GRAYSCALE_8BIT or SEGTYPE_PICTURE

uCombineFactor | A percentage value that represents the acceptable difference between the two segments being combined. This is valid only when uCombineFlags is COMBINE_TRY. Possible values are between 0 and 100. A value of 0 indicates that only segments that are an exact match can be combined. A value of 100 indicates that any two segments of the same type can be combined. Large values cause very different segments to be joined, which causes considerable quality loss.
uImageType | Value that indicates the image type. Possible values are:
 | Value | Meaning
 | IMAGE_SCANNED | [0x00] The image is a scanned image. It will be cleaned before segmentation.
 | IMAGE_COMPUTERGENERATED | [0x01] The image is computer generated. It will not be cleaned before segmentation.

Comments

Please note that the LSegment::MrcSegmentBitmap function will be removed in Version 15. It is being replaced with the LSegment::MrcSegmentBitmapExt function.


SEGMENTDATA (Document/Medical only)

typedef struct _tagSEGMENTDATA
{
L_UINT uStructSize;
RECT rcBitmapSeg;
L_UINT uType;
} SEGMENTDATA, L_FAR * pSEGMENTDATA;

The SEGMENTDATA structure contains segment information.

Member | Description
uStructSize | Size of this structure in bytes, for versioning. Use the sizeof() macro to calculate this value.
rcBitmapSeg | Segment boundaries from the original bitmap.
uType | Flag that indicates the type of segment. Possible values are:
 | Value | Meaning
 | SEGTYPE_BACKGROUND | [0x01] Segment is a background (The most prevalent color in the document is considered to be the background color.).
 | SEGTYPE_ONECOLOR | [0x02] Segment is a one color.
 | SEGTYPE_TEXT_1BIT_BW | [0x03] Segment is 1-bit black and white text.
 | SEGTYPE_TEXT_1BIT_COLOR | [0x04] Segment is 1 bit colored text.
 | SEGTYPE_TEXT_2BITBW | [0x05] Segment is 2-bit black and white text.
 | SEGTYPE_TEXT_2BIT_COLOR | [0x06] Segment is 2 bit colored text.
 | SEGTYPE_GRAYSCALE_2BIT | [0x07] Segment is 2-bit grayscale.
 | SEGTYPE_GRAYSCALE_8BIT | [0x08] Segment is 8-bit grayscale.
 | SEGTYPE_PICTURE | [0x09] Segment is an image.

Comments

pSEGMENTDATA is a pointer to a SEGMENTDATA structure. Where the message parameter type is pSEGMENTDATA, you can declare a SEGMENTDATA variable, update the structure's fields, and pass the variable's address in the parameter. Declaring a pSEGMENTDATA variable is necessary only if your program requires a pointer.

This structure describes the data of a segment (image portion).

SEGMENTDATA is used with the following function:

LSegment::MrcEnumSegmentsCallBack

LSegment::MrcSetSegmentData

LSegment::MrcCreateNewSegment


SEGMENTEXTOPTIONS

typedef struct _tag SEGMENTEXTOPTIONS
{
L_UINT uStructSize;
L_UINT uCleanSize;
L_UINT uSegmentQuality;
L_UINT uColorThreshold;
L_UINT uBackGroundThreshold;
L_UINT uCombineThreshold;
L_UINT uFlags;
} SEGMENTEXTOPTIONS, L_FAR * pSEGMENTEXTOPTIONS;

The SEGMENTEXTOPTIONS structure contains segmentation options to control the auto segmentation process using LSegment::MrcSegmentBitmapExt.

Member | Description
uStructSize | Size of this structure in bytes, for versioning. Use the sizeof() macro to calculate this value.
uCleanSize | Value that indicates the cleaner size used to remove the noise inside the segmented image. Possible values range from 0 to 10, where 0 means to skip the cleaning stage.
uSegmentQuality | Threshold value used to determine whether the segment is a picture segment. Possible values range from 0 to 100. Use 0 to set all possible picture segments to 2-bit without loss of a lot of information. Use 100 to set all picture segments to 2 bit only if they are very close to 2-bit.
uColorThreshold | Threshold value used to combine colors. Colors that are closer together than this amount will be combined. The best value is 25. Values saturate at 443.
uBackGroundThreshold | Threshold value used to separate image objects from the background. Best values are from 5 to 35.
uCombineThreshold | Threshold value used to merge segments. Best values are from 75 to 125.
uFlags | Flags that indicate segmentation preference, whether to force segments to be 2-bit segments, and whether to search for background segments. You can use a bitwise OR (|) to specify one flag from each group:
 | The following are the flags that indicate the segmentation preference, and whether to force segments to be 2-bit segments:
 | Value | Meaning
 | SGM_FAVOR_ONEBIT | [0x0000] The preferred segment type is one bit.
 | SGM_FAVOR_TWOBIT | [0x0001] The preferred segment type is two bit.
 | SGM_FORCE_ONEBIT | [0x0002] Force all two bit segment types to be one bit segments.
 | SGM_FORCE_TWOBIT | [0x0003] Force all one bit segment types to be two bit segments.
 | The following are the flags that indicate whether to search for background segments:
 | Value | Meaning
 | SGM_WITHBKGRND | [0x0000] Search for background segments.
 | SGM_WITHOUTBKGRND | [0x0010] Do not search for background segments.


PDFCOMPRESSION

typedef struct tagPDFCOMPRESSION
{
L_UINT uStructSize;
L_UINT32 dwFlags;
PDFCOMP_1BITCOMPTYPE comp1Bit;
PDFCOMP_2BITCOMPTYPE comp2Bit;
PDFCOMP_PICTURECOMPTYPE compPicture;
L_INT nQFactor;
} PDFCOMPRESSION, *LPPDFCOMPRESSION;

The PDFCOMPRESSION structure provides information about PDF compression options.

Member | Description
uStructSize | Size of this structure in bytes, for versioning. Use the sizeof() macro to calculate this value.
dwFlags | Flag that indicates which members contain valid data. You can combine values when appropriate by using a bitwise OR ( | ). The following are valid values:
 | Value | Meaning
 | PDFCOMP_1BITCOMPTYPE_ENABLED | [0] The comp1Bit member indicates the compression type to use for 1-bit segments/images.
 | PDFCOMP_2BITCOMPTYPE_ENABLED | [2] The comp2Bit member indicates the compression type to use for 2-bit segments/images.
 | PDFCOMP_PICTURECOMPTYPE_ENABLED | [4] The compPicture member indicates the compression type to use for Picture Compression segments/images.
comp1Bit | Value that indicates the compression type to use for 1-bit segments/images. For possible values, refer to PDFCOMP_1BITCOMPTYPE.
comp2Bit | Value that indicates the compression type to use for 2-bit segments/images. For possible values, refer to PDFCOMP_2BITCOMPTYPE.
compPicture | Value that indicates the compression type to use for Picture segments. For possible values, refer to PDFCOMP_PICTURECOMPTYPE.
nQFactor | QFactor to used with JPEG Compressions types. For a list of possible values, refer to Compression Quality Factors.

Comments

LPPDFCOMPRESSION is a pointer to a PDFCOMPRESSION structure. Where a function parameter type is LPPDFCOMPRESSION, declare a PDFCOMPRESSION variable and pass the variable's address in the parameter. Declaring an LPPDFCOMPRESSION variable is necessary only if the program requires a pointer.

The comp1Bit, comp2Bit and compPicture members are valid only if the appropriate value is set in dwFlags. This lets you set the compression type for 1-bit segments, for example, without affecting the compression of 2-bit or picture segments.

This structure is used with the LPDFCompressor::SetCompression function.


PDFCOMPOPTIONS

typedef struct _PDFCOMPOPTIONS
{
L_UINT uStructSize;
L_UINT32 dwFlags;
PDFCOMP_IMAGEQUALITY imageQuality;
PDFCOMP_OUTPUTQUALITY outputQuality;
L_UINT uCleanSize;
L_UINT uBackGroundThreshold;
L_UINT uCombineThreshold;
L_UINT uSegmentQuality;
L_UINT uColorThreshold;

} PDFCOMPOPTIONS, L_FAR * LPPDFCOMPOPTIONS;

The PDFCOMPOPTIONS structure provides information about PDF Compressor options.

Member | Description
uStructSize | Size of this structure in bytes, for versioning. Use the sizeof() macro to calculate this value.
dwFlags | Flag that indicates the PDF Compressor options behavior. Possible values are:
 | Value | Meaning
 | PDFCOMP_FAVOR_ONEBIT | [0x00] Favor the detection of 1-bit segments.
 | PDFCOMP_FAVOR_TWOBIT | [0x01] Favor the detection of 2-bit segments.
 | PDFCOMP_FORCE_ONEBIT | [0x02] Force all 2-bit segments to be 1-bit.
 | PDFCOMP_FORCE_TWOBIT | [0x03] Force all 1-bit segments to be 2-bit.
 | PDFCOMP_WITH_BACKGROUND | [0x00] Detect background segments.
 | PDFCOMP_WITHOUT_BACKGROUND | [0x10] Don’t detect background segments.

imageQuality | Value that indicates the bitmap's quality before processing. Possible values are:
 | Value | Meaning
 | PDFCOMP_IMAGEQUALITY_UNKNOWN | [0] Unknown image quality. Use default handling.
 | PDFCOMP_IMAGEQUALITY_NOISY | [1] The source image is noisy.
 | PDFCOMP_IMAGEQUALITY_SCANNED | [2] The source image is a scanned image.
 | PDFCOMP_IMAGEQUALITY_PRINTED | [3] The source image is a printed document.
 | PDFCOMP_IMAGEQUALITY_COMPUTER_GENERATED | [4] The source image is a high quality computer-generated image.
 | PDFCOMP_IMAGEQUALITY_PHOTO | [5] The source image is a high quality photo image; for example, from a digital camera .
 | PDFCOMP_IMAGEQUALITY_USER | [6] The quality is set manually. This flag is for advanced users.

outputQuality | Value that indicates the image's output quality. Possible values are:
 | Value | Meaning
 | PDFCOMP_OUTPUTQUALITY_AUTO | [0] Choose the quality of the output automatically.
 | PDFCOMP_OUTPUTQUALITY_POOR | [1] Poor output quality with best compression.
 | PDFCOMP_OUTPUTQUALITY_AVERAGE | [2] Average output quality with average compression.
 | PDFCOMP_OUTPUTQUALITY_GOOD | [3] Good output quality with good compression.
 | PDFCOMP_OUTPUTQUALITY_EXCELLENT | [4] Excellent output quality with poor compression.
 | PDFCOMP_OUTPUTQUALITY_USER | [5] The user detects the output quality. This flag is for advanced users.
uCleanSize | Value that indicates the size of the area used to remove the noise inside the segmented image. Possible values range from 0 to 10, where 0 means skip the cleaning stage.
uBackGroundThreshold | Threshold value used to separate image objects from the background. Best values are from 5 to 35.
uCombineThreshold | Threshold value used to combine colors. Colors that are closer together than this amount will be combined. The best value is 25. Values saturate at 443.
uSegmentQuality | Threshold value used to determine whether the segment is a picture segment. Possible values range from 0 to 100. Use 0 to set all possible picture segments to 2-bit without losing a lot of information. Use 100 to set all picture segments to 2-bit only if they are very close to 2-bit.
uColorThreshold | Threshold value used to merge segments. Best values are from 75 to 125.

Comments

LPPDFCOMPOPTIONS is a pointer to a PDFCOMPOPTIONS structure. Where a function parameter type is LPPDFCOMPOPTIONS, declare a PDFCOMPOPTIONS variable and pass the variable's address in the parameter. Declaring an LPPDFCOMPOPTIONS variable is necessary only if the program requires a pointer.

The values of uCleanSize, uBackGroundThreshold and uCombineThreshold are valid only if the imageQuality is set to PDFCOMP_IMAGEQUALITY_USER flag.

The values of uSegmentQuality and uColorThreshold are valid only if the outputQuality is set to PDFCOMP_OUTPUTQUALITY_USER flag.

This structure is used with the LPDFCompressor::InsertMRC function.


PDFCOMP_1BITCOMPTYPE

typedef enum tagPDFCOMP_1BITCOMPTYPE
{
PDFCOMP_1BITCOMPTYPE_ZIP = 0,
PDFCOMP_1BITCOMPTYPE_LZW,
PDFCOMP_1BITCOMPTYPE_CCITT_G3_1D,
PDFCOMP_1BITCOMPTYPE_CCITT_G3_2D,
PDFCOMP_1BITCOMPTYPE_CCITT_G4,
PDFCOMP_1BITCOMPTYPE_JBIG2
} PDFCOMP_1BITCOMPTYPE, *LPPDFCOMP_1BITCOMPTYPE;

The PDFCOMP_1BITCOMPTYPE enumerated type represents the values used to determine the Compression type to be used with 1 bit images. This enumerated type is used by the comp1Bit member of the PDFCOMPRESSION structure.

Member | Description
PDFCOMP_1BITCOMPTYPE_ZIP | Use Zip Compression.
PDFCOMP_1BITCOMPTYPE_LZW | Use LZW Compression.
PDFCOMP_1BITCOMPTYPE_CCITT_G3_1D | Use FAX G3_2D Compression.
PDFCOMP_1BITCOMPTYPE_CCITT_G3_2D | Use FAX G3_2D Compression.
PDFCOMP_1BITCOMPTYPE_CCITT_G4 | Use FAX G4 Compression.
PDFCOMP_1BITCOMPTYPE_JBIG2 | Use JBIG2 Compression.


PDFCOMP_2BITCOMPTYPE

typedef enum tagPDFCOMP_2BITCOMPTYPE
{
PDFCOMP_2BITCOMPTYPE_ZIP = 0,
PDFCOMP_2BITCOMPTYPE_LZW,

} PDFCOMP_2BITCOMPTYPE, *LPPDFCOMP_2BITCOMPTYPE;

The PDFCOMP_2BITCOMPTYPE enumerated type represents the possible compression types used with 2 bit images. This enumerated type is used by the comp2Bit member of the PDFCOMPRESSION structure.

Member | Description
PDFCOMP_2BITCOMPTYPE_ZIP | Use Zip Compression.
PDFCOMP_2BITCOMPTYPE_LZW | Use LZW Compression.


PDFCOMP_IMAGEQUALITY

typedef enum tagPDFCOMP_IMAGEQUALITY
{
PDFCOMP_IMAGEQUALITY_UNKNOWN = 0, /* */
PDFCOMP_IMAGEQUALITY_NOISY, /* */
PDFCOMP_IMAGEQUALITY_SCANNED, /* */
PDFCOMP_IMAGEQUALITY_PRINTED, /* */
PDFCOMP_IMAGEQUALITY_COMPUTER_GENERATED, /* */
PDFCOMP_IMAGEQUALITY_PHOTO, /* */
PDFCOMP_IMAGEQUALITY_USER /* */
} PDFCOMP_IMAGEQUALITY, *LPPDFCOMP_IMAGEQUALITY;

The PDFCOMP_IMAGEQUALITY enumerated type represents the values used to determine the quality of the input image when working with the PDF Compressor. This enumerated type is used by the imageQuality member of the PDFCompOptions structure.

Member | Description
PDFCOMP_IMAGEQUALITY_UNKNOWN | Unknown image quality; use default handling.
PDFCOMP_IMAGEQUALITY_NOISY | The source image is noisy.
PDFCOMP_IMAGEQUALITY_SCANNED | The source image is a scanned image.
PDFCOMP_IMAGEQUALITY_PRINTED | The source image is a printed document.
PDFCOMP_IMAGEQUALITY_COMPUTER_GENERATED | The source image is a high quality computer generated image.
PDFCOMP_IMAGEQUALITY_PHOTO | The source image is a high quality photo image, for example, from a digital camera.
PDFCOMP_IMAGEQUALITY_USER | For advanced users, can be set manually


PDFCOMP_OUTPUTQUALITY

typedef enum tagPDFCOMP_OUTPUTQUALITY
{
PDFCOMP_OUTPUTQUALITY_AUTO = 0,
PDFCOMP_OUTPUTQUALITY_POOR,
PDFCOMP_OUTPUTQUALITY_AVERAGE,
PDFCOMP_OUTPUTQUALITY_GOOD,
PDFCOMP_OUTPUTQUALITY_EXCELLENT,
PDFCOMP_OUTPUTQUALITY_USER

} PDFCOMP_OUTPUTQUALITY, *LPPDFCOMP_OUTPUTQUALITY;

The PDFCOMP_OUTPUTQUALITY enumerated type represents the possible values used to determine the quality of the output image when working with the PDF Compressor. This enumerated type is used by the outputQuality member of the PDFCompOptions structure.

Member | Description
PDFCOMP_OUTPUTQUALITY_AUTO | Choose the quality of the output automatically.
PDFCOMP_OUTPUTQUALITY_POOR | Poor output quality, best compression.
PDFCOMP_OUTPUTQUALITY_AVERAGE | Average output quality, average compression.
PDFCOMP_OUTPUTQUALITY_GOOD | Good output quality, good compression.
PDFCOMP_OUTPUTQUALITY_EXCELLENT | Excellent output quality, poor compression.
PDFCOMP_OUTPUTQUALITY_USER | For advanced users only.


PDFCOMP_PICTURECOMPTYPE

typedef enum tagPDFCOMP_PICTURECOMPTYPE
{
PDFCOMP_PICTURECOMPTYPE_JPEG = 0,
PDFCOMP_PICTURECOMPTYPE_JPEG_YUV422,
PDFCOMP_PICTURECOMPTYPE_JPEG_YUV411,
PDFCOMP_PICTURECOMPTYPE_JPEG_PROGRESSIVE,
PDFCOMP_PICTURECOMPTYPE_JPEG_PROGRESSIVE_YUV422,
PDFCOMP_PICTURECOMPTYPE_JPEG_PROGRESSIVE_YUV411,
PDFCOMP_PICTURECOMPTYPE_ZIP ,
PDFCOMP_PICTURECOMPTYPE_LZW,

} PDFCOMP_PICTURECOMPTYPE, *LPPDFCOMP_PICTURECOMPTYPE;

The PDFCOMP_PICTURECOMPTYPE enumerated type represents the values used to determine the Compression type to be used with Picture images. This enumerated type is used by the compPicture member of the PDFCOMPRESSION structure.

Member | Description
PDFCOMP_PICTURECOMPTYPE_JPEG | [0] Uses JEG Compression
PDFCOMP_PICTURECOMPTYPE_JPEG_YUV422 | [1] Uses JPEG YUV 4:2:2 Compression.
PDFCOMP_PICTURECOMPTYPE_JPEG_YUV411 | [2] Uses JPEG YUV 4:1:1 Compression.
PDFCOMP_PICTURECOMPTYPE_JPEG_PROGRESSIVE | [3] Uses JPEG Progressive Compression.
PDFCOMP_PICTURECOMPTYPE_JPEG_PROGRESSIVE_YUV422 | [4] Uses JPEG Progressive YUV 4:2:2 Compression.
PDFCOMP_PICTURECOMPTYPE_JPEG_PROGRESSIVE_YUV411 | [5] Uses JPEG Progressive YUV 4:1:1 Compression.
PDFCOMP_PICTURECOMPTYPE_ZIP | [6] Uses Zip Compression.
PDFCOMP_PICTURECOMPTYPE_LZW | [7] Uses LZW Compression.


SEGMENTINFO

typedef struct _SEGMENTINFO
{
RECT rcSegmentRect;
L_UINT uSegmentType;
COLORREF rgbColors[4];
L_UINT uColorsCount;
} SEGMENTINFO, L_FAR *LPSEGMENTINFO;

The SEGMENTINFO structure provides information about a segment in PDF Compressor.

Member | Description
rcSegmentRect | RECT structure that contains the dimensions and position of the segment in an image.
uSegmentType | A value that specifies the segment type. Possible values are:
 | Value | Meaning
 | SEGMENT_BACKGROUND | Background segment.
 | SEGMENT_ONEBIT | 1-bit per pixel segment.
 | SEGMENT_ONEBITBW | 1-bit per pixel black and white segment.
 | SEGMENT_TWOBIT | 2-bits per pixel segment.
 | SEGMENT_TWOBITGRAY | 2-bits per pixel grayscale segment.
 | SEGMENT_GRAY | Grayscale segment.
 | SEGMENT_PICTURE | Picture segment
 | SEGMENT_TWOBITBW | 2-bits per pixel black and white segment
 | SEGMENT_ONECOLOR | The segment has one color.
rgbColors | Array which specifies the colors being used by this segment, which is available only for the following segment types: SEGMENT_BACKGROUND SEGMENT_ONEBIT SEGMENT_ONEBITBW SEGMENT_TWOBIT SEGMENT_TWOBITGRAY SEGMENT_TWOBITBW SEGMENT_ONECOLOR
uColorsCount | Number of valid colors in the array of colors specified by rgbColors.

Comments

LPSEGMENTINFO is a pointer to a SEGMENTINFO structure. Where the function parameter type is LPSEGMENTINFO, you can declare a SEGMENTINFO variable, update the structure's fields, and pass the variable's address in the parameter. Declaring a LPSEGMENTINFO variable is necessary only if your program requires a pointer.

This structure is used by the following functions:

LPDFCompressor::InsertSegments

LPDFCompressor::ImageCallBack


WINDOWS Structures

COLORREF

COLORREF is a Windows data type. For further information concerning COLORREF, please refer to the Microsoft SDK documentation.

HCURSOR

HCURSOR is a standard Windows data type. For further information concerning HCURSOR, please refer to the Microsoft SDK documentation or your compiler's documentation.

HICON

HICON is a standard Windows data type. For further information concerning HICON, please refer to the Microsoft SDK documentation or your compiler's documentation.

HWND

HWND is a standard Windows data type. For further information concerning HWND, please refer to the Microsoft SDK documentation or your compiler's documentation.

LPCSTR

LPCSTR is a standard Windows data type. For further information concerning LPCSTR, please refer to the Microsoft SDK documentation or your compiler's documentation.

LPRECT

LPRECT is a standard Windows data type. For further information concerning LPRECT, please refer to the Microsoft SDK documentation or your compiler's documentation.

OPENFILENAME

This is a Microsoft Windows structure as documented in the Microsoft SDK documentation. For complete documentation on this structure please refer to the Microsoft SDK documentation for OPENFILENAME.


LPDFCompressor::~LPDFCompressor

#include "ltwrappr.h"

#include "LTCPDFComp.h"

L_VOID LPDFCompressor::~LPDFCompressor(L_VOID)

Destroys the LPDFCompressor object and frees any resources associated with it.

Returns

None.

Comments

This is the destructor for the LPDFCompressor class.

Required DLLs and Libraries

LCMRC
LCPDF
LCENC
LCZIB
LTSGM

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: | LPDFCompressor::LPDFCompressor, Class Members
Topics: | Creating a Compressed PDF File
 | Class Library Function Groups

Example

For an example, refer to LPDFCompressor::LPDFCompressor.


LPDFCompressor::Free

#include "ltwrappr.h"

#include "LTCPDFComp.h"

L_VOID LPDFCompressor::Free();

Frees all associated memory allocated by LPDFCompressor::Init function.

Returns

None.

Comments

For each call to LPDFCompressor::Init there must be a call to LPDFCompressor::Free. This function should be the last function to be called when using the PDF compressor.

If this function is called before calling LPDFCompressor::Write, then the PDF document file in the memory will be destroyed and the user will lose the data in that document.

Required DLLs and Libraries

LCMRC
LCPDF
LCENC
LCZIB
LTSGM

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: | LPDFCompressor::Init
Topics: | Creating a Compressed PDF File
 | Class Library Function Groups

Example

For an example, refer to LPDFCompressor::InsertNormal.


LPDFCompressor::ImageCallBack

#include "ltwrappr.h"

#include "LTCPDFComp.h"

L_INT LPDFCompressor::ImageCallBack (nPage, pSegment)

L_INT nPage; | /* current page index */
pSEGMENTINFO pSegment; | /* pointer to the SEGMENTINFO structure */

This callback function is called every time a segment is added to the PDF document.

Parameter | Description
nPage | Index of the page on which the segment is being written. This is a zero-based index.
pSegment | Pointer to the SEGMENTINFO structure that contains the segment information.

Returns

SUCCESS | Add the current segment and continue.
FAILURE | Do not add this segment. Continue to the next segment.

Comments

This callback is called each time an MRC segment is added to the PDF file in memory, by calling LPDFCompressor::InsertMRC, if LBase::EnableCallBack was set to TRUE.

The user should return SUCCESS to add the current segment and continue with the process, or FAILURE, to not add this segment and proceed with the next one.

Required DLLs and Libraries

LCMRC
LCPDF
LCENC
LCZIB
LTSGM

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: | LPDFCompressor::Init, LPDFCompressor::InsertMRC, Class Members
Topics: | Creating a Compressed PDF File
 | Class Library Function Groups

Example

For an example, refer to LPDFCompressor::InsertMRC.


LPDFCompressor::Init

#include "ltwrappr.h"

#include "LTCPDFComp.h"

L_INT LPDFCompressor::Init()

Initializes the PDF compressor and creates an empty PDF document file in the memory.

Returns

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

Comments

LPDFCompressor::Init must be called before calling any other PDF compressor functions.

When the PDF Compressor and the PDF document are no longer needed, they should be freed by calling LPDFCompressor::Free. For every call to LPDFCompressor::Init there must be a call to LPDFCompressor::Free.

Required DLLs and Libraries

LCMRC
LCPDF
LCENC
LCZIB
LTSGM

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: | LPDFCompressor::Free
Topics: | Creating a Compressed PDF File
 | Class Library Function Groups

Example

For an example, refer to LPDFCompressor::InsertNormal.


LPDFCompressor::InsertMRC

#include "ltwrappr.h"

#include "LTCPDFComp.h"

L_INT LPDFCompressor::InsertMRC(pBitmap, pPDFOptions)

LBitmapBase * pBitmap; | /* pointer to an LBitmapBase object */
LPPDFCOMPOPTIONS pPDFOptions; | /* pointer to the PDFCOMPOPTIONS structure */

Segments the specified image using MRC segmentation, compresses it, and inserts the image in the PDF file in memory.

Parameter | Description
pBitmap | Pointer to the bitmap object that references the image to be inserted in the PDF file.
pPDFOptions | Pointer to the PDFCOMPOPTIONS structure that contains options used to write the image to the PDF file in memory.

Returns

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

Comments

To insert the bitmap without using MRC segmentation, use LPDFCompressor::InsertNormal.

This function calls the LPDFCompressor::ImageCallBack, if LBase::EnableCallBack was set to TRUE, to allow the user to accept or reject the addition of any segment to the PDF document.

Required DLLs and Libraries

LCMRC
LCPDF
LCENC
LCZIB
LTSGM

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: | LPDFCompressor::InsertNormal, LPDFCompressor::ImageCallBack, Class Members
Topics: | Creating a Compressed PDF File
 | Class Library Function Groups

Example

/* This example inserts an image in a pdf document and uses MRC segmentation to segment this image. In this sample we don't need to add a background segment. */
class LPDFCompressorKid : public LPDFCompressor
{
protected:
L_INT ImageCallBack(L_INT nPage, LPSEGMENTINFO pSegment)
{
if(pSegment->uSegmentType == SEGMENT_BACKGROUND)
return FAILURE;
else
return SUCCESS;
}
};

void PdfcompressorinsertmrcExample(HWND hwnd)
{
LPDFCompressorKid pdf ;
L_INT nRet;
LBitmap LEADBitmap;
PDFCOMPOPTIONS PDFOptions;
PDFCOMPRESSION pdfComp;

memset(&PDFOptions,0,sizeof(&PDFOptions));

pdf.EnableCallBack
  (TRUE);

nRet = pdf.Init ();
if (nRet != SUCCESS)
{
MessageBox(hwnd, "Couldn't initialize pdf compressor","Error", MB_OK) ;
return ;
}

pdfComp.uStructSize = sizeof( pdfComp );
pdfComp.dwFlags = PDFCOMP_1BITCOMPTYPE_ENABLED | PDFCOMP_2BITCOMPTYPE_ENABLED | PDFCOMP_PICTURECOMPTYPE_ENABLED;
pdfComp.comp1Bit = PDFCOMP_1BITCOMPTYPE_JBIG2;
pdfComp.comp2Bit = PDFCOMP_2BITCOMPTYPE_ZIP;
pdfComp.compPicture = PDFCOMP_PICTURECOMPTYPE_JPEG;
pdfComp.nQFactor =50;

nRet = pdf.SetCompression ( &pdfComp );
if(nRet != SUCCESS)
{
pdf.Free ();
return ;
}

PDFOptions.uStructSize = sizeof(PDFCOMPOPTIONS);
PDFOptions. dwFlags = PDFCOMP_FAVOR_ONEBIT | PDFCOMP_WITH_BACKGROUND;

PDFOptions.imageQuality = PDFCOMP_IMAGEQUALITY_USER;
PDFOptions.outputQuality = PDFCOMP_OUTPUTQUALITY_USER;

PDFOptions.uCleanSize = 7;
PDFOptions.uBackGroundThreshold = 15;
PDFOptions.uCombineThreshold = 100;
PDFOptions.uSegmentQuality = 50;
PDFOptions.uColorThreshold = 25;

if (LEADBitmap.Load(TEXT("C:\\IMAGE4.CMP")) != SUCCESS)
{
MessageBox(hwnd, TEXT("Failed to load source image \"C:\\IMAGE4.CMP\""),"Error", MB_OK);
pdf.Free();
return ;
}
nRet = pdf.InsertMRC(&LEADBitmap, &PDFOptions);

nRet = pdf.Write (TEXT("C:\\Output(InsertMRC).pdf"));
if (nRet ==SUCCESS)
MessageBox( hwnd, TEXT("Result saved to C:\\Output(InsertMRC).pdf"),"Error", MB_OK);
else
MessageBox( hwnd, TEXT("Failed to save result"),"Error", MB_OK);

pdf.Free ();
}


LPDFCompressor::InsertNormal

#include "ltwrappr.h"

#include "LTCPDFComp.h"

L_INT LPDFCompressor::InsertNormal(pBitmap)

LBitmapBase * pBitmap;

/* pointer to an LBitmapBase object*/

Compresses the specified image, without segmenting it, and inserts the image in the PDF file in memory.

Parameter | Description
pBitmap | Pointer to the bitmap handle that references the image to be inserted in the PDF document.

Returns

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

Comments

To segment an image using MRC segmentation, compress it, and insert the bitmap to the PDF file in memory, call LPDFCompressor::InsertMRC.

Required DLLs and Libraries

LCMRC
LCPDF
LCENC
LCZIB
LTSGM

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: | LPDFCompressor::InsertMRC, Class Members
Topics: | Creating a Compressed PDF File
 | Class Library Function Groups

Example

/* This example inserts an image in a pdf document without using MRC segmentation */
class LPDFCompressorKid : public LPDFCompressor
{
protected:
L_INT ImageCallBack(L_INT nPage, LPSEGMENTINFO pSegment)
{
if(pSegment->uSegmentType == SEGMENT_BACKGROUND)
return FAILURE;
else
return SUCCESS;
}
};
void PdfcompressorinsertnormalExample()
{
LPDFCompressorKid pdf ;
L_INT nRet;
LBitmap LEADBitmap ;
PDFCOMPOPTIONS PDFOptions;
memset(&PDFOptions,0,sizeof(&PDFOptions));

nRet = pdf.Init ();
if (nRet != SUCCESS)
{
MessageBox("Couldn't initialize pdf compressor") ;
return ;
}

PDFOptions.imageQuality = PDFCOMP_IMAGEQUALITY_USER;
PDFOptions.outputQuality = PDFCOMP_OUTPUTQUALITY_USER;

PDFOptions.uCleanSize = 7;
PDFOptions.uBackGroundThreshold = 15;
PDFOptions.uCombineThreshold = 100;
PDFOptions.uSegmentQuality = 50;
PDFOptions.uColorThreshold = 25;

if (LEADBitmap.Load(TEXT("C:\\IMAGE4.CMP")) != SUCCESS)
{
MessageBox(TEXT("Failed to load source image \"C:\\IMAGE4.CMP\""));
pdf.Free ();
return ;
}
nRet = pdf.InsertNormal(&LEADBitmap);

nRet = pdf.Write (TEXT("C:\\Output(InsertNormal).pdf"));
if (nRet ==SUCCESS)
MessageBox(TEXT("result saved to C:\\Output(InsertNormal).pdf"));
else
MessageBox(TEXT("failed to save result"));

pdf.Free ();
}


LPDFCompressor::InsertSegments

#include "ltwrappr.h"

L_INT LPDFCompressor::InsertSegments( pBitmap, uSegmentCnt, pSegmentInfo, bIsThereBackGround, rgbBackGroundColor)

LBitmapBase * pBitmap; | /* pointer to bitmap */
L_UINT uSegmentCnt; | /* number of elements in segment array */
LPSEGMENTINFO pSegmentInfo; | /* pointer to the SEGMENTINFO structure */
L_BOOL bIsThereBackGround; | /* flag */
COLORREF rgbBackGroundColor; | /* background color */

Applies the segments specified in pSegmentInfo to the specified bitmap, then compresses and inserts the resulting image into the PDF file in memory.

Parameter | Description
pBitmap | Pointer to the LBitmapBase class that references the image to be inserted in the PDF file.
uSegmentCnt | Number of elements in the pSegmentInfo parameter. It represents the number of segments that will be applied to pBitmap.
pSegmentInfo | Pointer to the SEGMENTINFO structure that contains an array that has the information for each segment.
bIsThereBackGround | Flag that indicates whether to use the average background color to represent the background of the page in the PDF file. Possible values are:
 | Value | Meaning
 | TRUE | Use the average color to draw a background color in the generated PDF page before drawing the segments.
 | FALSE | Leave the background of the PDF page untouched.
rgbBackGroundColor | Average background color. This parameter is ignored if bIsThereBackGround is FALSE.

Returns

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

Comments

To insert the bitmap using MRC segmentation, use LPDFCompressor::InsertMRC.

Required DLLs and Libraries

LCMRC
LCPDF
LCENC
LCZIB

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: | LPDFCompressor::InsertMRC, LPDFCompressor::InsertNormal, LPDFCompressor::SetCompression
Topics: | Creating a Compressed PDF File
 | Class Library Function Groups

Example

// This example inserts an image to pdf document with using user Segments
L_INT InsertSegmentExample(LBitmapBase* pBitmap, L_UINT uSegmentCnt, LPSEGMENTINFO pSegmentInfo , COLORREF rgbBackGroundColor, L_BOOL bIsThereBackGround)
{
L_INT nRet;
LPDFCompressor Pdf;

nRet = Pdf.Init ();
if(nRet != SUCCESS)
return nRet;

nRet = Pdf.InsertSegments( pBitmap, uSegmentCnt, pSegmentInfo, bIsThereBackGround, rgbBackGroundColor);
if(nRet != SUCCESS)
{
Pdf.Free ();
return nRet;
}

nRet = pdf.Write (TEXT("C:\\Output.pdf"));

Pdf.Free();
return nRet;
}


LPDFCompressor::LPDFCompressor

#include "ltwrappr.h"

#include "LTCPDFComp.h"

L_VOID LPDFCompressor::LPDFCompressor(L_VOID)

Constructs and initializes the member variables of the LPDFCompressor object.

Returns

None.

Comments

This is the constructor for the LPDFCompressor class.

Required DLLs and Libraries

LCMRC
LCPDF
LCENC
LCZIB
LTSGM

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: | LPDFCompressor::~LPDFCompressor, Class Members
Topics: | Creating a Compressed PDF File
 | Class Library Function Groups

Example

L_VOID TestConstructor()
{
// this will call the default constructor and destructor when it is out of scope
LPDFCompressor MyCompressor;

//...
}


LPDFCompressor::SetCompression

#include "ltwrappr.h"

L_INT LPDFCompressor::SetCompression(pCompression)

LPPDFCOMPRESSION pCompression;

/* pointer to the PDFCOMPRESSION structure */

Sets the compression type to be used with each image segment inserted in the PDF file.

Parameter | Description
pCompression | Pointer to the PDFCOMPRESSION structure that contains the compression options to set.

Returns

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

Comments

This function must be called before inserting a compressed image into the PDF file by calling the following functions:

LPDFCompressor::InsertMRC

LPDFCompressor::InsertNormal

LPDFCompressor::InsertSegments

If the user does not call this function before using these methods, then the insertion process will use the default compression types.

Required DLLs and Libraries

LCMRC
LCPDF
LCENC
LCZIB

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: | LPDFCompressor::InsertMRC, LPDFCompressor::InsertNormal, LPDFCompressor::InsertSegments
Topics: | Creating a Compressed PDF File
 | Class Library Function Groups

Example

For an example, refer to LPDFCompressor::InsertMRC


LPDFCompressor::Write

#include "ltwrappr.h"

#include "LTCPDFComp.h"

L_INT LPDFCompressor::Write(pwszOutFile)

L_TCHAR * pwszOutFile;

/* path of the file to save */

Writes the file in memory to a file on disk, using the path provided.

Parameter | Description
pwszOutFile | Character string that contains the name, including the path, of the document file to save.

Returns

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

Comments

This function saves a compressed PDF document file to disk. The pwszOutFile parameter indicates where the PDF document file should be created.

The PDF Compressor normally creates the compressed PDF document file in memory. It can add as many pages as required to the file. Once the PDF file in memory is complete, call this function to write the file to disk, before calling LPDFCompressor::Free.

Required DLLs and Libraries

LCMRC
LCPDF
LCENC
LCZIB
LTSGM

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: | LPDFCompressor::Init, LPDFCompressor::Free, LPDFCompressor::InsertMRC, LPDFCompressor::InsertNormal
Topics: | Creating a Compressed PDF File
 | Class Library Function Groups

Example

For an example, refer to LPDFCompressor::InsertNormal.


LSegment::LSegment

#include "ltwrappr.h"

L_VOID LSegment::LSegment(L_VOID)

Constructs and initializes the LSegment object. This function is available in the ( Document/Medical ) toolkits.

Returns

None.

Comments

This is the constructor of the LSegment class.

Required DLLs and Libraries

LTSGM

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:

LSegment::~LSegment, Class Members

Example

The following example creates an instance of the LSegment class.

L_VOID SomeFunction()
{
/* The following will cause the constructor to be called */
/* The destructor is called when the object is freed or goes out of
scope */
LSegment Segment;

//…
//…
}


LSegment::~LSegment

#include "ltwrappr.h"

virtual L_VOID LSegment::~LSegment(L_VOID)

Destroys the object and frees any resources associated with it. This function is available in the ( Document/Medical ) toolkits.

Returns

None.

Comments

This is the destructor of the LSegment class.

Required DLLs and Libraries

LTSGM

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:

LSegment::LSegment, Class Members

Example

For an example, refer to LSegment::LSegment.


LSegment::MrcCombineSegments

#include "ltsgm.h"

L_INT EXT_FUNCTION LSegment::MrcCombineSegments(nSegId1, nSegId2, uCombineFlags, uCombineFactor)

L_INT nSegId1; | /* first segment identifier */
L_INT nSegId2; | /* second segment identifier */
L_UINT16 uCombineFlags; | /* combining flag */
L_UINT16 uCombineFactor; | /* combining quality factor */

Combines two segments. This function is available in the ( Document/Medical ) toolkits.

Parameter

Description

nSegId1

ID of the first segment to be combined.

nSegId2

ID of the second segment to be combined.

uCombineFlags

Flag that indicates how segments will be combined. Possible values are:

Value

Meaning

COMBINE_FORCE

[0x00] Always combine segments of any type.

COMBINE_FORCESIMILAR

[0x01] Always combine similar segments.

COMBINE_TRY

[0x02] Use the uCombineFactor value to determine similarity, and combine similar segments.

For the COMBINE_FORCESIMILAR value, the following types are considered similar and could therefore be combined:

SEGTYPE_ONECOLOR, SEGTYPE_BACKGROUND, SEGTYPE_TEXT_1BIT_BW, SEGTYPE_TEXT_2BITBW, SEGTYPE_TEXT_1BIT_COLOR, SEGTYPE_TEXT_2BIT_COLOR, or SEGTYPE_GRAYSCALE_2BIT

These types are considered similar and therefore could be combined:

SEGTYPE_GRAYSCALE_2BIT or SEGTYPE_GRAYSCALE_8BIT

These types are considered similar and therefore could be combined:

SEGTYPE_GRAYSCALE_8BIT or SEGTYPE_PICTURE

uCombineFactor

A percentage value that represents the acceptable difference between the two segments being combined. This is valid only when uCombineFlags is COMBINE_TRY. Possible values are between 0 and 100. A value of 0 indicates that only segments that are an exact match can be combined. A value of 100 indicates that any two segments of the same type can be combined. Large values cause very different segments to be joined, which causes considerable quality loss.

Returns

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

Comments

This function is used to combine two specific segments from the segmentation handle. The two segments must be in the same row or column to be combined.

This function can be used when performing automatic or manual segmentation.

Call the LSegment::MrcStartBitmapSegmentation function before using any of the segmentation functions. When the LSegment class object is no longer needed, free it by calling the LSegment::MrcStopBitmapSegmentation function.

Required DLLs and Libraries

LTSGM

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: | LSegment::MrcCreateNewSegment, LSegment::MrcDeleteSegment, LSegment::MrcSegmentBitmapExt, Class Members
Topics: | General Segmentation
 | Manual Segmentation

Example

L_INT CombineSegments(LSegment Segment,
L_INT nSegId1, L_INT nSegId2)
{
return Segment.MrcCombineSegments(nSegId1, nSegId2,
COMBINE_FORCE, 20);
}


LSegment::MrcCopySegmentationHandle

#include "ltsgm.h"

L_INT EXT_FUNCTION LSegment::MrcCopySegmentationHandle(phSegmentDst, hSegmentSrc)

pHSEGMENTATION phSegmentDst; | /* pointer to the destination segmentation handle */
HSEGMENTATION hSegmentSrc; | /* structure containing the source segmentation handle */

Copies one segmentation handle to another. This function is available in the ( Document/Medical ) toolkits.

Parameter | Description
phSegmentDst | Pointer to the segmentation handle referencing the destination handle.
hSegmentSrc | HSEGMENTATION structure that contains the source segmentation handle to copy.

Returns

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

Comments

This function copies the segmentation handle and the segmentation data. Call the LSegment::MrcStopBitmapSegmentation function to free the new segmentation handle.

Call the LSegment::MrcStartBitmapSegmentation function before using any of the segmentation functions. When the class object of the segmentation is no longer needed, it should be freed by calling the LSegment::MrcStopBitmapSegmentation function.

Required DLLs and Libraries

LTSGM

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: | LSegment::MrcSegmentBitmap, LSegment::MrcCreateNewSegment, LSegment::MrcStartBitmapSegmentation, LSegment::MrcStopBitmapSegmentation, LSegment::MrcSetSegmentData, LSegment::MrcEnumSegments, LSegment::MrcCombineSegments, LSegment::MrcSaveSegmentation, LSegment::MrcSegmentBitmapExt, Class Members
Topics: | General Segmentation
 | Manual Segmentation

Example

L_INT CopySegmentation(LSegment& SegDst, LSegment& SegSrc)
{
return SegDst.MrcCopySegmentationHandle(SegSrc);
}


LSegment::MrcCreateNewSegment

#include "ltwrappr.h"

L_INT LSegment::MrcCreateNewSegment(pBitmap, pSegment)

LBitmapBase * pBitmap; | /* pointer to an LBitmapBase object */
pSEGMENTDATA pSegment; | /* segment information */

Manually adds a new segment to a specific stripe and sets the segment information. This function is available in the ( Document/Medical ) toolkits.

Parameter | Description
pBitmap | Pointer to an LBitmapBase object that references the bitmap in which the segment will be created.
pSegment | Pointer to the SEGMENTDATA structure that contains the segment information.

Returns

>= 0 | Index of the newly added segment.
< 1 | An error occurred. Refer to Return Codes .

Comments

Use this function to manually add a new segment using the coordinates and type specified in pSegment.

Call the LSegment::MrcStartBitmapSegmentation function before using any of the segmentation functions. When the LSegment class object is no longer needed, free it by calling the LSegment::MrcStopBitmapSegmentation function.

Required DLLs and Libraries

LTSGM

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: | LSegment::MrcStartBitmapSegmentation, LSegment::MrcStopBitmapSegmentation, LSegment::MrcEnumSegments, LSegment::MrcSaveSegmentation, LSegment::MrcLoadSegmentation, LSegment:: MrcCopySegmentationHandle, LSegment::MrcSegmentBitmapExt, LSegment::MrcSetSegmentData, LSegment::MrcDeleteSegment, Class Members
Topics: | General Segmentation
 | Manual Segmentation

Example

The following example illustrates the use of LSegment::MrcCreateNewSegment in performing manual segmentation.

L_VOID ManuallySegmentBitmap(LBitmapBase & Bitmap)
{
LSegment Segment;
SEGMENTDATA SegData;
L_INT nRet;

// Initialize the segmentation process
nRet = Segment.MrcStartBitmapSegmentation(&Bitmap,
RGB(255, 255, 255),
RGB(0, 0, 0));

SegData.uStructSize = sizeof(SEGMENTDATA);
SegData.rcBitmapSeg.left = 20;
SegData.rcBitmapSeg.top = 20;
SegData.rcBitmapSeg.right = 60;
SegData.rcBitmapSeg.bottom = 60;
SegData.uType = SEGTYPE_PICTURE;

// Add a segment to the stripe just set
nRet = Segment.MrcCreateNewSegment(&Bitmap, &SegData);

// Clean up
Segment.MrcStopBitmapSegmentation();
}


LSegment::MrcDeleteSegment

#include "ltwrappr.h"

L_INT LSegment::MrcDeleteSegment(nSegId)

L_INT nSegId;

/* segment identifier */

Deletes a segment. This function is available in the ( Document/Medical ) toolkits.

Parameter | Description
nSegId | Segment’s ID to delete.

Returns

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

Comments

Use this function to delete a specific segment from the segmentation handle. This function is valid with both the automatic and the manual segmentation processes.

Call the LSegment::MrcStartBitmapSegmentation function before using any of the segmentation functions. When the class object of the segmentation is no longer needed, it should be freed by calling the LSegment::MrcStopBitmapSegmentation function.

Required DLLs and Libraries

LTSGM

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: | LSegment::MrcStartBitmapSegmentation, LSegment::MrcStopBitmapSegmentation, LSegment::MrcSegmentBitmap, LSegment::MrcCreateNewSegment, LSegment::MrcEnumSegments, LSegment::MrcSetSegmentData, Class Members
Topics: | General Segmentation
 | Auto-Segmentation
 | Manual Segmentation

Example

For an example, refer to LSegment::MrcSetSegmentData.


LSegment::MrcEnumSegments

#include "ltwrappr.h"

L_INT LSegment::MrcEnumSegments(dwFlags)

L_UINT32 dwFlags;

/* reserved flags */

Enumerates the segments. This function is available in the ( Document/Medical ) toolkits.

Parameter | Description
dwFlags | Reserved for future use. Pass 0.

Returns

>= 1 | The number of segments enumerated.
< 1 | An error occurred. Refer to Return Codes .

Comments

This function calls the LSegment::MrcEnumSegmentsCallBack function for each segment found in the auto segmentation process. To get information about each segment, derive a new class from LSegment and override the LSegment::MrcEnumSegmentsCallBack function. This is explained in the description of the callback function itself.

This function can be used to enumerate segments. These segments can be generated manually or automatically.

If there is no callback function implemented OR the callback function succeeded, then the number of enumerated segments will be returned by this function.

Call the LSegment::MrcStartBitmapSegmentation function before using any of the segmentation functions. When the LSegment class object is no longer needed, free it by calling the LSegment::MrcStopBitmapSegmentation function.

Required DLLs and Libraries

LTSGM

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

Function: | LSegment::MrcCreateNewSegment, LSegment::MrcStartBitmapSegmentation, LSegment::MrcStopBitmapSegmentation, LSegment::MrcSegmentBitmap, LSegment::MrcEnumSegmentsCallBack, LSegment::MrcSetSegmentData, LSegment::MrcDeleteSegment, LSegment::MrcCombineSegments, LSegment::MrcSaveSegmentation, LSegment::MrcLoadSegmentation, LSegment::MrcCopySegmentationHandle, LSegment::MrcSegmentBitmapExt, Class Members
Topics: | General Segmentation
 | Auto-Segmentation
 | Manual Segmentation

Example

For an example, refer to LSegment::MrcEnumSegmentsCallBack.


LSegment::MrcEnumSegmentsCallBack

#include "ltwrappr.h"

virtual L_INT LSegment::MrcEnumSegmentsCallBack(pSegment, nSegId)

const pSEGMENTDATA pSegment; | /* pointer to a structure */
L_INT nSegId; | /* segment identifier */

Handles each enumerated segment that LSegment::MrcEnumSegments has enumerated. This function is available in the ( Document/Medical ) toolkits.

Parameter | Description
pSegment | Pointer to a SEGMENTDATA structure that contains segment data for the segment being enumerated.
nSegId | ID of the segment being enumerated.

Returns

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

Comments

This callback function is called for each segment enumerated by the LSegment::MrcEnumSegments function. The callback receives segment data and segment ID.

If you need to investigate the segments, create a new class derived from LSegment and override LSegment::MrcEnumSegmentsCallBack adding the desired processing to the overriding version. (Create your object from the new class.)

This function can be used when performing automatic or manual segmentation.

Call the LSegment::MrcStartBitmapSegmentation function before using any of the segmentation functions. When the LSegment class object is no longer needed, free it by calling the LSegment::MrcStopBitmapSegmentation function.

Required DLLs and Libraries

LTSGM

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: | LSegment::MrcStartBitmapSegmentation, LSegment::MrcStopBitmapSegmentation, LSegment::MrcEnumSegments, LSegment::MrcSetSegmentData, LSegment::MrcDeleteSegment, Class Members
Topics: | General Segmentation
 | Auto-Segmentation
 | Manual Segmentation

Example

For an example, refer to LSegment::MrcSegmentBitmap .


LSegment::MrcGetHandle

#include "ltsgm.h"

pHSEGMENTATION EXT_FUNCTION LSegment::MrcGetHandle()

Gets the segmentation handle. This function is available in the ( Document/Medical ) toolkits.

Returns

This function returns the segmentation handle for this object.

Required DLLs and Libraries

LTSGM

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: | LSegment::MrcSegmentBitmap ,LSegment::MrcCreateNewSegment, Class Members
Topics: | General Segmentation
 | Manual Segmentation

Example

pHSEGMENTATION GetSegmentationHandle(LSegment& Segment)
{
return Segment.MrcGetHandle();
}


LSegment::MrcGetPagesCount

#include "ltwrappr.h"

L_INT LSegment::MrcGetPagesCount(pszFileName)

L_TCHAR * pszFileName;

/* MRC image file name */

Gets the number of pages in an MRC image file. This function is available in the ( Document/Medical ) toolkits.

Parameter | Description
pszFileName | Character string that contains the name of the MRC image file.

Returns

The number of pages in the given MRC image file.

Required DLLs and Libraries

LTSGM

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: | LSegment::MrcSaveBitmap, LSegment::MrcSaveBitmapT44, LSegment::MrcLoadBitmap, Class Members
Topics: | Loading Capabilities

Example

L_INT GetTotalPages(L_TCHAR * szFileName)
{
LSegment Segment;
return Segment.MrcGetPagesCount(szFileName);
}


LSegment::MrcLoadBitmap

#include "ltwrappr.h"

L_INT LSegment::MrcLoadBitmap(pszFileName, pBitmap, uStructSize, nPageNo)

L_TCHAR * pszFileName; | /* name of the file to load */
LBitmapBase * pBitmap; | /* pointer to an LBitmapBase object */
L_UINT uStructSize; | /* size in bytes, of the structure pointed to by pBitmap */
L_INT nPageNo; | /* page number */

Loads an MRC image file into a bitmap. The file can be in any supported image file format. This function is available in the ( Document/Medical ) toolkits.

Parameter | Description
pszFileName | Character string containing the name of the file to load.
pBitmap | Pointer to the target LBitmapBase object that references the target bitmap.
uStructSize | Size in bytes, of the structure pointed to by pBitmap, for versioning. Use sizeof(BITMAPHANDLE).
nPageNo | The page number of a multi-page file, which can contain more than one image. When loading a file, this is the exact page number. For more information on multi-page files refer to Multipage File Formats .

Returns

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

Comments

This function loads the MRC image files that were saved using either LEAD Proprietary T44 Format or Standard T44 Format.

Required DLLs and Libraries

LTSGM

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: | LSegment::MrcSaveBitmap, LSegment::MrcSaveBitmapT44, LSegment::MrcGetPagesCount, Class Members
Topics: | General Segmentation
 | Loading Capabilities

Example

The following is a simple example that uses LSegment::MrcLoadBitmap to load an MRC image.

L_VOID LoadMrcBitmap(LBitmapBase & Bitmap, L_TCHAR * pszFileName)
{
LSegment Segment;

// Load the image
Segment.MrcLoadBitmap(pszFileName, &Bitmap, sizeof(BITMAPHANDLE), 1);
}


LSegment::MrcLoadSegmentation

#include "ltwrappr.h"

L_INT EXT_FUNCTION LSegment::MrcLoadSegmentation(phSegment, pBitmap, pszFileNamer)

LBitmapBase * pBitmap; | /* pointer to an LBitmapBase object */
L_TCHAR L_FAR * pszFileName; | /* output file name */

Loads segments from a file. This function is available in the ( Document/Medical ) toolkits.

Parameter

Description

pBitmap

Pointer to the target LBitmapBase object that references the target bitmap.

pszFileName

Character string that contains the output file name.

Returns

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

Comments

This function loads the segments from a file to the segmentation handle.

Call LSegment::MrcEnumSegments to enumerate the segments.

Required DLLs and Libraries

LTSGM

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: | LSegment::MrcSaveSegmentation, Class Members
Topics: | General Segmentation
 | Manual Segmentation

Example

L_INT ImportSegments(LSegment Segment, L_TCHAR L_FAR* pszFileName, LBitmapBase &Bitmap)
{
return Segment.MrcLoadSegmentation(&Bitmap, pszFileName);
}


LSegment::MrcSaveBitmap

#include "ltwrappr.h"

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

LBitmapBase * pBitmap; | /* pointer to an LBitmapBase object */
pCOMPRESSIONOPTIONS pCmpOption; | /* pointer to the compression options structure */
L_TCHAR * pszFileName; | /* output file name */
L_INT nFormat | /* output file format */
pSAVEFILEOPTION pSaveOptions | /* pointer to optional extended save options */

Saves an MRC image contained in a bitmap to a file using the LEAD Proprietary T44 format. This function is available in the ( Document/Medical ) toolkits.

Parameter | Description
pBitmap | Pointer to an LBitmapBase object that references the bitmap to be saved.
pCmpOption | Pointer to the COMPRESSIONOPTIONS structure that contains the compression information to use when saving the file.
pszFileName | Character string that contains the output file name.
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.
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

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:

Take advantage of the greater number of different segment types available when using the proprietary format.

Create smaller files than would be possible by saving them to the Standard T44 format.

Create higher quality files than would be possible by saving them to the Standard T44 format.

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::MrcSegmentBitmapExt 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 hasn’t been segmented, then the function will automatically segment the bitmap by calling LSegment::MrcSegmentBitmapExt and then save the image file. The LSegment::MrcSegmentBitmapExt 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

LTSGM

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: | LSegment::MrcSaveBitmapT44, LSegment::MrcLoadBitmap, LSegment::MrcGetPagesCount, LSegment::MrcSegmentBitmapExt, Class Members
Topics: | General Segmentation
 | Saving Capabilities

Example

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

L_INT SaveBitmap(LSegment Segment, LBitmapBase & Bitmap, L_CHAR * 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;
}


LSegment::MrcSaveBitmapT44

#include "ltwrappr.h"

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

LBitmapBase * pBitmap; | /* pointer to an LBitmapBase object */
pCOMPRESSIONOPTIONS pCmpOption; | /* pointer to the compression options structure */
L_TCHAR * pszFileName; | /* output file name */
L_INT nFormat | /* output file format */
pSAVEFILEOPTION pSaveOptions | /* pointer to optional extended save options */

Saves an MRC image contained in a bitmap to a file using the Standard T44 format. This function is available in the ( Document/Medical ) toolkits.

Parameter | Description
pBitmap | Pointer to an LBitmapBase object that references the bitmap to be saved.
pCmpOption | Pointer to the COMPRESSIONOPTIONS structure that contains the compression information to use when saving the file.
pszFileName | Character string that contains the output file name.
nFormat | Output file format. Possible values are:
 | Value | Meaning
 | FILE_MRC | [168] Standard MRC Compression. The default file extension is *.MRC.
 | FILE_TIF_MRC | [177] Tagged Image File with standard MRC Compression. (Supports multi-page). The default file extension is *.TIF.
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

Use this function to save the given LEADImage bitmap in one of the standard T44 Formats: either as a Standard T44 format file (if the nFormat value is FILE_MRC) or as a TIF file with a MRC subtype format (if the nFormat value is FILE_TIF_MRC). When an nFormat value of FILE_MRC is used, *.MRC is the default file extension. When an nFormat value of FILE_TIF_MRC is used, *.TIF is the default file extension.

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.

Use the LSegment::MrcSaveBitmap function to save a file in the LEAD Proprietary T44 format to:

Take advantage of the greater number of different segment types available when using the proprietary format.

Create smaller files than would be possible by saving them to the standard T44 format.

Create higher quality files than would be possible by saving them to the standard T44 format.

Please note that when creating a Standard T44 format file (calling the LSegment::MrcSaveBitmapT44 function using an nFormat value of FILE_MRC), only one page can be saved.

If segmentation has been performed, when the LSegment::MrcSaveBitmapT44 function is called any 2-bit text, 2-bit grayscale, and 8-bit grayscale segments are treated as 24-bit image segments. If a text segment contains text over a background, when it is saved using the LSegment::MrcSaveBitmapT44 function the background color is lost. For more information on Mixed Raster Content (MRC) formats, refer to General Information.

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

SEGTYPE_BACKGROUND

SEGTYPE_ONECOLOR

SEGTYPE_TEXT_1BIT_BW

SEGTYPE_TEXT_1BIT_COLOR

SEGTYPE_PICTURE

Use the COMPRESSIONOPTIONS structure to set the compression to be used for the different types of segments.

It is best to perform segmentation before calling the LSegment::MrcSaveBitmap function. Segmentation can be performed automatically by calling the LSegment::MrcSegmentBitmapExt 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.

If the bitmap hasn’t been segmented, the function will auto segment it by calling LSegment::MrcSegmentBitmapExt first and then will save it.

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. The 2 bit text segments and the grayscale (2 bit and 8 bit) segments will be treated as 24 bit image segments. For more information, refer to COMPRESSIONOPTIONS.

Control page replacement/insertion operations by using some of the member values available in the SAVEFILEOPTION structure. When saving using an nFormat of FILE_MRC (where only one page can be saved), use the SAVEFILEOPTION.PageNumber member to designate the page number to be saved. When saving using an nFormat of FILE_TIF_MRC, use one of the following SAVEFILEOPTION.Flags values to specify what to do with the image being saved:

Value | Meaning
0 | Overwrite the file.
ESO_REPLACEPAGE | [0x00000400] Replace the page specified by SAVEFILEOPTION.PageNumber.
ESO_INSERTPAGE | [0x00000800] Insert the image before the page specified by SAVEFILEOPTION.PageNumber.

Required DLLs and Libraries

LTSGM

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: | LSegment::MrcSaveBitmap, LSegment::MrcLoadBitmap, LSegment::MrcGetPagesCount, LSegment::MrcSegmentBitmapExt, Class Members
Topics: | General Segmentation
 | Saving Capabilities

Example

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

L_INT SaveBitmap(LSegment Segment, LBitmapBase & Bitmap, L_CHAR * 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;

/* Save the MRC bitmap using the LEAD Proprietary T44 Format */
nRet = Segment.MrcSaveBitmapT44(&Bitmap, &CmpOption, pszFileName, FILE_LEAD_MRC, NULL);
if (nRet != SUCCESS)
return nRet;

return SUCCESS;
}


LSegment::MrcSaveSegmentation

#include "ltwrappr.h"

L_INT EXT_FUNCTION LSegment::MrcSaveSegmentation(pszFileName)

L_TCHAR L_FAR * pszFileName;

/* output file name */

Saves the segments to a file. This function is available in the ( Document/Medical ) toolkits.

Parameter | Description
pszFileName | Character string that contains the output file name.

Returns

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

Comments

This function is used to export the segments from the segmentation handle to the specified file in a binary file format.

Call the LSegment::MrcStartBitmapSegmentation function before using any of the segmentation functions. When the LSegment class object is no longer needed, free it by calling the LSegment::MrcStopBitmapSegmentation function.

Required DLLs and Libraries

LTSGM

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: | LSegment::MrcGetPagesCount, LSegment::MrcCreateNewSegment, LSegment::MrcStartBitmapSegmentation, LSegment::MrcStopBitmapSegmentation, LSegment::MrcSetSegmentData, LSegment::MrcEnumSegments, LSegment::MrcCombineSegments, LSegment::MrcLoadSegmentation, LSegment::MrcCopySegmentationHandle, LSegment::MrcSegmentBitmapExt, Class Members
Topics: | General Segmentation
 | Manual Segmentation

Example

L_INT ExportSegments(LSegment Segment, L_TCHAR L_FAR* pszFileName, LBitmapBase &Bitmap)
{
return Segment.MrcSaveSegmentation(pszFileName);
}


LSegment::MrcSegmentBitmap

#include "ltwrappr.h"

L_INT LSegment::MrcSegmentBitmap(pBitmap, pMinSeg, uSegFactor)

LBitmapBase * pBitmap; | /* pointer to an LBitmapBase object */
pMINSEGMENT pMinSeg; | /* pointer to a structure */
pSEGMENTATIONOPTIONS pSegOpt; | /* pointer to a structure */

Automatically segments the specified bitmap. This function is available in the ( Document/Medical ) toolkits.

Parameter | Description
pBitmap | Pointer to an LBitmapBase object that references the bitmap to be segmented.
pMinSeg | Pointer to the MINSEGMENT structure that contains the desired minimum width and height for the segments.
pSegOpt | Pointer to the SEGMENTATIONOPTIONS structure that controls the auto segmentation process. This cannot be NULL.

Returns

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

Comments

Please note that the LSegment::MrcSegmentBitmap function will be removed in Version 15. It is being replaced with the LSegment::MrcSegmentBitmapExt function.

Call this function to segment the bitmap automatically. LEADTOOLS segments the bitmap into blocks pMinSeg->nMinWidth wide by pMinSeg->nMinHeight long. Blocks with the same characteristics may be combined. Segments are assigned a type according to the number of colors they have (those with a few colors become text segments and those with many colors become picture segments). Call the LSegment::MrcStartBitmapSegmentation function before using any of the segmentation functions. When the LSegment class object is no longer needed, free it by calling the LSegment::MrcStopBitmapSegmentation function.

The nMinWidth and nMinHeight members of the MINSEGMENT structure must be set before calling this function.

Values less than 10x10 pixels will cause an error.

Use the members of the SEGMENTATIONOPTIONS structure to control the segmentation process. If the LSegment::MrcSegmentBitmap function is called with SEGMENTATIONOPTIONS.uImageType member set to IMAGETYPE_SCANNED, noise is removed from the image before segmenting it. Set the uImageType member to IMAGETYPE_COMPUTERGENERATED if noise does not need to be removed from the image.

Required DLLs and Libraries

LTSGM

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: | LSegment::MrcStartBitmapSegmentation, LSegment::MrcStopBitmapSegmentation, LSegment::MrcEnumSegments, LSegment::MrcSetSegmentData, LSegment::MrcDeleteSegment, Class Members
Topics: | General Segmentation
 | Auto-Segmentation

Example

The following example illustrates the use of LSegment::MrcSegmentBitmap to perform auto segmentation.

// Create a new class derived from LSegment and
// override LSegment::MrcEnumSegmentsCallBack
class LUserSeg : public Lsegment
{
virtual L_INT MrcEnumSegmentsCallBack(const pSEGMENTDATA pSegment,
L_INT nSegId)
{
L_TCHAR szSegmentRect[256];
L_TCHAR szSegmentId[256];

memset(szSegmentRect, 0, 256);
memset(szSegmentId, 0, 256);

wsprintf(szSegmentId, TEXT("Segment ID %d"), nSegId);
wsprintf(szSegmentRect, TEXT("Left = %d, Top = %d, Right = %d, Bottom = %d"), pSegment->rcBitmapSeg.left, pSegment->rcBitmapSeg.top, pSegment->rcBitmapSeg.right, pSegment->rcBitmapSeg.bottom);

MessageBox(NULL, szSegmentRect, szSegmentId, MB_OK);

return SUCCESS;
}
};

L_VOID AutoSegmentBitmap(LBitmapBase & Bitmap)
{
LUserSeg Segment;
MINSEGMENT ms;
SEGMENTATIONOPTIONS SegOpt;

// Specify the minimum segment width and height
ms.uStructSize = sizeof(MINSEGMENT);
ms.nMinWidth = 60;
ms.nMinHeight = 60;

// Specify the segmentation options
SegOpt.uStructSize = sizeof(SEGMENTATIONOPTIONS);
SegOpt.uSensitivity = 25;
SegOpt.uCombineFlags = COMBINE_TRY;
SegOpt.uCombineFactor = 30;
SegOpt.uImageType = IMAGETYPE_COMPUTERGENERATED;

// Initialize the segmentation process
Segment.MrcStartBitmapSegmentation(&Bitmap,
RGB(255, 255, 255),
RGB(0, 0, 0));
// Perform the auto segmentation process
Segment.MrcSegmentBitmap(&Bitmap, &ms, &SegOpt);

// Enumerate the resulted segments
Segment.MrcEnumSegments(0);

// Clean up
Segment.MrcStopBitmapSegmentation ();
}


LSegment::MrcSetSegmentData

#include "ltwrappr.h"

L_INT LSegment::MrcSetSegmentData(pBitmap, nSegId, pSegmentData)

LBitmapBase * pBitmap; | /* pointer to an LBitmapBase object */
L_INT nSegId; | /* segment identifier */
pSEGMENTDATA pSegmentData; | /* new segment information */

Updates the specified segment. This function is available in the ( Document/Medical ) toolkits.

Parameter | Description
pBitmap | Pointer to an LBitmapBase object that references the bitmap in which the segment will be updated.
nSegId | Segment’s ID to be updated.
pSegmentData | Pointer to the SEGMENTDATA structure that contains the new segment information.

Returns

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

Comments

Use this function to update the segment information. In the auto segmentation mode, the LEADTOOLS engine will update the segments using the new segment data passed to this function. This process may create or delete segments. The function will update the segments so they remain within the bitmap width and height.

In the manual segmentation mode, the user is free to update the segments. The LEAD engine will not delete or create segments. If an error occurs, the pSegmentData parameter will be updated with the target segment.

To get segment IDs and segment information, use the LSegment::MrcEnumSegments function to enumerate all segments.

The function will return an error if the updated segment exceeds its stripe boundaries.

Call the LSegment::MrcStartBitmapSegmentation function before using any of the segmentation functions. When the LSegment class object is no longer needed, free it by calling the LSegment::MrcStopBitmapSegmentation function.

Required DLLs and Libraries

LTSGM

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: | LSegment::MrcStartBitmapSegmentation, LSegment::MrcStopBitmapSegmentation, LSegment::MrcSegmentBitmap, LSegment::MrcEnumSegments, LSegment::MrcDeleteSegment, LSegment::MrcCreateNewSegment, Segment::MrcCombineSegments, LSegment::MrcSaveSegmentation, LSegment::MrcLoadSegmentation, LSegment::MrcCopySegmentationHandle, LSegment::MrcSegmentBitmapExt, Class Members
Topics: | General Segmentation
 | Auto-Segmentation
 | Manual Segmentation

Example

The following example uses LSegment::MrcSetSegmentData to update the data of the segment with the identifier 0. It also demonstrates the use of LSegment::MrcDeleteSegment to delete a segment.

// Create a new class derived from LSegment and
// override LSegment::MrcEnumSegments CallBack
class LUserSeg : public Lsegment
{
virtual L_INT MrcEnumSegmentsCallBack(const pSEGMENTDATA pSegment,
L_INT nSegId)
{
L_TCHAR szSegmentRect[256];
L_TCHAR szSegmentId[256];

memset(szSegmentRect, 0, 256);
memset(szSegmentId, 0, 256);

wsprintf(szSegmentId, TEXT("Segment ID %d"), nSegId);
wsprintf(szSegmentRect, TEXT("Left = %d, Top = %d, Right = %d, Bottom = %d"), pSegment->rcBitmapSeg.left, pSegment->rcBitmapSeg.top, pSegment->rcBitmapSeg.right, pSegment->rcBitmapSeg.bottom);

MessageBox(NULL, szSegmentRect, szSegmentId, MB_OK);

return SUCCESS;
}
};

L_INT UpdateSegment(LUserSeg seg,
LBitmapBase & Bitmap,
pSEGMENTDATA pNewSegmentData,
L_INT nSegId)
{
L_INT nRet;

/* update the segments dependent on the new segment */
nRet = seg.MrcSetSegmentData (&Bitmap, nSegId, pNewSegmentData);
if (nRet != SUCCESS)
return nRet;

/* Enumerate the new segments and their id's */
seg.MrcEnumSegments(0);

/* Delete a segment */
nRet = seg.MrcDeleteSegment(nSegId);
if (nRet != SUCCESS)
return nRet;

/* Enumerate the new segments and their id's */
seg.MrcEnumSegments(0);

return SUCCESS;
}


LSegment::MrcStartBitmapSegmentation

#include "ltwrappr.h"

L_INT LSegment::MrcStartBitmapSegmentation(pBitmap, clrBackground, clrForeground)

LBitmapBase * pBitmap; | /* pointer to an LBitmapBase object */
COLORREF clrBackground; | /* default base background color */
COLORREF clrForeground; | /* default base foreground color */

Initializes internal fields of the class object. This function is available in the ( Document/Medical ) toolkits.

Parameter | Description
pBitmap | Pointer to an LBitmapBase object that references the bitmap to be segmented.
clrBackground | Default base background color for the MRC bitmap.
clrForeground | Default base foreground color for the MRC bitmap.

Returns

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

Comments

LSegment::MrcStartBitmapSegmentation must be called before calling any other LEADTOOLS segmentation functions.

When the class object of the segmentation is no longer needed, it should be freed by calling LSegment::MrcStopBitmapSegmentation. For every call to LSegment::MrcStartBitmapSegmentation there must be a call to LSegment::MrcStopBitmapSegmentation.

Required DLLs and Libraries

LTSGM

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: | LSegment::MrcStopBitmapSegmentation, LSegment::MrcSetSegmentData, LSegment::MrcDeleteSegment, LSegment::MrcEnumSegments, LSegment::MrcCombineSegments, LSegment::MrcSaveSegmentation, LSegment::MrcLoadSegmentation, LSegment::MrcCopySegmentationHandle, LSegment::MrcSegmentBitmapExt, Class Members
Topics: | General Segmentation
 | Auto-Segmentation
 | Manual Segmentation
 | Using Color Values in LEADTOOLS

Example

For an example, refer to LSegment::MrcSegmentBitmap.


LSegment::MrcStopBitmapSegmentation

#include "ltwrappr.h"

L_INT LSegment::MrcStopBitmapSegmentation(L_VOID)

Ends the bitmap segmentation and frees all data variables and buffers allocated by the segmentation class object. This function is available in the ( Document/Medical ) toolkits.

Returns

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

Comments

The segmentation class object is allocated by calling the LSegment::MrcStartBitmapSegmentation function.

For each call to LSegment::MrcStartBitmapSegmentation there must a call to LSegment::MrcStopBitmapSegmentation.

This function should be the last function to be called in the segmentation functions. It will clean up and free memory allocated by the segmentation class object.

Required DLLs and Libraries

LTSGM

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: | LSegment::MrcCreateNewSegment, LSegment::MrcStartBitmapSegmentation, LSegment::MrcSetSegmentData, LSegment::MrcDeleteSegment, LSegment::MrcEnumSegments, LSegment::MrcCombineSegments, LSegment::MrcSaveSegmentation, LSegment::MrcLoadSegmentation, LSegment::MrcCopySegmentationHandle, LSegment::MrcSegmentBitmapExt, Class Members
Topics: | General Segmentation
 | Auto-Segmentation
 | Manual Segmentation

Example

For an example, refer to LSegment::MrcSegmentBitmap.


LSegment::MrcSaveBitmapList

#include "ltwrappr.h"

#include "ltsgm.h"

L_INT LSegment::MrcSaveBitmapList(uhSegmentCount, hList, pCmpOption, pszFileName, nFormat)

L_UINT32 uhSegmentCount; | /* segmentation handles count*/
HBITMAPLIST hList; | /* handle to a list of bitmaps */
pCOMPRESSIONOPTIONS pCmpOption; | /* pointer to the compression options structure */
L_TCHAR L_FAR * pszFileName; | /* output file name */
L_INT nFormat; | /* output file format */

Saves MRC images contained in a bitmap list to a file using the MRC LEAD, standard Proprietary T44 or PDF format. This function is available in the ( Document/Medical ) toolkits.

Parameter | Description
uhSegmentCount | Number of segmentations.
hList | Handle to the list of bitmaps that holds the image data.
pCmpOption | Pointer to the COMPRESSIONOPTIONS structure that contains the compression information to use when saving the file.
pszFileName | Character string that contains the output file name.
nFormat | Output file format. Possible values are:
 | Value | Meaning
 | FILE_TIF_MRC | [177] Tagged Image File with standard MRC Compression (Standard T44). (Supports multi-page).
 | FILE_PDF_LEAD_MRC | [338] PDF compression using MRC segmentation technique.
 | FILE_TIF_LEAD_MRC | [315] Tagged Image File with LEAD proprietary MRC. (Supports multi-page). The default file extension is *.TIF.

Returns

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

Comments

Use this function to save a list of bitmaps as a TIF file using the Standard T44 format (if the nFormat value is FILE_TIF_MRC), as a TIF file with a LEAD MRC subtype format (if the nFormat value is FILE_TIF_LEAD_MRC), or as a multipage PDF using segmentation capabilities (if the nFormat value is FILE_PDF_LEAD_MRC). If nFormat is FILE_TIF_MRC or FILE_TIF_LEAD_MRC, *.TIF is the default file extension. If nFormat is FILE_PDF_LEAD_MRC, *.PDF is the default file extension.

Use the LSegment::MrcSaveBitmapList function to save a list of bitmaps as a TIF file with a Standard T44 subtype format, LEAD MRC subtype format, or PDF file, based on the LEAD segmentation technique, if you want to:

Take advantage of the greater number of different segment types available when using the proprietary format.

Create smaller files than would be possible by saving them to the Standard T44 format.

Create higher quality files than would be possible by saving them to the Standard T44 format.

All formats supported by this function generate multi-page files (TIF, or PDF). The number of pages in the file is either uhSegmentCount or the number of images in hList, whichever is smaller.

Use the LSegment::MrcSaveBitmapT44, or LSegment::MrcSaveBitmap functions to save a single image or to append, inset overwrite to already existing TIF file.

It is best to perform segmentation for all images in the list before calling the LSegment::MrcSaveBitmapList function. Segmentation can be performed automatically by calling the LSegment::MrcSegmentBitmapExt 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::MrcSaveBitmapList 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 hasn’t been segmented, or has any NULL element, then the function will automatically segment the bitmaps in hList by calling LSegment::MrcSegmentBitmapExt. The LSegment::MrcSegmentBitmapExt 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 (1-bit), 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, and the nGrayscale8BitQFactor members of the COMPRESSIONOPTIONS structure are used only with the FILE_TIF_LEAD_MRC formats. The nText2BitCoder member of the COMPRESSIONOPTIONS structure is used with the FILE_TIF_LEAD_MRC and FILE_PDF_LEAD_MRC formats only.

Required DLLs and Libraries

LTSGM

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: | LSegment::MrcSaveBitmapT44, LSegment::MrcLoadBitmap, LSegment::MrcGetPagesCount, LSegment::MrcSegmentBitmapExt, Class Members
Topics: | Saving Capabilities
 | Class Library Function Groups

Example

L_INT SaveBitmapListExample(LSegment& LeadSegment, L_UINT uhSegments, HBITMAPLIST hList, L_TCHAR L_FAR* 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 list using the LEAD Proprietary T44 Format */
nRet = LeadSegment.MrcSaveBitmapList(uhSegments, hList, &CmpOption, pszFileName, FILE_TIF_LEAD_MRC);

return nRet;
}


LSegment::MrcSegmentBitmapExt

#include "ltwrappr.h"

L_INT LSegment::MrcSegmentBitmapExt(pBitmap, pSegOption)

LBitmapBase * pBitmap; | /* pointer to a bitmap handle */
pSEGMENTEXTOPTIONS pSegOption; | /* pointer to a structure */

Automatically segments the specified bitmap, finding the best segment combination without specifying minimum segment dimensions. This function is available only in the Document/Medical Toolkits.

Parameter | Description
pBitmap | Pointer to the bitmap object that references the bitmap to be segmented.
pSegOption | Pointer to the SEGMENTEXTOPTIONS structure that controls the automatic segmentation process. This cannot be NULL.

Returns

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

Comments

Please note that this function handles background segments and certain text segments that the LSegment::MrcSegmentBitmap function. In addition, the LSegment::MrcSegmentBitmap function will be removed in the next major release of LEADTOOLS and this function will replace it.

Call this function to segment the bitmap automatically. LEAD will process the bitmap and break it into appropriate picture, grayscale, text and background segments.

Call the LSegment::MrcStartBitmapSegmentation function before using any of the segmentation functions. When the LSegment class object is no longer needed, free it by calling the LSegment::MrcStopBitmapSegmentation function.

Required DLLs and Libraries

LTSGM

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: | LSegment::MrcStartBitmapSegmentation, LSegment::MrcStopBitmapSegmentation, LSegment::MrcSetSegmentData, LSegment::MrcEnumSegments, LSegment::MrcDeleteSegment, LSegment::MrcCombineSegments, LSegment::MrcSaveSegmentation, LSegment::MrcLoadSegmentation, LSegment::MrcCopySegmentationHandle, LSegment::MrcSegmentBitmap, Class Members
Topics: | Auto-Segmentation
 | MRC Bitmap Functions: Automatic Segmentation

Example

class LSegmentChild : public Lsegment
{
L_INT MrcEnumSegmentsCallBack(const pSEGMENTDATA pSegment, L_INT nSegId)
{
L_TCHAR szSegmentRect[256];
L_TCHAR szSegmentId[256];

memset(szSegmentRect, 0, 256);
memset(szSegmentId, 0, 256);

wsprintf(szSegmentId, TEXT("Segment ID %d"), nSegId);
wsprintf(szSegmentRect, TEXT("Left = %d, Top = %d, Right = %d, Bottom = %d"), pSegment->rcBitmapSeg.left, pSegment->rcBitmapSeg.top, pSegment->rcBitmapSeg.right, pSegment->rcBitmapSeg.bottom);

MessageBox(NULL, szSegmentRect, szSegmentId, MB_OK);

return SUCCESS;
}
};

void MrcSegmentBitmapExtExample(LBitmap& LeadBitmap)
{
LSegmentChild segment ;
SEGMENTEXTOPTIONS SegOpt;
L_INT nRet = 0 ;

memset(&SegOpt,0,sizeof(SegOpt));
/* Specify the minimum segment width and height*/
SegOpt.uStructSize = sizeof(SegOpt);
SegOpt.uBackGroundThreshold = 10;
SegOpt.uSegmentQuality = 50;
SegOpt.uColorThreshold = 25;
SegOpt.uCleanSize = 5;
SegOpt.uCombineThreshold = 75;

/* Start the segmentation process */
nRet = segment.MrcStartBitmapSegmentation (&LeadBitmap, RGB(255, 255, 255), RGB(0, 0, 0));
if(nRet == SUCCESS)
{
/* do the auto-segmentation*/
nRet = segment.MrcSegmentBitmapExt(&LeadBitmap, &SegOpt);
if(nRet == SUCCESS)
{
segment.EnableCallBack (TRUE);
nRet = segment.MrcEnumSegments (0);
segment.EnableCallBack(FALSE);

/* end the segmentation process */
nRet = segment.MrcStopBitmapSegmentation ();
}
}
}


Raster Pro/Document/Medical Features

Raster Pro:

LEADTOOLS Raster Imaging Pro provides some imaging capabilities that are not available in the LEADTOOLS Raster Imaging product. In order to access these features, you must unlock them by calling LSettings::UnlockSupport (L_SUPPORT_LTPRO, L_KEY_LTPRO). L_KEY_LTPRO can be found in ltkey.h.

If you are a licensed user of LEADTOOLS Raster Imaging, and would like to access Raster Imaging Pro features, you must contact Tech Support for information on obtaining a license and the unlock key for calling LSettings::UnlockSupport.

Document/Medical:

LEADTOOLS Document Imaging, LEADTOOLS Document Imaging Suite, LEADTOOLS Medical Imaging and LEADTOOLS Medical Imaging Suite are the most comprehensive imaging toolkits on the market. No other toolkit provides as many imaging features for color, gray-scale and black & white images in one development package, and for one price. These toolkits comprise LEAD's best code and are designed for the programmer who is looking for the fastest performance, and/or the most extensive color, document, and medical imaging capabilities available.

These toolkits contain powerful annotation capabilities and optimized document image processing filters, and high performance compression, decompression and viewing of JPEG, LEAD CMP, MRC and CCITT G3/G4. The annotation capabilities enable the programmer to add text, highlights, sticky notes, audio, ellipses, buttons, lines, arrows, rectangles, polygons, redaction (blackout), hotspots, freehand scribble, pointers, bitmap and text stamps, to black & white and color images. Programmers working with document imaging will also find special processing filters such as despeckle, deskew, favor black, and scale to gray to enhance their black and white 1 bit images. Additionally, you can achieve faster rotation in 90-degree increments by applying a rotated view perspective to the bitmap. These LEADTOOLS toolkits offer the fastest software-only JPEG decoder available.

LEADTOOLS Document Imaging

The LEADTOOLS Document Imaging toolkit contains all the features available in the LEADTOOLS Raster Imaging Pro. In addition, it contains the following capabilities:

Special functions for Document (bitonal) images. The LEADTOOLS functions for bitonal images are especially useful for working with images from black-and-white scanners or FAX machines. These functions let you do things such as automatically straighten (deskew) an image, remove spots (despeckle), or clarify a scaled display (using scale-to-gray and favor-black features).

Annotation. LEADTOOLS supports annotation of images by letting you overlay images with text, lines, shapes, arrows, buttons, highlights, hot spots, sticky notes, stamps, buttons, and sounds.

Fast rotation. LEADTOOLS achieves fast rotation in 90-degree increments by applying a rotated view perspective to the bitmap.

ISIS support. LEADTOOLS supports ISIS interfaces for driving scanning devices.

Faster compression and decompression. The Document/Medical editions work faster when loading and saving LEAD CMP, JPEG, and CCITT Group 3 and Group 4 images. The LEADTOOLS functions for loading and saving are the same in all products. The only difference is in performance.

1-bit Image Clean-up. The Document toolkits include support for removing dots, blobs, holes, inverted text, lines, borders, bumps and nicks from 1-bit images.

Region Clean-up. [Document/Medical] Remove all the holes from a region.

Embedded Messages. The Document toolkits include support for embedding messages in lossless image formats like bmp, tiff, lossless jpeg, etc. The message is embedded without any visible changes to the image, and does not appreciably increase the size of the image. The message is password-protected.

Image Conversion. The Document toolkits include support for transforming a bitmap into a binary image using specified thresholds or a threshold calculated automatically based on statistical features of the bitmap.

12 and 16 bit grayscale images. [Document/Medical] Load, process, display, window level and save 12 and 16 bit grayscale images (including support for 16-bit grayscale TIFF).

48 and 64 bit color images. [Document/Medical] Load, process, display, and save 48 and 64 bit color images.

MRC Support. [Document/Medical] LEADTOOLS supports the Mixed Raster Content format for color documents containing mixed image and text components.

Halftoning. [Document/Medical] Convert 1-, 4-, 8-, 16-, 24-, or 32-bit bitmaps to a halftoned bitmap, with a specified pattern rotation. A halftoned bitmap is a 1-bit bitmap that has been dithered for black and white printing or display.

LEADTOOLS Document Imaging Suite

The LEADTOOLS Document Imaging Suite toolkit contains all the capabilities of LEADTOOLS Document Imaging, and includes the features listed below. Please note that the OCR features are included in this toolkit, however they can also be purchased as a plug-in for the LEADTOOLS Document Imaging toolkit. Also, JBIG support is provided in this toolkit, however a JBIG Module may be added on to LEADTOOLS Document Imaging, LEADTOOLS Medical Imaging or LEADTOOLS Medical Imaging Suite.

OCR features. [Document/Medical] LEAD offers OCR features that use Scansoft Textbridge technology. Support for these features is included in the LEADTOOLS Document Imaging Suite, and can be added, via plug-in to the LEADTOOLS Document Imaging, LEADTOOLS Medical Imaging and LEADTOOLS Medical Imaging Suite toolkits. The OCR features allow you to perform optical character recognition and turn images into documents. Features include preset confidence and accuracy levels for controlling how sensitive the engine is to unrecognized text, artificial intelligence for improving recognition on documents of the same type, and built-in and user-defined lexicons for limiting the type of text to recognize within a particular zone. LEADTOOLS provides the ability to verify or correct text during, and (using LEAD's unique OCR editor) after recognition. LEAD's OCR editor ties the text being edited directly to the image, providing a visual reference to the original bitmap data. The OCR engine can perform Automatic area segmentation creating multi-layered zones, recognizing areas such as tables, rules, images and text. Or, you can manually designate up to 250 such zones. The OCR features support different fonts, sizes (5 to 72 point) and styles. Fax, dot matrix and halftones can be preprocessed to improve recognition results. The OCR Engine supports major European and Scandinavian languages (Danish, Dutch, Finnish, French, German, Italian, Norwegian, Portuguese, Russian, Spanish, and Swedish) as well as English. Support for dialects such as US. English, French Canadian, Latin American Spanish, Swiss German, and Brazilian Portuguese is also provided.

Recognized text can be exported to more than 40 different formats, including MS Word, MS Excel, Dbase andWordPerfect. The LEADTOOLS OCR features contain superior OCR processing speeds, for use in form recognition and processing applications.

LEAD's JBIG filter. [Document/Medical] LEAD includes support for this filter in the LEADTOOLS Document Imaging Suite toolkit. Support for this filter can be added to LEADTOOLS Document Imaging, LEADTOOLS Medical Imaging or LEADTOOLS Medical Imaging Suite by purchasing the JBIG Module. JBIG defines a method for lossless compression encoding of a bi-level image (two-color image). This method can also be used for coding grayscale and color images. LEADTOOLS completely supports all three types of images, giving you the ability to make full use of this powerful compression technology. LEADTOOLS also supports the progressive capability of JBIG, allowing you to store and send multiple representations of images at different resolutions without any extra storage overhead.

LEADTOOLS Medical Imaging

LEADTOOLS Medical Imaging contains all the capabilities of LEADTOOLS Document Imaging. It also includes general medical imaging technologies (1-16,24,32 bit color, 1-16 bit grayscale and window leveling of 12 and 16-bit grayscale images) and support for the DICOM file format.

DICOM file support. [Medical] LEADTOOLS Medical Imaging provides COMPLETE support for the DICOM 3.0 specification, including all standard IOD classes and modalities (CR, CT, MR, NM, US, RF, SC, VL, etc.) and complete DICOM Basic Directory support.

Window leveling. [Document/Medical] Detect and set LowBit and HighBit for image data, display images with automatic LUT intensity expansion, or set LUT entries and ranges with specific values and gradients. Display images through the LUT without changing the data, or process the image data using the LUT. Linearize the number of pixels locally in a bitmap, based on the specified color space in order to bring out the detail in dark areas of an image, and smooth the edges between blocks.

Medical Imaging Processing. [Medical] LEADTOOLS Medical Imaging provides image processing functionality designed specifically to allow you to examine and improve the quality of medical images.

LEADTOOLS Medical Imaging Suite

LEADTOOLS Medical Imaging Suite contains all the capabilities of LEADTOOLS Medical Imaging. In addition, it supports the following:

DICOM Communication support. [Medical Suite] LEADTOOLS provides COMPLETE support for DICOM Communications, including all Service Classes (Verification, Storage, Query/Retrieve, Patient Management, etc), and contains high-level communications functions simplifying the creation of DICOM client/server applications.

(Document/Medical) is used in the documentation to designate the features that are available in LEADTOOLS Document Imaging, LEADTOOLS Document Imaging Suite, LEADTOOLS Medical Imaging and LEADTOOLS Medical Imaging Suite. Those features that are available only in the Medical toolkits are indicated in the documentation by (Medical). Features available only in the LEADTOOLS Medical Imaging Suite toolkit are indicated in the documentation by (Medical Suite).

(Internet only) is used in the documentation to designate the features that are available only in the LEADTOOLS Internet toolkit.

For more information, refer to Document/Medical Edition Support and Licensing Requirements .


LEADTOOLS Reference Manuals

LEADTOOLS provides reference manuals that contain the same information as the online help. You can print them from PDF files. Please note that due to the large size of the PDF files that contain the LEADTOOLS manuals, these files are no longer included in the setup. Instead, these PDF files can be downloaded from our website at http://support.leadtools.com/SupportPortal/DesktopDefault.aspx?tabindex=3&tabid=27.

To print the PDF files, you must use the Adobe Acrobat Reader 3.0 or higher. You can download a copy of the Acrobat Reader from the Adobe web site (http://www.adobe.com). Note that different versions of the Acrobat Reader are available for different operating systems, but they all can read the same PDF files.


Topic Selection

LEAD Technologies, Inc.
Suite 400
1201 Greenwood Cliff
Charlotte, NC 28204

Sales@Leadtools.com
www.leadtools.com

(704) 332-5532
FAX: (704) 372-8161
Tech Support: (704) 372-9681

LEADTOOLS is ideal for developers involved in still frame, multimedia, document, medical, and vector imaging projects, including Internet/Intranet applications. Independent of the specific application requirement – scanning, file format support/conversion, compression, image processing, annotation, database support, multimedia, etc. – LEADTOOLS provides the most comprehensive, robust, flexible, and powerful imaging solution available.

Click this button to start the Licensing help file to review the License Agreements governing your use of the software.

Click this button to start the Products help file to review the full line of LEADTOOLS Products.

Click this button to start the Imaging help file to review the full line of LEADTOOLS Image Categories.