←Select platform

CodecsImageInfo Class

Summary

Provides functionality for getting information about image files supported by LEADTOOLS.

Syntax

C#
VB
Java
Objective-C
WinRT C#
C++
public class CodecsImageInfo : IDisposable 
Public Class CodecsImageInfo  
   Implements System.IDisposable  
public sealed class CodecsImageInfo : IClosable    
@interface LTCodecsImageInfo : NSObject<NSCopying> 
public class CodecsImageInfo 
function Leadtools.Codecs.CodecsImageInfo() 
public ref class CodecsImageInfo : public System.IDisposable   

Remarks

Note: For information about loading PDF files, refer to Implementing PDF Features.

Example

C#
VB
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Examples; 
 
public void CodecsImageInfoExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // try a GIF 
   string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "eye.gif"); 
   CodecsImageInfo info = codecs.GetInformation(srcFileName, true); 
   Console.WriteLine("Information for: {0}", srcFileName); 
   Console.WriteLine(string.Format("BitsPerPixel: {0}", info.BitsPerPixel)); 
   Console.WriteLine(string.Format("BytesPerLine: {0}", info.BytesPerLine)); 
   Console.WriteLine(string.Format("ColorSpace: {0}", info.ColorSpace.ToString())); 
   Console.WriteLine(string.Format("Compresion: {0}", info.Compression)); 
   Console.WriteLine(string.Format("Fax: {0}", info.Fax)); 
   Console.WriteLine(string.Format("Format: {0}", info.Format)); 
   if (info.Gif.HasAnimationBackground) 
      Console.WriteLine(string.Format("Gif.AnimationBackground: {0}", info.Gif.AnimationBackground.ToString())); 
   Console.WriteLine(string.Format("Gif.AnimationHeight: {0}", info.Gif.AnimationHeight)); 
   Console.WriteLine(string.Format("Gif.AnimationWidth: {0}", info.Gif.AnimationWidth)); 
   if (info.Gif.HasAnimationLoop) 
      Console.WriteLine(string.Format("Gif.AnimationLoop: {0}", info.Gif.AnimationLoop.ToString())); 
   if (info.Gif.HasAnimationPalette) 
   { 
      RasterColor[] pal = info.Gif.GetAnimationPalette(); 
      Console.WriteLine("GifAnimationPalette:\n"); 
      for (int x = 0; x < pal.Length; x++) 
      { 
         Console.Write("{0},", pal[x]); 
      } 
      Console.WriteLine("\n"); 
   } 
   Console.WriteLine(string.Format("Gif.IsInterlaced: {0}", info.Gif.IsInterlaced.ToString())); 
   Console.WriteLine(string.Format("PageNumber: {0}", info.PageNumber)); 
   Console.WriteLine(string.Format("TotalPages: {0}", info.TotalPages)); 
 
   // try a FAX TIFF 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "OCR1.TIF"); 
   info = codecs.GetInformation(srcFileName, true); 
   Console.WriteLine("Information for: {0}", srcFileName); 
   Console.WriteLine(string.Format("Width: {0}", info.Width)); 
   Console.WriteLine(string.Format("Height: {0}", info.Height)); 
   Console.WriteLine(string.Format("IsLink: {0}", info.IsLink.ToString())); 
   Console.WriteLine(string.Format("IsRotated: {0}", info.IsRotated.ToString())); 
   Console.WriteLine(string.Format("Fax.IsCompressed: {0}", info.Fax.IsCompressed.ToString())); 
   if (info.HasResolution) 
   { 
      Console.WriteLine(string.Format("X Resolution: {0}", info.XResolution)); 
      Console.WriteLine(string.Format("Y Resolution: {0}", info.YResolution)); 
   } 
   Console.WriteLine(string.Format("Tiff.HasNoPalette: {0}", info.Tiff.HasNoPalette.ToString())); 
   Console.WriteLine(string.Format("Tiff.ImageFileDirectoryOffset: {0}", info.Tiff.ImageFileDirectoryOffset.ToString())); 
   Console.WriteLine(string.Format("Tiff.IsImageFileDirectoryOffsetValid: {0}", info.Tiff.IsImageFileDirectoryOffsetValid.ToString())); 
   Console.WriteLine(string.Format("Tiff.IsBigTiff: {0}", info.Tiff.IsBigTiff.ToString())); 
 
   // try a PNG 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "compression.png"); 
   info = codecs.GetInformation(srcFileName, true); 
   Console.WriteLine("Information for: {0}", srcFileName); 
   Console.WriteLine(string.Format("HasAlpha: {0}", info.HasAlpha.ToString())); 
 
   // try a DICOM 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.dcm"); 
   info = codecs.GetInformation(srcFileName, true); 
   Console.WriteLine("Information for: {0}", srcFileName); 
   Console.WriteLine(string.Format("IsSigned: {0}", info.IsSigned.ToString())); 
 
   // try a JPEG 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg"); 
   info = codecs.GetInformation(srcFileName, true); 
   Console.WriteLine("Information for: {0}", srcFileName); 
   Console.WriteLine(string.Format("Name: {0}", info.Name)); 
   Console.WriteLine(string.Format("Jpeg.HasStamp: {0}", info.Jpeg.HasStamp.ToString())); 
   Console.WriteLine(string.Format("Jpeg.IsLossless: {0}", info.Jpeg.IsLossless.ToString())); 
   Console.WriteLine(string.Format("Jpeg.IsProgressive: {0}", info.Jpeg.IsProgressive.ToString())); 
   Console.WriteLine(string.Format("Order: {0}", info.Order.ToString())); 
   Console.WriteLine(string.Format("SizeDisk: {0}", info.SizeDisk)); 
   Console.WriteLine(string.Format("SizeMemory: {0}", info.SizeMemory)); 
 
   // try a PSD 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.psd"); 
   info = codecs.GetInformation(srcFileName, true); 
   Console.WriteLine("Information for: {0}", srcFileName); 
   Console.WriteLine(string.Format("Psd.Layers: {0}", info.Psd.Layers)); 
 
   // try a BMP 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ulay1.bmp"); 
   info = codecs.GetInformation(srcFileName, true); 
   Console.WriteLine("Information for: {0}", srcFileName); 
   Console.WriteLine(string.Format("ViewPerspective: {0}", info.ViewPerspective)); 
 
   // Clean up 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
 
