←Select platform

BytesPerLine Property

Summary
Gets the number of bytes per scanline for the image data.
Syntax
C#
Objective-C
C++/CLI
Java
Python
public int BytesPerLine { get; } 
@property (nonatomic, assign, readonly) NSInteger bytesPerLine; 
public int getBytesPerLine() 
public: 
property int BytesPerLine { 
   int get(); 
} 
BytesPerLine # get  (CodecsImageInfo) 

Property Value

the number of bytes per scanline for the image data.. The default value is 0.

Remarks

The BytesPerLine is rounded upward to the nearest multiple of four.

Example
C#
using Leadtools; 
using Leadtools.Codecs; 
 
 
public void CodecsImageInfoExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // Parse the colorspace types 
   CodecsColorSpaceType[] colorSpaceTypes = (CodecsColorSpaceType[])Enum.GetValues(typeof(CodecsColorSpaceType)); 
   foreach (var colorSpaceType in colorSpaceTypes) 
   { 
      Debug.WriteLine($"Colorspace of image data: {colorSpaceType}"); 
   } 
 
   // try a GIF - CodecsGifImageInfo reference 
   string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Eye_SavePage.gif"); 
   CodecsImageInfo info = codecs.GetInformation(srcFileName, true); 
   info.GetPalette(); 
   Debug.WriteLine("Information for: {0}", srcFileName); 
   Debug.WriteLine(string.Format("BitsPerPixel: {0}", info.BitsPerPixel)); 
   Debug.WriteLine(string.Format("BytesPerLine: {0}", info.BytesPerLine)); 
   Debug.WriteLine(string.Format("ColorSpace: {0}", info.ColorSpace.ToString())); 
   Debug.WriteLine(string.Format("Compression: {0}", info.Compression)); 
   Debug.WriteLine(string.Format("Fax: {0}", info.Fax)); 
   Debug.WriteLine(string.Format("Format: {0}", info.Format)); 
   if (info.Gif.HasAnimationBackground) 
      Debug.WriteLine(string.Format("Gif.AnimationBackground: {0}", info.Gif.AnimationBackground.ToString())); 
   Debug.WriteLine(string.Format("Gif.AnimationHeight: {0}", info.Gif.AnimationHeight)); 
   Debug.WriteLine(string.Format("Gif.AnimationWidth: {0}", info.Gif.AnimationWidth)); 
   if (info.Gif.HasAnimationLoop) 
      Debug.WriteLine(string.Format("Gif.AnimationLoop: {0}", info.Gif.AnimationLoop.ToString())); 
   if (info.Gif.HasAnimationPalette) 
   { 
      RasterColor[] pal = info.Gif.GetAnimationPalette(); 
      Debug.WriteLine("GifAnimationPalette:\n"); 
      for (int x = 0; x < pal.Length; x++) 
      { 
         Console.Write("{0},", pal[x]); 
      } 
      Debug.WriteLine("\n"); 
   } 
   Debug.WriteLine(string.Format("Gif.IsInterlaced: {0}", info.Gif.IsInterlaced.ToString())); 
   Debug.WriteLine(string.Format("PageNumber: {0}", info.PageNumber)); 
   Debug.WriteLine(string.Format("TotalPages: {0}", info.TotalPages)); 
 
   // try a FAX TIFF - CodecsFaxImageInfo reference 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, @"Forms\Forms to be Recognized\Invoice", "invoice.tif"); 
   info = codecs.GetInformation(srcFileName, true); 
   info.GetPalette(); 
   Debug.WriteLine("Information for: {0}", srcFileName); 
   Debug.WriteLine(string.Format("Width: {0}", info.Width)); 
   Debug.WriteLine(string.Format("Height: {0}", info.Height)); 
   Debug.WriteLine(string.Format("IsLink: {0}", info.IsLink.ToString())); 
   Debug.WriteLine(string.Format("IsRotated: {0}", info.IsRotated.ToString())); 
   Debug.WriteLine(string.Format("Fax.IsCompressed: {0}", info.Fax.IsCompressed.ToString())); 
   if (info.HasResolution) 
   { 
      Debug.WriteLine(string.Format("X Resolution: {0}", info.XResolution)); 
      Debug.WriteLine(string.Format("Y Resolution: {0}", info.YResolution)); 
   } 
   // CodecsTiffImageInfo 
   Debug.WriteLine(string.Format("Tiff.HasNoPalette: {0}", info.Tiff.HasNoPalette.ToString())); 
   Debug.WriteLine(string.Format("Tiff.ImageFileDirectoryOffset: {0}", info.Tiff.ImageFileDirectoryOffset.ToString())); 
   Debug.WriteLine(string.Format("Tiff.IsImageFileDirectoryOffsetValid: {0}", info.Tiff.IsImageFileDirectoryOffsetValid.ToString())); 
   Debug.WriteLine(string.Format("Tiff.IsBigTiff: {0}", info.Tiff.IsBigTiff.ToString())); 
 
   // try a PNG 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "quality.png"); 
   info = codecs.GetInformation(srcFileName, true); 
   info.GetPalette(); 
   Debug.WriteLine("Information for: {0}", srcFileName); 
   Debug.WriteLine(string.Format("HasAlpha: {0}", info.HasAlpha.ToString())); 
   Debug.WriteLine(string.Format("HasStamp: {0}", info.HasStamp.ToString())); 
 
   // try a DICOM 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, @"DICOM", "Image1.dcm"); 
   info = codecs.GetInformation(srcFileName, true); 
   info.GetPalette(); 
   Debug.WriteLine("Information for: {0}", srcFileName); 
   Debug.WriteLine(string.Format("IsSigned: {0}", info.IsSigned.ToString())); 
 
   // try a JPEG 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg"); 
   info = codecs.GetInformation(srcFileName, true); 
   info.GetPalette(); 
   Debug.WriteLine("Information for: {0}", srcFileName); 
   Debug.WriteLine(string.Format("Name: {0}", info.Name)); 
   Debug.WriteLine(string.Format("Jpeg.HasStamp: {0}", info.Jpeg.HasStamp.ToString())); // CodecsJpegImageInfo reference 
   Debug.WriteLine(string.Format("Jpeg.IsLossless: {0}", info.Jpeg.IsLossless.ToString())); 
   Debug.WriteLine(string.Format("Jpeg.IsProgressive: {0}", info.Jpeg.IsProgressive.ToString())); 
   Debug.WriteLine(string.Format("Order: {0}", info.Order.ToString())); 
   Debug.WriteLine(string.Format("SizeDisk: {0}", info.SizeDisk)); 
   Debug.WriteLine(string.Format("SizeMemory: {0}", info.SizeMemory)); 
 
   // try a PSD 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.psd"); 
   if (File.Exists(srcFileName)) 
   { 
      info = codecs.GetInformation(srcFileName, true); 
      info.GetPalette(); 
      Debug.WriteLine("Information for: {0}", srcFileName); 
      Debug.WriteLine(string.Format("Psd.Layers: {0}, channels: {1}", info.Psd.Layers, info.Psd.Channels)); // CodecsPsdImageInfo reference 
   } 
 
   // try a BMP 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ulay1.bmp"); 
   info = codecs.GetInformation(srcFileName, true); 
   info.GetPalette(); 
   Debug.WriteLine("Information for: {0}", srcFileName); 
   Debug.WriteLine(string.Format("ViewPerspective: {0}", info.ViewPerspective)); 
 
   // try an HEIC - CodecsHeicImageInfo reference 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "clean.heic"); 
   info = codecs.GetInformation(srcFileName, true); 
   info.GetPalette(); 
   Debug.WriteLine("Information for: {0}", srcFileName); 
   Debug.WriteLine(string.Format("HasStamp: {0}", info.Heic.HasStamp)); 
 
   // try a PST 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "DataFile.pst"); 
   info = codecs.GetInformation(srcFileName, true); 
   info.GetPalette(); 
   Debug.WriteLine("Information for: {0}", srcFileName); 
   Debug.WriteLine(string.Format("PST info: {0}, message count: {1}", info.Pst, info.Pst.MessageCount)); // CodecsPstImageInfo reference 
 
   // Finalize cannot be called directly, it is invoked automatically. 
   // To clean up before exiting, use Dispose 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS22\Resources\Images"; 
} 
Requirements

Target Platforms

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

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