Leadtools.Mrc Requires Document/Medical product license | Send comments on this topic. | Back to Introduction - All Topics | Help Version 16.5.9.25
SaveBitmapList Method
See Also  Example
Leadtools.Mrc Namespace > MrcSegmenter Class : SaveBitmapList Method



segmenters
List of MrcSegmenter objects.
images
List of images to be saved.
fileName
Output file name.
format
Output file format.
options
Structure that contains the compression information to use when saving the file.
segmenters
List of MrcSegmenter objects.
images
List of images to be saved.
fileName
Output file name.
format
Output file format.
options
Structure that contains the compression information to use when saving the file.
Saves MRC images contained in an image list to a file using the MRC LEAD, standard Proprietary T44 or PDF format.

Syntax

Visual Basic (Declaration) 
Public Shared Sub SaveBitmapList( _
   ByVal segmenters As List(Of MrcSegmenter), _
   ByVal images As List(Of RasterImage), _
   ByVal fileName As String, _
   ByVal format As MrcImageListFormat, _
   ByVal options As MrcCompressionOptions _
) 
Visual Basic (Usage)Copy Code
Dim segmenters As List(Of MrcSegmenter)
Dim images As List(Of RasterImage)
Dim fileName As String
Dim format As MrcImageListFormat
Dim options As MrcCompressionOptions
 
MrcSegmenter.SaveBitmapList(segmenters, images, fileName, format, options)
C# 
public static void SaveBitmapList( 
   List<MrcSegmenter> segmenters,
   List<RasterImage> images,
   string fileName,
   MrcImageListFormat format,
   MrcCompressionOptions options
)
C++/CLI 
public:
static void SaveBitmapList( 
   List<MrcSegmenter>^ segmenters,
   List<RasterImage>^ images,
   String^ fileName,
   MrcImageListFormat format,
   MrcCompressionOptions options
) 

Parameters

segmenters
List of MrcSegmenter objects.
images
List of images to be saved.
fileName
Output file name.
format
Output file format.
options
Structure that contains the compression information to use when saving the file.

Example

Visual BasicCopy Code
Private Function MrcListSegmentation(ByVal image As RasterImage) As MrcSegmenter
    Dim segmentImageOptions As MrcSegmentImageOptions = MrcSegmentImageOptions.Empty
    segmentImageOptions.CleanSize = 5
    segmentImageOptions.SegmentQuality = 50
    segmentImageOptions.ColorThreshold = 25
    segmentImageOptions.BackgroundThreshold = 10
    segmentImageOptions.CombineThreshold = 75
    segmentImageOptions.Flags = MrcSegmentImageFlags.FavorOneBit Or MrcSegmentImageFlags.SegmentWithBackground
    Dim backColor As RasterColor = New RasterColor(255, 255, 255)
    Dim foreColor As RasterColor = New RasterColor(0, 0, 0)
    Dim mrcSegmenter As MrcSegmenter = New MrcSegmenter(image, Color.White, Color.Black)
    mrcSegmenter.SegmentImage(image, segmentImageOptions)
    Return mrcSegmenter
End Function


Public Sub SaveBitmapListExample()
    ' Load an image
    RasterCodecs.Startup()
    Dim codecs As RasterCodecs = New RasterCodecs()
    codecs.ThrowExceptionsOnInvalidImages = True
    Dim image1 As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "MRCSegmentation.mrc")

    ' Load an image
    Dim image2 As RasterImage = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "MRCSegmentation.mrc")

    Dim segmenter1 As MrcSegmenter = MrcListSegmentation(image1)
    Dim segmenter2 As MrcSegmenter = MrcListSegmentation(image2)
    Dim segmenter3 As MrcSegmenter = CType(segmenter2.Clone(), MrcSegmenter)
    Dim segmenterList As List(Of MrcSegmenter) = New List(Of MrcSegmenter)()

    segmenterList.Add(segmenter1)
    segmenterList.Add(segmenter2)
    segmenterList.Add(segmenter3)

    Dim segmenterArray As MrcSegmenter() = New MrcSegmenter(2) {}

    segmenterList.CopyTo(segmenterArray, 0)

    Dim imageList As List(Of RasterImage) = New List(Of RasterImage)()
    Dim index As Integer

    For index = 0 To 2
        If segmenterList.Contains(segmenterArray(index)) Then
            Select Case segmenterList.IndexOf(segmenterArray(index))
                Case 0
                    imageList.Add(image1)
                Case 1
                    imageList.Add(image2)
                Case 2
                    ' Remove the last segmenter from the segmenter array...
                    segmenterList.Remove(segmenterArray(index))
            End Select
        End If
    Next index
    Dim compressionOptions As MrcCompressionOptions = New MrcCompressionOptions()

    compressionOptions.MaskCoder = MrcMaskCompression.FaxG31D
    compressionOptions.PictureCoder = MrcPictureCompression.Jpeg
    compressionOptions.PictureQualityFactor = 10
    compressionOptions.Text2BitCoder = MrcTextCompression2BitCoder.Gif2Bit
    compressionOptions.Grayscale2BitCoder = MrcGrayscaleCompression2BitCoder.Jbig2
    compressionOptions.Grayscale8BitCoder = MrcGrayscaleCompression8BitCoder.GrayscaleCmw
    compressionOptions.Grayscale8BitFactor = 2

    ' Save the two segmenters
    MrcSegmenter.SaveBitmapList(segmenterList, imageList, LeadtoolsExamples.Common.ImagesPath.Path + "SaveBitmapListResult.mrc", MrcImageListFormat.MrcTif, compressionOptions)
