←Select platform

SegmentTypeFlags Enumeration

Summary
Flags that identify the type of the segment.

Syntax
C#
C++/CLI
Python
[FlagsAttribute()] 
public enum SegmentTypeFlags   
[FlagsAttribute()] 
public enum class SegmentTypeFlags   
class SegmentTypeFlags(Enum): 
   Background = 0 
   OneBit = 1 
   OnBitBW = 2 
   TwoBit = 3 
   TwoBitGray = 4 
   Gray = 5 
   Picture = 6 
   TwoBitBW = 7 
   OneColor = 8 
Members
ValueMemberDescription
0x00000000Background The segment uses one color that represents the image background.
0x00000001OneBit The segment is a 1BPP image.
0x00000002OnBitBW The segment is a 1BPP black and white image.
0x00000003TwoBit The segment is a 2BPP image.
0x00000004TwoBitGray The segment is a 2BPP gray scale image.
0x00000005Gray The segment is a gray scale image.
0x00000006Picture The segment is a picture.
0x00000007TwoBitBW The segment is a 2BPP black and white image.
0x00000008OneColor The segment has only one color.
Example
C#
using Leadtools; 
using Leadtools.PdfCompressor; 
using Leadtools.Codecs; 
 
 
public void pdfCompressor_SegmentImage_PdfDocument(object sender, PdfCompressorSegmentImageEventArgs e) 
{ 
   //This will prevent addition to any segment with type background in all pages except the first page only 
   if (e.Page != 0 && e.Segment.Type == SegmentTypeFlags.Background) 
      e.Cancel = true; 
   else 
      e.Cancel = false; 
 
} 
 
public void PdfCompressorExample_PdfDocument() 
{ 
   // Load an image 
   RasterCodecs codecs = new RasterCodecs(); 
   codecs.ThrowExceptionsOnInvalidImages = true; 
 
   RasterImage image = codecs.Load(Path.Combine(LEAD_VARS.ImagesDir, "MRCSegmentation.mrc")); 
 
   PdfCompressorEngine pdfCompressor = new PdfCompressorEngine(); 
   PdfCompressorCompressionTypes compressionTypes = new PdfCompressorCompressionTypes(); 
 
   //Sets compression types needed for each segment 
   compressionTypes.Comp1Bit = PdfCompressor1BitCompression.Zip1Bit; 
   compressionTypes.Comp2Bit = PdfCompressor2BitCompression.Lzw2Bit; 
   compressionTypes.CompPicture = PdfCompressorPictureCompression.JpgPic; 
   compressionTypes.QFactor = 2; 
   //Flags for used compression types should be set 
   compressionTypes.Flags = EnabledCompressionsFlags.EnableOneBit | 
      EnabledCompressionsFlags.EnableTwoBit | 
      EnabledCompressionsFlags.EnablePicture; 
 
   pdfCompressor.SetCompression(compressionTypes); 
 
   pdfCompressor.Insert(image); 
   pdfCompressor.SegmentImage += new EventHandler<PdfCompressorSegmentImageEventArgs>(pdfCompressor_SegmentImage_PdfDocument); 
   pdfCompressor.Write(Path.Combine(LEAD_VARS.ImagesDir, "Out_Image.pdf")); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

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

Leadtools.PdfCompressor Assembly

Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.