Leadtools.Codecs Namespace : CodecsImageInfo Class |
public class CodecsImageInfo : System.IDisposable
'Declaration Public Class CodecsImageInfo Implements System.IDisposable
'Usage Dim instance As CodecsImageInfo
public sealed class CodecsImageInfo : IClosable //In WinRT the IDisposable interface is replaced by IClosable
function Leadtools.Codecs.CodecsImageInfo()
public ref class CodecsImageInfo : public System.IDisposable
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())) ' 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
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())); // 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"; }
CodecsImageInfoExamples.prototype.CodecsImageInfoExample = function () { Tools.SetLicense ( ) ; with (Leadtools) { with (Leadtools.Codecs) { var codecs = new RasterCodecs(); // try a GIF var srcFileName = "Assets\\eye.gif"; return Tools.AppInstallFolder().getFileAsync(srcFileName).then(function (loadFile) { return codecs.getInformationAsync(LeadStreamFactory.create(loadFile), true, 1) }) .then(function (info) { console.info("Information for: ", srcFileName); console.info("BitsPerPixel: ", info.bitsPerPixel); console.info("BytesPerLine: ", info.bytesPerLine); console.info("ColorSpace: ", info.colorSpace.toString()); console.info("Compresion: ", info.compression); console.info("Fax: ", info.fax); console.info("Format: ", info.format); if (info.gif.hasAnimationBackground) console.info("Gif.AnimationBackground: ", info.gif.animationBackground.toString()); console.info("Gif.AnimationHeight: ", info.gif.animationHeight); console.info("Gif.AnimationWidth: ", info.gif.animationWidth); if (info.gif.hasAnimationLoop) console.info("Gif.AnimationLoop: ", info.gif.animationLoop.toString()); if (info.gif.hasAnimationPalette) { var pal = info.gif.getAnimationPalette(); console.info("GifAnimationPalette:\n"); for (var x = 0; x < pal.length; x++) { console.info(RasterColorHelper.getStringDescription(pal[x]), ", "); } console.info("\n"); } console.info("Gif.IsInterlaced: ", info.gif.isInterlaced.toString()); console.info("PageNumber: ", info.pageNumber); console.info("TotalPages: ", info.totalPages); // try a FAX TIFF srcFileName = "Assets\\OCR1.TIF"; return Tools.AppInstallFolder().getFileAsync(srcFileName) }) .then(function (loadFile) { return codecs.getInformationAsync(LeadStreamFactory.create(loadFile), true, 1) }) .then(function (info) { console.info("Information for: ", srcFileName); console.info("Width: ", info.width); console.info("Height: ", info.height); console.info("IsLink: ", info.isLink.toString()); console.info("IsRotated: ", info.isRotated.toString()); console.info("Fax.IsCompressed: ", info.fax.isCompressed.toString()); if (info.hasResolution) { console.info("X Resolution: ", info.xresolution); console.info("Y Resolution: ", info.yresolution); } console.info("Tiff.HasNoPalette: ", info.tiff.hasNoPalette.toString()); console.info("Tiff.ImageFileDirectoryOffset: ", info.tiff.imageFileDirectoryOffset.toString()); console.info("Tiff.IsImageFileDirectoryOffsetValid: ", info.tiff.isImageFileDirectoryOffsetValid.toString()); // try a PNG srcFileName = "Assets\\LittleGFlyingAlpha.png"; return Tools.AppInstallFolder().getFileAsync(srcFileName) }) .then(function (loadFile) { return codecs.getInformationAsync(LeadStreamFactory.create(loadFile), true, 1) }) .then(function (info) { console.info("Information for: ", srcFileName); console.info("HasAlpha: ", info.hasAlpha.toString()); // try a DICOM srcFileName = "Assets\\Image1.dcm"; return Tools.AppInstallFolder().getFileAsync(srcFileName) }) .then(function (loadFile) { return codecs.getInformationAsync(LeadStreamFactory.create(loadFile), true, 1) }) .then(function (info) { console.info("Information for: ", srcFileName); console.info("IsSigned: ", info.isSigned.toString()); // try a JPEG srcFileName = "Assets\\cannon.jpg"; return Tools.AppInstallFolder().getFileAsync(srcFileName) }) .then(function (loadFile) { return codecs.getInformationAsync(LeadStreamFactory.create(loadFile), true, 1) }) .then(function (info) { console.info("Information for: ", srcFileName); console.info("Name: ", info.name); console.info("Jpeg.HasStamp: ", info.jpeg.hasStamp.toString()); console.info("Jpeg.IsLossless: ", info.jpeg.isLossless.toString()); console.info("Jpeg.IsProgressive: ", info.jpeg.isProgressive.toString()); console.info("Order: ", info.order.toString()); console.info("SizeDisk: ", info.sizeDisk); console.info("SizeMemory: ", info.sizeMemory); // try a PSD srcFileName = "Assets\\Image1.psd"; return Tools.AppInstallFolder().getFileAsync(srcFileName) }) .then(function (loadFile) { return codecs.getInformationAsync(LeadStreamFactory.create(loadFile), true, 1) }) .then(function (info) { console.info("Information for: ", srcFileName); console.info("Psd.Layers: ", info.psd.layers); // try a BMP srcFileName = "Assets\\Ulay1.bmp"; return Tools.AppInstallFolder().getFileAsync(srcFileName) }) .then(function (loadFile) { return codecs.getInformationAsync(LeadStreamFactory.create(loadFile), true, 1) }) .then(function (info) { console.info("Information for: ", srcFileName); console.info("ViewPerspective: ", info.viewPerspective); // Clean up codecs.close(); }); } } }
[TestMethod] public async Task CodecsImageInfoExample() { RasterCodecs codecs = new RasterCodecs(); // try a GIF string srcFileName = @"Assets\eye.gif"; StorageFile loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName); CodecsImageInfo info = await codecs.GetInformationAsync(LeadStreamFactory.Create(loadFile), true, 1); 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("Compresion: {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++) { Debug.WriteLine("{0},", RasterColorHelper.GetStringDescription(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 srcFileName = @"Assets\OCR1.TIF"; loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName); info = await codecs.GetInformationAsync(LeadStreamFactory.Create(loadFile), true, 1); 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)); } 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())); // try a PNG srcFileName = @"Assets\LittleGFlyingAlpha.png"; loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName); info = await codecs.GetInformationAsync(LeadStreamFactory.Create(loadFile), true, 1); Debug.WriteLine("Information for: {0}", srcFileName); Debug.WriteLine(string.Format("HasAlpha: {0}", info.HasAlpha.ToString())); // try a DICOM srcFileName = @"Assets\Image1.dcm"; loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName); info = await codecs.GetInformationAsync(LeadStreamFactory.Create(loadFile), true, 1); Debug.WriteLine("Information for: {0}", srcFileName); Debug.WriteLine(string.Format("IsSigned: {0}", info.IsSigned.ToString())); // try a JPEG srcFileName = @"Assets\cannon.jpg"; loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName); info = await codecs.GetInformationAsync(LeadStreamFactory.Create(loadFile), true, 1); 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())); 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 = @"Assets\Image1.psd"; loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName); info = await codecs.GetInformationAsync(LeadStreamFactory.Create(loadFile), true, 1); Debug.WriteLine("Information for: {0}", srcFileName); Debug.WriteLine(string.Format("Psd.Layers: {0}", info.Psd.Layers)); // try a BMP srcFileName = @"Assets\Ulay1.bmp"; loadFile = await Tools.AppInstallFolder.GetFileAsync(srcFileName); info = await codecs.GetInformationAsync(LeadStreamFactory.Create(loadFile), true, 1); Debug.WriteLine("Information for: {0}", srcFileName); Debug.WriteLine(string.Format("ViewPerspective: {0}", info.ViewPerspective)); // Clean up codecs.Dispose(); }
Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2