End Sub
C#Copy Code
private MrcSegmenter MrcListSegmentation(RasterImage image) 

   MrcSegmentImageOptions segmentImageOptions = MrcSegmentImageOptions.Empty; 
   segmentImageOptions.CleanSize = 5; 
   segmentImageOptions.SegmentQuality = 50; 
   segmentImageOptions.ColorThreshold = 25; 
   segmentImageOptions.BackgroundThreshold = 10; 
   segmentImageOptions.CombineThreshold = 75; 
   segmentImageOptions.Flags = MrcSegmentImageFlags.FavorOneBit | MrcSegmentImageFlags.SegmentWithBackground; 
   RasterColor backColor = new RasterColor(255, 255, 255); 
   RasterColor foreColor = new RasterColor(0, 0, 0); 
   MrcSegmenter mrcSegmenter = new MrcSegmenter(image, Color.White, Color.Black); 
   mrcSegmenter.SegmentImage(image, segmentImageOptions); 
   return mrcSegmenter; 

 
 
public void SaveBitmapListExample() 

   // Load an image 
   RasterCodecs.Startup(); 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
   RasterImage image1 = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "MRCSegmentation.mrc"); 
 
   // Load an image 
   RasterImage image2 = codecs.Load(LeadtoolsExamples.Common.ImagesPath.Path + "MRCSegmentation.mrc"); 
 
   MrcSegmenter segmenter1 = MrcListSegmentation(image1); 
   MrcSegmenter segmenter2 = MrcListSegmentation(image2); 
   MrcSegmenter segmenter3 = (MrcSegmenter) segmenter2.Clone(); 
   List<MrcSegmenter> segmenterList = new List<MrcSegmenter>(); 
 
   segmenterList.Add(segmenter1); 
   segmenterList.Add(segmenter2); 
   segmenterList.Add(segmenter3); 
 
   MrcSegmenter[] segmenterArray = new MrcSegmenter[3]; 
 
   segmenterList.CopyTo(segmenterArray, 0); 
 
   List<RasterImage> imageList = new List<RasterImage>(); 
   int index; 
 
   for(index = 0 ; index < 3; index++) 
   { 
      if (segmenterList.Contains(segmenterArray[index])) 
      { 
         switch (segmenterList.IndexOf(segmenterArray[index])) 
         { 
            case 0: 
               imageList.Add(image1); 
               break; 
            case 1: 
               imageList.Add(image2); 
               break; 
            case 2: 
               // Remove the last segmenter from the segmenter array... 
               segmenterList.Remove(segmenterArray[index]); 
               break; 
         } 
      } 
   } 
   MrcCompressionOptions compressionOptions = new MrcCompressionOptions(); 
 
   compressionOptions.MaskCoder = MrcMaskCompression.FaxG31D; 
   compressionOptions.PictureCoder = MrcPictureCompression.Jpeg; 
   compressionOptions.PictureQualityFactor = 10; 
   compressionOptions.Text2BitCoder = MrcTextCompression2BitCoder.Gif2Bit; 
   compressionOptions.Grayscale2BitCoder = MrcGrayscaleCompression2BitCoder.Jbig2; 
   compressionOptions.Grayscale8BitCoder = MrcGrayscaleCompression8BitCoder.GrayscaleCmw; 
   compressionOptions.Grayscale8BitFactor = 2; 
 
   // Save the two segmenters 
   MrcSegmenter.SaveBitmapList(segmenterList, imageList, LeadtoolsExamples.Common.ImagesPath.Path + "SaveBitmapListResult.mrc", MrcImageListFormat.MrcTif, compressionOptions); 
}

Remarks

This method is available in the Document/Medical toolkits.
Use this method to save a list of images as a:
  • TIF file using the Standard T44 format (if the format parameter is set to MrcT44Tif).
  • TIF file with a LEAD MRC subtype format (if the format parameter is set to MrcTif).
  • Multipage PDF using segmentation capabilities (if the format parameter is set to MrcPdf).
If format parameter is set to MrcT44Tif or MrcTif, *.TIF is the default file extension.
If format parameter is set to MrcPdf, *.PDF is the default file extension.
Use this method to save a list of images 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 method generate multi-page files (TIF, or PDF). The number of pages in the file is the number of images in the list, whichever is smaller.
Use the MrcSegmenter.SaveImageT44, or MrcSegmenter.SaveImage methods 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 this method. Segmentation can be performed automatically by calling the MrcSegmenter.SegmentImage method, or performed manually by calling the MrcSegmenter.AddSegment method.
When using this method, segments can be any value of the MrcSegmentType enumeration values.
The MrcSegmenter.SegmentImage method 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 image 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.
If the options parameter is empty, then the method 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 MrcCompressionOptions. Note that the Grayscale2BitCoder, the Grayscale8BitCoder, and the Grayscale8BitFactor properties of the MrcCompressionOptions structure are used only with the MrcTif formats. The Text2BitCoder property of the MrcCompressionOptions structure is used with the MrcTif and MrcPdf formats only. For more information, refer to Programming with LEADTOOLS MRC.

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also

Leadtools.Mrc requires a Document or Medical toolkit license and unlock key. For more information, refer to: Imaging Pro/Document/Medical Features