LEADTOOLS Image File Support (Leadtools.Codecs assembly) Send comments on this topic. | Back to Introduction - All Topics | Help Version 17.0.3.29
CodecsPngOptions Class
See Also  Members  
Leadtools.Codecs Namespace : CodecsPngOptions Class



Provides extra options for loading and saving PNG images.

Object Model

CodecsPngOptions ClassCodecsPngLoadOptions ClassCodecsPngSaveOptions Class

Syntax

Visual Basic (Declaration) 
Public Class CodecsPngOptions 
Visual Basic (Usage)Copy Code
Dim instance As CodecsPngOptions
C# 
public class CodecsPngOptions 
C++/CLI 
public ref class CodecsPngOptions 

Example

Visual BasicCopy Code
Public Sub CodecsPngOptionsExample()
      Dim codecs As RasterCodecs = New RasterCodecs()

      Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")
      Dim image As RasterImage = codecs.Load(srcFileName)

      ' save with maximum quality
      codecs.Options.Png.Save.QualityFactor = 1
      codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "quality.png"), RasterImageFormat.Png, image.BitsPerPixel)

      ' save with maximum compression
      codecs.Options.Png.Save.QualityFactor = 9
      codecs.Save(image, Path.Combine(LEAD_VARS.ImagesDir, "compression.png"), RasterImageFormat.Png, image.BitsPerPixel)

      ' Clean up
      image.Dispose()
      codecs.Dispose()
   End Sub

Public NotInheritable Class LEAD_VARS
   Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
C#Copy Code
public void CodecsPngOptionsExample()
   {
      RasterCodecs codecs = new RasterCodecs();

      string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp");
      RasterImage image = codecs.Load(srcFileName);

      // save with maximum quality
      codecs.Options.Png.Save.QualityFactor = 1;
      codecs.Save(image,  Path.Combine(LEAD_VARS.ImagesDir, "quality.png"), RasterImageFormat.Png, image.BitsPerPixel);

      // save with maximum compression
      codecs.Options.Png.Save.QualityFactor = 9;
      codecs.Save(image,  Path.Combine(LEAD_VARS.ImagesDir, "compression.png"), RasterImageFormat.Png, image.BitsPerPixel);

      // Clean up
      image.Dispose();
      codecs.Dispose();
   }

static class LEAD_VARS
{
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
SilverlightCSharpCopy Code
public void CodecsPngOptionsExample(Stream inStream, Stream outStreamPng1, Stream outStreamPng2)
{
   RasterCodecs codecs = new RasterCodecs();
   RasterImage image = codecs.Load(inStream);

   // save with maximum quality
   codecs.Options.Png.Save.QualityFactor = 1;
   codecs.Save(image, outStreamPng1, RasterImageFormat.Png, image.BitsPerPixel);

   // save with maximum compression
   codecs.Options.Png.Save.QualityFactor = 9;
   codecs.Save(image, outStreamPng2, RasterImageFormat.Png, image.BitsPerPixel);

   // Clean up
   image.Dispose();
}
SilverlightVBCopy Code
Public Sub CodecsPngOptionsExample(ByVal inStream As Stream, ByVal outStreamPng1 As Stream, ByVal outStreamPng2 As Stream)
   Dim codecs As RasterCodecs = New RasterCodecs()
   Dim image As RasterImage = codecs.Load(inStream)

   ' save with maximum quality
   codecs.Options.Png.Save.QualityFactor = 1
   codecs.Save(image, outStreamPng1, RasterImageFormat.Png, image.BitsPerPixel)

   ' save with maximum compression
   codecs.Options.Png.Save.QualityFactor = 9
   codecs.Save(image, outStreamPng2, RasterImageFormat.Png, image.BitsPerPixel)

   ' Clean up
   image.Dispose()
End Sub

Inheritance Hierarchy

System.Object
   Leadtools.Codecs.CodecsPngOptions

Requirements

Target Platforms: Silverlight, Windows XP, Windows Server 2003 family, Windows Server 2008 family, Windows Vista, Windows 7, MAC OS/X (Intel Only)

See Also