←Select platform

IgnoreCodecs Method

Summary
Specifies which file codecs LEADTOOLS should NEVER load, even if present.
Syntax
C#
C++/CLI
Java
Python
public void IgnoreCodecs( 
   string codecs 
) 
public void ignoreCodecs(String codecs) 
public: 
void IgnoreCodecs(  
   String^ codecs 
)  
def IgnoreCodecs(self,codecs): 

Parameters

codecs
A String containing which codecs should be ignored and therefore not loaded. Has the same format as in PreloadCodecs.

Remarks

Use this method if you never want to load a particular file codec(s). This is useful for instance if you never load AVI files and you want to ignore the AVI codec since this codec on its own loads all the DLLs required for Video for Windows (there are about 10 of them).

The files specified in PreloadCodecs take priority over the files specified in IgnoreCodecs. This means that if the codec is present in  codecs for both methods, then the codec will be loaded and will not be ignored.

Before calling this method, you can get the default ignore codecs list using IgnoreCodecsList.

Example
C#
Java
using Leadtools; 
using Leadtools.Codecs; 
using Leadtools.ImageProcessing; 
using Leadtools.ImageProcessing.Color; 
using Leadtools.Svg; 
 
 
public void PreloadCodecsExample() 
{ 
   RasterCodecs codecs = new RasterCodecs(); 
 
   string srcFileName1 = Path.Combine(LEAD_VARS.ImagesDir, "Image1.j2k"); 
   string srcFileName2 = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp"); 
 
   // display the original values before changing them 
   Debug.WriteLine("PreloadCodecList - {0}", codecs.PreloadCodecsList); 
   Debug.WriteLine("FixedPreloadCodecs - {0}", codecs.FixedPreloadCodecs); 
   Debug.WriteLine("CachedPreloadCodecs - {0}", codecs.CachedPreloadCodecs); 
   Debug.WriteLine("IgnoreCodecList - {0}", codecs.IgnoreCodecsList); 
 
   // preload only the j2k filter and ignore the cmp filter 
   codecs.PreloadCodecs(1, 1, "j2k"); 
   codecs.IgnoreCodecs("cmp"); 
 
   // try to get info on a j2k image 
   CodecsImageInfo info = codecs.GetInformation(srcFileName1, false); 
   Debug.WriteLine("j2k - Width: {0}, Height {1}", info.Width, info.Height); 
 
   // try to get info on a cmp image 
   try 
   { 
      info = codecs.GetInformation(srcFileName2, false); 
   } 
   catch 
   { 
      Debug.WriteLine("GetInformation for cmp failed - sample success!"); 
   } 
 
   // Clean up 
   codecs.Dispose(); 
} 
 
static class LEAD_VARS 
{ 
   public const string ImagesDir = @"C:\LEADTOOLS23\Resources\Images"; 
} 
 
import java.io.*; 
import java.net.*; 
import java.nio.file.Paths; 
import java.util.*; 
import java.time.Instant; 
import java.time.Duration; 
 
import org.junit.*; 
import org.junit.runner.JUnitCore; 
import org.junit.runner.Result; 
import org.junit.runner.notification.Failure; 
import static org.junit.Assert.*; 
 
import leadtools.*; 
import leadtools.codecs.*; 
import leadtools.codecs.RasterCodecs.FeedCallbackThunk; 
import leadtools.drawing.internal.*; 
import leadtools.imageprocessing.*; 
import leadtools.imageprocessing.color.ChangeIntensityCommand; 
import leadtools.svg.*; 
 
 
public void preloadCodecsExample() { 
   final String LEAD_VARS_IMAGES_DIR = "C:\\LEADTOOLS23\\Resources\\Images"; 
   RasterCodecs codecs = new RasterCodecs(); 
 
   String srcFileName1 = combine(LEAD_VARS_IMAGES_DIR, "Image1.j2k"); 
   String srcFileName2 = combine(LEAD_VARS_IMAGES_DIR, "Image1.cmp"); 
   String dstFileName1 = combine(LEAD_VARS_IMAGES_DIR, "Test1.j2k"); 
 
   // display the original values before changing them 
   System.out.println("PreloadCodecList - " + codecs.getPreloadCodecsList()); 
   System.out.println("FixedPreloadCodecs - " + codecs.getFixedPreloadCodecs()); 
   System.out.println("CachedPreloadCodecs - " + codecs.getCachedPreloadCodecs()); 
   System.out.println("IgnoreCodecList - " + codecs.getIgnoreCodecsList()); 
 
   // preload only the j2k filter and ignore the cmp filter 
   codecs.preloadCodecs(1, 1, "j2k"); 
   codecs.ignoreCodecs("cmp"); 
 
   // try to get info on a j2k image 
   CodecsImageInfo info = codecs.getInformation(srcFileName1, false); 
   System.out.println("j2k - Width: " + info.getWidth() + ", Height: " + info.getHeight()); 
 
   // try to get info on a cmp image 
   try { 
      info = codecs.getInformation(srcFileName2, false); 
   } catch (Exception e) { 
      System.out.println("GetInformation for cmp failed - sample success!"); 
   } 
 
   RasterImage image1 = codecs.load(srcFileName1); 
   codecs.save(image1, dstFileName1, RasterImageFormat.J2K, 0); 
   assertTrue("File unsuccessfully saved", (new File(dstFileName1)).exists()); 
   System.out.println("File successfully saved to: " + dstFileName1); 
 
   // Clean up 
   codecs.dispose(); 
} 
Requirements

Target Platforms

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

Leadtools.Codecs Assembly
Products | Support | Contact Us | Intellectual Property Notices
© 1991-2023 LEAD Technologies, Inc. All Rights Reserved.