LEADTOOLS Image File Support (Leadtools.Codecs assembly)

PreloadCodecs Method

Show in webframe
Example 







Number of codecs that should stay loaded in memory at all times.
Number of codecs that should be loaded, but can be unloaded later to make room for other codecs.
A System.String containing the codecs which should be loaded.
Specifies the file format codecs to be loaded.
Syntax
public void PreloadCodecs( 
   int fixedCodecs,
   int cachedCodecs,
   string codecs
)
'Declaration
 
Public Sub PreloadCodecs( _
   ByVal fixedCodecs As Integer, _
   ByVal cachedCodecs As Integer, _
   ByVal codecs As String _
) 
'Usage
 
Dim instance As RasterCodecs
Dim fixedCodecs As Integer
Dim cachedCodecs As Integer
Dim codecs As String
 
instance.PreloadCodecs(fixedCodecs, cachedCodecs, codecs)
public void PreloadCodecs( 
   int fixedCodecs,
   int cachedCodecs,
   string codecs
)

            
public void preloadCodecs(int fixedCodecs, int cachedCodecs, String codecs)
 function Leadtools.Codecs.RasterCodecs.PreloadCodecs( 
   fixedCodecs ,
   cachedCodecs ,
   codecs 
)
public:
void PreloadCodecs( 
   int fixedCodecs,
   int cachedCodecs,
   String^ codecs
) 

Parameters

fixedCodecs
Number of codecs that should stay loaded in memory at all times.
cachedCodecs
Number of codecs that should be loaded, but can be unloaded later to make room for other codecs.
codecs
A System.String containing the codecs which should be loaded.
Remarks

If codecs is empty, all file codecs LEADTOOLS can find will be loaded and LEADTOOLS will determine the order in which the files will be used.

codecs is in the form xyz, yuv ... where Xyz are the 3 letters describing the file codec as in Leadtools.Codecs.Xyz.dll. For instance, if codecs is BMP,TIF,CMP then the following codecs will be loaded in the following order:

  1. Leadtools.Codecs.Bmp.dll
  2. Leadtools.Codecs.Tif.dll
  3. Leadtools.Codecs.Cmp.dll

The first fixedCodecs will stay in memory at all times, then the next cachedCodecs will be loaded. However, if other codecs will be needed, the cached codecs might be unloaded to make room for the new DLLs.

It is recommended that the most commonly used DLLs be loaded as fixed to minimize the time required to load/unload file codecs. Also, some DLLs may require additional DLLs (like the Leadtools.Pdf.dll or Leadtools.Codecs.Tif.dll) so the exact number of DLLs loaded is not necessarily equal fixedCodecs + cachedCodecs.

Before calling this method, you can get the default preload codecs list using PreloadCodecsList.

Example
Copy Code  
Imports Leadtools
Imports Leadtools.Codecs
Imports Leadtools.ImageProcessing
Imports Leadtools.ImageProcessing.Color
Imports Leadtools.Drawing

Public Sub PreloadCodecsExample()
   Dim codecs As RasterCodecs = New RasterCodecs()

   Dim srcFileName1 As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.j2k")
   Dim srcFileName2 As String = Path.Combine(LEAD_VARS.ImagesDir, "Image1.cmp")

   ' display the original values before changing them
   Console.WriteLine("PreloadCodecList - {0}", codecs.PreloadCodecsList)
   Console.WriteLine("FixedPreloadCodecs - {0}", codecs.FixedPreloadCodecs)
   Console.WriteLine("CachedPreloadCodecs - {0}", codecs.CachedPreloadCodecs)
   Console.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
   Dim info As CodecsImageInfo = codecs.GetInformation(srcFileName1, False)
   Console.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
      Console.WriteLine("GetInformation for cmp failed - sample success!")
   End Try

   ' Clean up
   codecs.Dispose()
End Sub

Public NotInheritable Class LEAD_VARS
Public Const ImagesDir As String = "C:\Users\Public\Documents\LEADTOOLS Images"
End Class
using Leadtools;
using Leadtools.Codecs;
using Leadtools.ImageProcessing;
using Leadtools.ImageProcessing.Color;

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
   Console.WriteLine("PreloadCodecList - {0}", codecs.PreloadCodecsList);
   Console.WriteLine("FixedPreloadCodecs - {0}", codecs.FixedPreloadCodecs);
   Console.WriteLine("CachedPreloadCodecs - {0}", codecs.CachedPreloadCodecs);
   Console.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);
   Console.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
   {
      Console.WriteLine("GetInformation for cmp failed - sample success!");
   }

   // Clean up
   codecs.Dispose();
}

static class LEAD_VARS
{
public const string ImagesDir = @"C:\Users\Public\Documents\LEADTOOLS Images";
}
Requirements

Target Platforms

See Also

Reference

RasterCodecs Class
RasterCodecs Members
Loading File Codecs
Fast File Info

 

 


Products | Support | Contact Us | Copyright Notices
© 2006-2014 All Rights Reserved. LEAD Technologies, Inc.