←Select platform

CodecsJpegOptions Class

Summary

Provides extra options for loading and saving JPEG and LEAD CMP images.

Syntax
C#
VB
Objective-C
C++
Java
public class CodecsJpegOptions 
Public Class CodecsJpegOptions  
@interface LTCodecsJpegOptions : NSObject 
public class CodecsJpegOptions 
public ref class CodecsJpegOptions  

Example
C#
VB
using Leadtools; 
using Leadtools.Codecs; 
 
public void CodecsJpegOptionsExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   string srcFileName = Path.Combine(LEAD_VARS.ImagesDir, "cannon.jpg"); 
 
   // Get all Information about the Jpeg file that you want to load. 
   CodecsImageInfo imageInfo = codecs.GetInformation(srcFileName, true); 
 
   //Setting Jpeg Load options. 
   codecs.Options.Jpeg.Load.DisableMmx = false; 
   codecs.Options.Jpeg.Load.DisableP3 = false; 
   codecs.Options.Jpeg.Load.ForceCieLab = true; 
   codecs.Options.Jpeg.Load.ForceRgbFile = false; 
   codecs.Options.Jpeg.Load.UseBadJpegPredictor = false; 
   codecs.Options.Jpeg.Load.Multithreaded = true; 
 
   RasterImage srcImage = codecs.Load(srcFileName); 
 
   //if the image has stamp then set the Jpeg settings related to the stamp. 
   if (imageInfo.Jpeg.HasStamp) 
   { 
      codecs.Options.Jpeg.Save.FixedPaletteStamp = true; 
      codecs.Options.Jpeg.Save.JpegStamp = true; 
      codecs.Options.Jpeg.Save.SaveWithoutTimestamp = false; 
      codecs.Options.Jpeg.Save.SaveWithStamp = true; 
      codecs.Options.Jpeg.Save.StampBitsPerPixel = srcImage.BitsPerPixel; 
      codecs.Options.Jpeg.Save.StampHeight = 100; 
      codecs.Options.Jpeg.Save.StampWidth = 100; 
      codecs.Options.Jpeg.Save.YccStamp = false; 
   } 
 
   if (imageInfo.Jpeg.IsLossless) 
      Console.WriteLine("This is a lossless Jpeg Image"); 
   else 
      Console.WriteLine("This is not a lossless Jpeg Image"); 
 
   if (imageInfo.Jpeg.IsProgressive) 
      codecs.Options.Jpeg.Save.Passes = 0; 
 
   codecs.Options.Jpeg.Save.CmpQualityFactorPredefined = CodecsCmpQualityFactorPredefined.Custom; 
   codecs.Options.Jpeg.Save.DisableMmx = true; 
   codecs.Options.Jpeg.Save.DisableP3 = true; 
   codecs.Options.Jpeg.Save.QualityFactor = 2; 
   codecs.Options.Jpeg.Save.SaveOldJtif = true; 
 
   codecs.Save(srcImage, Path.Combine(LEAD_VARS.ImagesDir, "jpeg1.jpg"), RasterImageFormat.Jpeg, srcImage.BitsPerPixel); 
 
   codecs.Options.Jpeg.Save.FixedPaletteStamp = false; 
   codecs.Options.Jpeg.Save.JpegStamp = true; 
   codecs.Options.Jpeg.Save.SaveWithoutTimestamp = true; 
   codecs.Options.Jpeg.Save.SaveWithStamp = true; 
   codecs.Options.Jpeg.Save.StampBitsPerPixel = srcImage.BitsPerPixel; 
   codecs.Options.Jpeg.Save.StampHeight = 75; 
   codecs.Options.Jpeg.Save.StampWidth = 50; 
   codecs.Options.Jpeg.Save.YccStamp = true; 
   codecs.Options.Jpeg.Save.CmpQualityFactorPredefined = CodecsCmpQualityFactorPredefined.MaximumQuality; 
   codecs.Options.Jpeg.Save.DisableMmx = false; 
   codecs.Options.Jpeg.Save.DisableP3 = false; 
   codecs.Options.Jpeg.Save.SaveOldJtif = false; 
 
   codecs.Save(srcImage, Path.Combine(LEAD_VARS.ImagesDir, "jpeg2.jpg"), RasterImageFormat.Jpeg, srcImage.BitsPerPixel); 
 
   // Clean up 
   srcImage.Dispose(); 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images"; 
} 
Imports Leadtools 
Imports Leadtools.Codecs 
 
