←Select platform

BitsPerPixel Property

Summary

Bits per pixel to use when saving the document.

Syntax
C#
C++/CLI
Java
Python
public int BitsPerPixel { get; set; } 
public:  
   property int BitsPerPixel 
   { 
      int get() 
      void set(int value) 
   } 
public int getBitsPerPixel() 
public void setBitsPerPixel(int value) 
BitsPerPixel # get and set (SaveDocumentOptions) 

Property Value

The bits per pixel to use when saving the document. Default value is 0.

Remarks

If the value of BitsPerPixel is the default 0, then the document will be saved using the bits per pixel of the original document.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Document.Writer; 
 
using Leadtools.Document; 
using Leadtools.Caching; 
using Leadtools.Annotations.Engine; 
using Leadtools.Ocr; 
using Leadtools.Barcode; 
using Leadtools.Document.Converter; 
 
public void DocumentSaveToFileExample() 
{ 
   var options = new LoadDocumentOptions(); 
   using (var document = DocumentFactory.LoadFromFile(Path.Combine(LEAD_VARS.ImagesDir, "Protected.tif"), options)) 
   { 
      // The document is read-only by default. Ensure that we can modify it 
      document.IsReadOnly = false; 
      var page = document.Pages[1]; 
      var container = page.GetAnnotations(true); 
      var obj = new AnnEllipseObject(); 
      obj.Rect = LeadRectD.Create(0, 0, 1 * 720, 1 * 720); 
      obj.Stroke = AnnStroke.Create(AnnSolidColorBrush.Create("red"), LeadLengthD.Create(1)); 
      container.Children.Add(obj); 
      page.SetAnnotations(container); 
 
      var outName = Path.GetFileName(document.Uri.AbsolutePath).Replace(".", "_") + ".tif"; 
 
      var outFileName = Path.Combine(LEAD_VARS.ImagesDir, outName); 
      if (File.Exists(outFileName)) 
         File.Delete(outFileName); 
 
      var saveOptions = new SaveDocumentOptions(); 
      saveOptions.Format = RasterImageFormat.CcittGroup4; 
      saveOptions.BitsPerPixel = 1; 
      saveOptions.WebClient = null; 
      var annFileName = Path.ChangeExtension(outFileName, ".xml"); 
      if (File.Exists(annFileName)) File.Delete(annFileName); 
      saveOptions.AnnotationsUri = new Uri(annFileName); 
      document.SaveToFile(outFileName, saveOptions); 
   } 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

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

Leadtools.Document Assembly

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