Public Sub CodecsImageInfoExample() 
   Dim codecs As RasterCodecs = New RasterCodecs() 
 
   ' try a GIF 
   Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "eye.gif") 
   Dim info As CodecsImageInfo = codecs.GetInformation(srcFileName, True) 
   Console.WriteLine("Information for: {0}", srcFileName) 
   Console.WriteLine(String.Format("BitsPerPixel: {0}", info.BitsPerPixel)) 
   Console.WriteLine(String.Format("BytesPerLine: {0}", info.BytesPerLine)) 
   Console.WriteLine(String.Format("ColorSpace: {0}", info.ColorSpace.ToString())) 
   Console.WriteLine(String.Format("Compresion: {0}", info.Compression)) 
   Console.WriteLine(String.Format("Fax: {0}", info.Fax)) 
   Console.WriteLine(String.Format("Format: {0}", info.Format)) 
   If info.Gif.HasAnimationBackground Then 
      Console.WriteLine(String.Format("Gif.AnimationBackground: {0}", info.Gif.AnimationBackground.ToString())) 
   End If 
   Console.WriteLine(String.Format("Gif.AnimationHeight: {0}", info.Gif.AnimationHeight)) 
   Console.WriteLine(String.Format("Gif.AnimationWidth: {0}", info.Gif.AnimationWidth)) 
   If info.Gif.HasAnimationLoop Then 
      Console.WriteLine(String.Format("Gif.AnimationLoop: {0}", info.Gif.AnimationLoop.ToString())) 
   End If 
   If info.Gif.HasAnimationPalette Then 
      Dim pal As RasterColor() = info.Gif.GetAnimationPalette() 
      Console.WriteLine("GifAnimationPalette:" & Constants.vbLf) 
      Dim x As Integer = 0 
      Do While x < pal.Length 
         Console.Write("{0},", pal(x)) 
         x += 1 
      Loop 
      Console.WriteLine(Constants.vbLf) 
   End If 
   Console.WriteLine(String.Format("Gif.IsInterlaced: {0}", info.Gif.IsInterlaced.ToString())) 
   Console.WriteLine(String.Format("PageNumber: {0}", info.PageNumber)) 
   Console.WriteLine(String.Format("TotalPages: {0}", info.TotalPages)) 
 
   ' try a FAX TIFF 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "OCR1.TIF") 
   info = codecs.GetInformation(srcFileName, True) 
   Console.WriteLine("Information for: {0}", srcFileName) 
   Console.WriteLine(String.Format("Width: {0}", info.Width)) 
   Console.WriteLine(String.Format("Height: {0}", info.Height)) 
   Console.WriteLine(String.Format("IsLink: {0}", info.IsLink.ToString())) 
   Console.WriteLine(String.Format("IsRotated: {0}", info.IsRotated.ToString())) 
   Console.WriteLine(String.Format("Fax.IsCompressed: {0}", info.Fax.IsCompressed.ToString())) 
   If info.HasResolution Then 
      Console.WriteLine(String.Format("X Resolution: {0}", info.XResolution)) 
      Console.WriteLine(String.Format("Y Resolution: {0}", info.YResolution)) 
   End If 
   Console.WriteLine(String.Format("Tiff.HasNoPalette: {0}", info.Tiff.HasNoPalette.ToString())) 
   Console.WriteLine(String.Format("Tiff.ImageFileDirectoryOffset: {0}", info.Tiff.ImageFileDirectoryOffset.ToString())) 
   Console.WriteLine(String.Format("Tiff.IsImageFileDirectoryOffsetValid: {0}", info.Tiff.IsImageFileDirectoryOffsetValid.ToString())) 
   Console.WriteLine(String.Format("Tiff.IsBigTiff: {0}", info.Tiff.IsBigTiff.ToString())) 
 
   ' try a PNG 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "compression.png") 
   info = codecs.GetInformation(srcFileName, True) 
   Console.WriteLine("Information for: {0}", srcFileName) 
   Console.WriteLine(String.Format("HasAlpha: {0}", info.HasAlpha.ToString())) 
 
   ' try a DICOM 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.dcm") 
   info = codecs.GetInformation(srcFileName, True) 
   Console.WriteLine("Information for: {0}", srcFileName) 
   Console.WriteLine(String.Format("IsSigned: {0}", info.IsSigned.ToString())) 
 
   ' try a JPEG 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg") 
   info = codecs.GetInformation(srcFileName, True) 
   Console.WriteLine("Information for: {0}", srcFileName) 
   Console.WriteLine(String.Format("Name: {0}", info.Name)) 
   Console.WriteLine(String.Format("Jpeg.HasStamp: {0}", info.Jpeg.HasStamp.ToString())) 
   Console.WriteLine(String.Format("Jpeg.IsLossless: {0}", info.Jpeg.IsLossless.ToString())) 
   Console.WriteLine(String.Format("Jpeg.IsProgressive: {0}", info.Jpeg.IsProgressive.ToString())) 
   Console.WriteLine(String.Format("Order: {0}", info.Order.ToString())) 
   Console.WriteLine(String.Format("SizeDisk: {0}", info.SizeDisk)) 
   Console.WriteLine(String.Format("SizeMemory: {0}", info.SizeMemory)) 
 
   ' try a PSD 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.psd") 
   info = codecs.GetInformation(srcFileName, True) 
   Console.WriteLine("Information for: {0}", srcFileName) 
   Console.WriteLine(String.Format("Psd.Layers: {0}", info.Psd.Layers)) 
 
   ' try a BMP 
   srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Ulay1.bmp") 
   info = codecs.GetInformation(srcFileName, True) 
   Console.WriteLine("Information for: {0}", srcFileName) 
   Console.WriteLine(String.Format("ViewPerspective: {0}", info.ViewPerspective)) 
 
   ' Clean up 
   codecs.Dispose() 
End Sub 
 
Public NotInheritable Class LEAD_VARS 
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images" 
End Class 

Requirements

Target Platforms

Help Version 19.0.2017.10.18
Products | Support | Contact Us | Copyright Notices
© 1991-2017 LEAD Technologies, Inc. All Rights Reserved.

Leadtools.Codecs Assembly