Public Sub CodecsJpegOptionsExample() 
   Dim codecs As RasterCodecs = New RasterCodecs() 
 
   Dim srcFileName As String = Path.Combine(LEAD_VARS.ImagesDir, "Slave.jpg") 
 
   ' Get all Information about the Jpeg file that you want to load. 
   Dim imageInfo As CodecsImageInfo = codecs.GetInformation(srcFileName, True) 
 
   'Setting Jpeg Load options. 
   codecs.Options.Jpeg.Load.DisableMmx = False 
   codecs.Options.Jpeg.Load.DisableP3 = False 
   codecs.Options.Jpeg.Load.ForceCieLab = True 
   codecs.Options.Jpeg.Load.ForceRgbFile = False 
   codecs.Options.Jpeg.Load.UseBadJpegPredictor = False 
 
   Dim srcImage As RasterImage = codecs.Load(srcFileName) 
 
   'if the image has stamp then set the Jpeg settings related to the stamp. 
   If imageInfo.Jpeg.HasStamp Then 
      codecs.Options.Jpeg.Save.FixedPaletteStamp = True 
      codecs.Options.Jpeg.Save.JpegStamp = True 
      codecs.Options.Jpeg.Save.SaveWithoutTimestamp = False 
      codecs.Options.Jpeg.Save.SaveWithStamp = True 
      codecs.Options.Jpeg.Save.StampBitsPerPixel = srcImage.BitsPerPixel 
      codecs.Options.Jpeg.Save.StampHeight = 100 
      codecs.Options.Jpeg.Save.StampWidth = 100 
      codecs.Options.Jpeg.Save.YccStamp = False 
   End If 
 
   If imageInfo.Jpeg.IsLossless Then 
      Console.WriteLine("This is a lossless Jpeg Image") 
   Else 
      Console.WriteLine("This is not a lossless Jpeg Image") 
   End If 
 
   If imageInfo.Jpeg.IsProgressive Then 
      codecs.Options.Jpeg.Save.Passes = 0 
   End If 
 
   codecs.Options.Jpeg.Save.CmpQualityFactorPredefined = CodecsCmpQualityFactorPredefined.Custom 
   codecs.Options.Jpeg.Save.DisableMmx = True 
   codecs.Options.Jpeg.Save.DisableP3 = True 
   codecs.Options.Jpeg.Save.QualityFactor = 2 
   codecs.Options.Jpeg.Save.SaveOldJtif = True 
 
   codecs.Save(srcImage, Path.Combine(LEAD_VARS.ImagesDir, "jpeg1.jpg"), RasterImageFormat.Jpeg, srcImage.BitsPerPixel) 
 
   codecs.Options.Jpeg.Save.FixedPaletteStamp = False 
   codecs.Options.Jpeg.Save.JpegStamp = True 
   codecs.Options.Jpeg.Save.SaveWithoutTimestamp = True 
   codecs.Options.Jpeg.Save.SaveWithStamp = True 
   codecs.Options.Jpeg.Save.StampBitsPerPixel = srcImage.BitsPerPixel 
   codecs.Options.Jpeg.Save.StampHeight = 75 
   codecs.Options.Jpeg.Save.StampWidth = 50 
   codecs.Options.Jpeg.Save.YccStamp = True 
   codecs.Options.Jpeg.Save.CmpQualityFactorPredefined = CodecsCmpQualityFactorPredefined.MaximumQuality 
   codecs.Options.Jpeg.Save.DisableMmx = False 
   codecs.Options.Jpeg.Save.DisableP3 = False 
   codecs.Options.Jpeg.Save.SaveOldJtif = False 
 
   codecs.Save(srcImage, Path.Combine(LEAD_VARS.ImagesDir, "jpeg2.jpg"), RasterImageFormat.Jpeg, srcImage.BitsPerPixel) 
 
   ' Clean up 
   srcImage.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 CodecsJpegOptionsExample(Stream inStream, Stream outStreamJpeg1, Stream outStreamJpeg2) 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   // Get all Information about the Jpeg file that you want to load. 
   CodecsImageInfo imageInfo = codecs.GetInformation(inStream, true); 
 
   //Setting Jpeg Load options. 
   codecs.Options.Jpeg.Load.DisableMmx = false; 
   codecs.Options.Jpeg.Load.DisableP3 = false; 
   codecs.Options.Jpeg.Load.ForceCieLab = true; 
   codecs.Options.Jpeg.Load.ForceRgbFile = false; 
   codecs.Options.Jpeg.Load.UseBadJpegPredictor = false; 
 
   RasterImage srcImage = codecs.Load(inStream); 
 
   //if the image has stamp then set the Jpeg settings related to the stamp. 
   if (imageInfo.Jpeg.HasStamp) 
   { 
      codecs.Options.Jpeg.Save.FixedPaletteStamp = true; 
      codecs.Options.Jpeg.Save.JpegStamp = true; 
      codecs.Options.Jpeg.Save.SaveWithoutTimestamp = false; 
      codecs.Options.Jpeg.Save.SaveWithStamp = true; 
      codecs.Options.Jpeg.Save.StampBitsPerPixel = srcImage.BitsPerPixel; 
      codecs.Options.Jpeg.Save.StampHeight = 100; 
      codecs.Options.Jpeg.Save.StampWidth = 100; 
      codecs.Options.Jpeg.Save.YccStamp = false; 
   } 
 
   if (imageInfo.Jpeg.IsLossless) 
      Console.WriteLine("This is a lossless Jpeg Image"); 
   else 
      Console.WriteLine("This is not a lossless Jpeg Image"); 
 
   if (imageInfo.Jpeg.IsProgressive) 
      codecs.Options.Jpeg.Save.Passes = 0; 
 
   codecs.Options.Jpeg.Save.CmpQualityFactorPredefined = CodecsCmpQualityFactorPredefined.Custom; 
   codecs.Options.Jpeg.Save.DisableMmx = true; 
   codecs.Options.Jpeg.Save.DisableP3 = true; 
   codecs.Options.Jpeg.Save.QualityFactor = 2; 
   codecs.Options.Jpeg.Save.SaveOldJtif = true; 
 
   codecs.Save(srcImage, outStreamJpeg1, RasterImageFormat.Jpeg, srcImage.BitsPerPixel); 
 
   codecs.Options.Jpeg.Save.FixedPaletteStamp = false; 
   codecs.Options.Jpeg.Save.JpegStamp = true; 
   codecs.Options.Jpeg.Save.SaveWithoutTimestamp = true; 
   codecs.Options.Jpeg.Save.SaveWithStamp = true; 
   codecs.Options.Jpeg.Save.StampBitsPerPixel = srcImage.BitsPerPixel; 
   codecs.Options.Jpeg.Save.StampHeight = 75; 
   codecs.Options.Jpeg.Save.StampWidth = 50; 
   codecs.Options.Jpeg.Save.YccStamp = true; 
   codecs.Options.Jpeg.Save.CmpQualityFactorPredefined = CodecsCmpQualityFactorPredefined.MaximumQuality; 
   codecs.Options.Jpeg.Save.DisableMmx = false; 
   codecs.Options.Jpeg.Save.DisableP3 = false; 
   codecs.Options.Jpeg.Save.SaveOldJtif = false; 
 
   codecs.Save(srcImage, outStreamJpeg2, RasterImageFormat.Jpeg, srcImage.BitsPerPixel); 
 
   // Clean up 
   srcImage.Dispose(); 
} 
vb[Silverlight VB Example] 
Imports Leadtools 
Imports Leadtools.Codecs 
Imports Leadtools.ImageProcessing 
 
