←Select platform

CodecsPngOptions Class

Summary

Provides extra options for loading and saving PNG images.

Syntax
C#
VB
Objective-C
C++
Java
public class CodecsPngOptions 
Public Class CodecsPngOptions  
@interface LTCodecsPngOptions : NSObject 
public class CodecsPngOptions 
public ref class CodecsPngOptions  
Example
C#
VB
using Leadtools; 
using Leadtools.Codecs; 
 
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"; 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
 
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#[Silverlight C# Example] 
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.Examples; 
using Leadtools.ImageProcessing; 
 
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(); 
} 
vb[Silverlight VB Example] 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.ImageProcessing 
 
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 
Requirements

Target Platforms

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

Leadtools.Codecs Assembly