Leadtools.Codecs Send comments on this topic. | Back to Introduction - All Topics | Help Version 15.12.17
CodecsJpegOptions Class
See Also  Members   Example 
Leadtools.Codecs Namespace : CodecsJpegOptions Class




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

Object Model



Syntax

Visual Basic (Declaration) 
Public Class CodecsJpegOptions 
Visual Basic (Usage)Copy Code
Dim instance As CodecsJpegOptions
C# 
public class CodecsJpegOptions 
Managed Extensions for C++ 
public __gc class CodecsJpegOptions 
C++/CLI 
public ref class CodecsJpegOptions 

Example

Visual BasicCopy Code
CodecsJpegOptions
      Public Sub CodecsJpegOptionsExample()
         RasterCodecs.Startup()
         Dim codecs As RasterCodecs = New RasterCodecs()

         Dim srcFileName As String = "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\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, "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\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, "C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\jpeg2.jpg", RasterImageFormat.Jpeg, srcImage.BitsPerPixel)

         ' Clean up
         srcImage.Dispose()
         codecs.Dispose()
         RasterCodecs.Shutdown()
      End Sub
C#Copy Code
CodecsJpegOptions 
      public void CodecsJpegOptionsExample() 
      { 
         RasterCodecs.Startup(); 
         RasterCodecs codecs = new RasterCodecs(); 
 
         string srcFileName = @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\Slave.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; 
 
         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, @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\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, @"C:\Program Files\LEAD Technologies\LEADTOOLS 15\Images\jpeg2.jpg", RasterImageFormat.Jpeg, srcImage.BitsPerPixel); 
 
         // Clean up 
         srcImage.Dispose(); 
         codecs.Dispose(); 
         RasterCodecs.Shutdown(); 
      }

Inheritance Hierarchy

System.Object
   Leadtools.Codecs.CodecsJpegOptions

Requirements

Target Platforms: Microsoft .NET Framework 2.0, Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

See Also