org.geotoolkit.image.jai
Class Registry

Object
  extended by Static
      extended by Registry

public final class Registry
extends Static

A set of static methods for managing JAI's operation registry. Also provides convenience methods for setting the preferred order between standard and JAI ImageReader/ImageWriter.

Since:
2.2
Version:
3.00
Author:
Martin Desruisseaux (IRD, Geomatys)
Module:
coverage/geotk-coverage (download)    View source code for this class

Method Summary
static boolean registerGeotoolkitServices(OperationRegistry registry)
          Unconditionally registers all JAI operations provided in the org.geotoolkit.image.jai package.
static void setDefaultCodecPreferences()
          Sets the default preferred order for JAI and Java standard codec.
static void setNativeAccelerationAllowed(String operation, boolean allowed)
          Allows or disallows native acceleration for the specified operation on the default JAI instance.
static void setNativeAccelerationAllowed(String operation, boolean allowed, JAI jai)
          Allows or disallows native acceleration for the specified operation on the given JAI instance.
static
<T extends ImageReaderWriterSpi>
void
setNativeCodecAllowed(String format, Class<T> category, boolean allowed)
          Allows or disallows native acceleration for the specified image format.
 
Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

registerGeotoolkitServices

@Configuration
public static boolean registerGeotoolkitServices(OperationRegistry registry)
Unconditionally registers all JAI operations provided in the org.geotoolkit.image.jai package. This method usually don't need to be invoked, since JAI should parse automatically the META-INF/registryFile.jai file at startup time. However, this default mechanism may fail when the Geotk JAR file is unreachable from the JAI class loader, in which case the org.geotoolkit.coverage.processing package will invoke this method as a fallback.

Note to module maintainer: if this method is updated, remember to update the META-INF/registryFile.jai file accordingly.

Parameters:
registry - The operation registry to register with.
Returns:
true if all registrations have been successful.

setNativeAccelerationAllowed

@Configuration
public static void setNativeAccelerationAllowed(String operation,
                                                              boolean allowed,
                                                              JAI jai)
Allows or disallows native acceleration for the specified operation on the given JAI instance. By default, JAI uses hardware accelerated methods when available. For example, it makes use of MMX instructions on Intel processors. Unfortunately, some native methods crash the Java Virtual Machine under some circumstances. For example on JAI 1.1.2, the "Affine" operation on an image with float data type, bilinear interpolation and an ImageLayout rendering hint cause an exception in medialib native code. Disabling the native acceleration (i.e using the pure Java version) is a convenient workaround until Sun fix the bug.
Note: The current implementation assumes that factories for native implementations are declared in the com.sun.media.jai.mlib package, while factories for pure Java implementations are declared in the com.sun.media.jai.opimage package. It works for Sun's 1.1.2 implementation, but may change in future versions. If this method doesn't recognize the package, it does nothing.

Parameters:
operation - The operation name (e.g. "Affine").
allowed - false to disallow native acceleration.
jai - The instance of JAI we are going to work on. This argument can be omitted for the default JAI instance.
Since:
2.5
See Also:
JAI bug report 4906854

setNativeAccelerationAllowed

@Configuration
public static void setNativeAccelerationAllowed(String operation,
                                                              boolean allowed)
Allows or disallows native acceleration for the specified operation on the default JAI instance. This method is a shortcut for setNativeAccelerationAllowed(operation, allowed, JAI.getDefaultInstance()).

Parameters:
operation - The operation name (e.g. "Affine").
allowed - false to disallow native acceleration.
See Also:
setNativeAccelerationAllowed(String, boolean, JAI)

setNativeCodecAllowed

@Configuration
public static <T extends ImageReaderWriterSpi> void setNativeCodecAllowed(String format,
                                                                                        Class<T> category,
                                                                                        boolean allowed)
Allows or disallows native acceleration for the specified image format. By default, the image I/O extension for JAI provides native acceleration for PNG and JPEG. Unfortunately, those native codecs have bug in their 1.0 version. Invoking this method will force the use of standard codecs provided in J2SE 1.4.
Note: The current implementation assumes that JAI codec class name start with "com.sun.media" package name. It works for JAI Image I/O 1.1 implementation, but may change in future versions. If this method doesn't recognize the class name, then it does nothing.

Type Parameters:
T - The category (ImageReaderSpi or ImageWriterSpi).
Parameters:
format - The format name (e.g. "png").
category - ImageReaderSpi.class to set the reader, or ImageWriterSpi.class to set the writer.
allowed - false to disallow native acceleration.
Since:
3.00

setDefaultCodecPreferences

@Configuration
public static void setDefaultCodecPreferences()
Sets the default preferred order for JAI and Java standard codec. This method invokes setNativeCodecAllowed for some well-known formats.

TIP: Experience suggests that on some platforms, new codecs appear magically after an AWT window has been created (e.g. "Standard TIFF image reader"). If this method is to be invoked for a graphical application, it is recommended to invoke this method after the Window has been created but before it is made visible.

Since:
3.00
See Also:
org.geotoolkit.image.io, Setup


Copyright © 2009-2012 Geotoolkit.org. All Rights Reserved.