Public Sub CodecsJpegOptionsExample(ByVal inStream As Stream, ByVal outStreamJpeg1 As Stream, ByVal outStreamJpeg2 As Stream) 
   Dim codecs As RasterCodecs = New RasterCodecs() 
 
   ' Get all Information about the Jpeg file that you want to load. 
   Dim imageInfo As CodecsImageInfo = codecs.GetInformation(inStream, True) 
 
   'Setting Jpeg Load options. 
   codecs.Options.Jpeg.Load.DisableMmx = False 
   codecs.Options.Jpeg.Load.DisableP3 = False 
   codecs.Options.Jpeg.Load.ForceCieLab = True 
   codecs.Options.Jpeg.Load.ForceRgbFile = False 
   codecs.Options.Jpeg.Load.UseBadJpegPredictor = False 
 
   Dim srcImage As RasterImage = codecs.Load(inStream) 
 
   'if the image has stamp then set the Jpeg settings related to the stamp. 
   If imageInfo.Jpeg.HasStamp Then 
      codecs.Options.Jpeg.Save.FixedPaletteStamp = True 
      codecs.Options.Jpeg.Save.JpegStamp = True 
      codecs.Options.Jpeg.Save.SaveWithoutTimestamp = False 
      codecs.Options.Jpeg.Save.SaveWithStamp = True 
      codecs.Options.Jpeg.Save.StampBitsPerPixel = srcImage.BitsPerPixel 
      codecs.Options.Jpeg.Save.StampHeight = 100 
      codecs.Options.Jpeg.Save.StampWidth = 100 
      codecs.Options.Jpeg.Save.YccStamp = False 
   End If 
 
   If imageInfo.Jpeg.IsLossless Then 
      Console.WriteLine("This is a lossless Jpeg Image") 
   Else 
      Console.WriteLine("This is not a lossless Jpeg Image") 
   End If 
 
   If imageInfo.Jpeg.IsProgressive Then 
      codecs.Options.Jpeg.Save.Passes = 0 
   End If 
 
   codecs.Options.Jpeg.Save.CmpQualityFactorPredefined = CodecsCmpQualityFactorPredefined.Custom 
   codecs.Options.Jpeg.Save.DisableMmx = True 
   codecs.Options.Jpeg.Save.DisableP3 = True 
   codecs.Options.Jpeg.Save.QualityFactor = 2 
   codecs.Options.Jpeg.Save.SaveOldJtif = True 
 
   codecs.Save(srcImage, outStreamJpeg1, RasterImageFormat.Jpeg, srcImage.BitsPerPixel) 
 
   codecs.Options.Jpeg.Save.FixedPaletteStamp = False 
   codecs.Options.Jpeg.Save.JpegStamp = True 
   codecs.Options.Jpeg.Save.SaveWithoutTimestamp = True 
   codecs.Options.Jpeg.Save.SaveWithStamp = True 
   codecs.Options.Jpeg.Save.StampBitsPerPixel = srcImage.BitsPerPixel 
   codecs.Options.Jpeg.Save.StampHeight = 75 
   codecs.Options.Jpeg.Save.StampWidth = 50 
   codecs.Options.Jpeg.Save.YccStamp = True 
   codecs.Options.Jpeg.Save.CmpQualityFactorPredefined = CodecsCmpQualityFactorPredefined.MaximumQuality 
   codecs.Options.Jpeg.Save.DisableMmx = False 
   codecs.Options.Jpeg.Save.DisableP3 = False 
   codecs.Options.Jpeg.Save.SaveOldJtif = False 
 
   codecs.Save(srcImage, outStreamJpeg2, RasterImageFormat.Jpeg, srcImage.BitsPerPixel) 
 
   ' Clean up 
   srcImage.Dispose() 
End Sub 

Requirements

Target Platforms

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

Leadtools.Codecs Assembly