org.geotools.resources.image
Class ImageUtilities

java.lang.Object
  extended byorg.geotools.resources.image.ImageUtilities

public final class ImageUtilities
extends java.lang.Object

A set of static methods working on images. Some of those methods are useful, but not really rigorous. This is why they do not appear in any "official" package, but instead in this private one. Do not rely on this API! It may change in incompatible way in any future version.

Since:
2.0
Version:
$Id: ImageUtilities.java 17672 2006-01-19 00:25:55Z desruisseaux $
Author:
Martin Desruisseaux

Method Summary
static void allowNativeAcceleration(java.lang.String operation, boolean allowed)
          Deprecated. Moved to Registry.setNativeAccelerationAllowed(java.lang.String, boolean).
static void allowNativeCodec(java.lang.String format, boolean writer, boolean allowed)
          Allows or disallows native acceleration for the specified image format.
static javax.media.jai.ImageLayout createIntersection(javax.media.jai.ImageLayout layout, java.util.List sources)
          Computes a new ImageLayout which is the intersection of the specified and all s in the supplied list.
static javax.media.jai.ImageLayout getImageLayout(java.awt.image.RenderedImage image)
          Suggests an ImageLayout for the specified image.
static java.lang.String getInterpolationName(javax.media.jai.Interpolation interp)
          Returns the interpolation name for the specified interpolation object.
static java.awt.RenderingHints getRenderingHints(java.awt.image.RenderedImage image)
          Suggest a set of RenderingHints for the specified image.
static javax.media.jai.Interpolation toInterpolation(java.lang.Object type)
          Casts the specified object to an object.
static java.awt.Dimension toTileSize(java.awt.Dimension size)
          Suggests a tile size for the specified image size.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getImageLayout

public static javax.media.jai.ImageLayout getImageLayout(java.awt.image.RenderedImage image)
Suggests an ImageLayout for the specified image. All parameters are initially set equal to those of the given RenderedImage, and then the tile size is updated according the image's size. This method never returns .


getRenderingHints

public static java.awt.RenderingHints getRenderingHints(java.awt.image.RenderedImage image)
Suggest a set of RenderingHints for the specified image. The rendering hints may include the following parameters: This method may returns if no rendering hints is proposed.


toTileSize

public static java.awt.Dimension toTileSize(java.awt.Dimension size)
Suggests a tile size for the specified image size. On input, is the image's size. On output, it is the tile size. This method returns for convenience.


createIntersection

public static javax.media.jai.ImageLayout createIntersection(javax.media.jai.ImageLayout layout,
                                                             java.util.List sources)
Computes a new ImageLayout which is the intersection of the specified and all s in the supplied list. If the minX, minY, width and height properties are not defined in the , then they will be inherited from the first source for consistency with OpImage constructor.

Parameters:
layout - The original layout. This object will not be modified.
sources - The list of sources RenderedImage.
Returns:
A new , or the original if no change was needed.

toInterpolation

public static javax.media.jai.Interpolation toInterpolation(java.lang.Object type)
                                                     throws java.lang.IllegalArgumentException
Casts the specified object to an object.

Parameters:
type - The interpolation type as an Interpolation or a CharSequence object.
Returns:
The interpolation object for the specified type.
Throws:
java.lang.IllegalArgumentException - if the specified interpolation type is not a know one.

getInterpolationName

public static java.lang.String getInterpolationName(javax.media.jai.Interpolation interp)
Returns the interpolation name for the specified interpolation object. This method tries to infer the name from the object's class name.


allowNativeAcceleration

public static void allowNativeAcceleration(java.lang.String operation,
                                           boolean allowed)
Deprecated. Moved to Registry.setNativeAccelerationAllowed(java.lang.String, boolean).

Allows or disallow native acceleration for the specified JAI operation. By default, JAI uses hardware accelerated methods when available. For example, it make use of MMX instructions on Intel processors. Unfortunatly, some native method crash the Java Virtual Machine under some circonstances. 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.

Implementation note: the current implementation assumes that factories for native implementations are declared in the package, while factories for pure java implementations are declared in the package. It work 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 - to disallow native acceleration.

allowNativeCodec

public static void allowNativeCodec(java.lang.String format,
                                    boolean writer,
                                    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. Unfortunatly, those native codec has bug in their 1.0 version. Invoking this method will force the use of standard codec provided in J2SE 1.4.

Implementation note: the current implementation assume that JAI codec class name start with "CLib". It work for Sun's 1.0 implementation, but may change in future versions. If this method doesn't recognize the class name, it does nothing.

Parameters:
format - The format name (e.g. "png").
writer - to set the reader, or to set the writer.
allowed - to disallow native acceleration.


Copyright © GeoTools. All Rights Reserved.