org.esa.beam.util.geotiff
Class IIOUtils

java.lang.Object
  extended by org.esa.beam.util.geotiff.IIOUtils

public class IIOUtils
extends Object


Method Summary
static ImageWriter getImageWriter(ImageTypeSpecifier imageType, String imageFormatName)
          Gets an image writer suitable to be used for the given image type and image format.
static ImageWriter getImageWriter(ImageTypeSpecifier imageType, String imageFormatName, String metadataFormatName)
          Gets an image writer suitable to be used for the given image type, image format and metadata format.
static String getXML(IIOMetadata metadata)
           
static IIOImage readImage(File input)
          Returns a BufferedImage as the result of decoding a supplied File with an ImageReader chosen automatically from among those currently registered.
static IIOImage readImage(ImageInputStream stream)
          Returns a BufferedImage as the result of decoding a supplied ImageInputStream with an ImageReader chosen automatically from among those currently registered.
static boolean writeImage(IIOImage iioImage, String formatName, File output)
          Writes an image using an arbitrary ImageWriter that supports the given format to a File.
static boolean writeImage(IIOImage iioImage, String formatName, ImageOutputStream output)
          Writes an image using the an arbitrary ImageWriter that supports the given format to an ImageOutputStream.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

readImage

public static IIOImage readImage(File input)
                          throws IOException
Returns a BufferedImage as the result of decoding a supplied File with an ImageReader chosen automatically from among those currently registered. The File is wrapped in an ImageInputStream. If no registered ImageReader claims to be able to readImage the resulting stream, null is returned.

The current cache settings from getUseCacheand getCacheDirectory will be used to control caching in the ImageInputStream that is created.

Note that there is no readImage method that takes a filename as a String; use this method instead after creating a File from the filename.

This methods does not attempt to locate ImageReaders that can readImage directly from a File; that may be accomplished using IIORegistry and ImageReaderSpi.

Parameters:
input - a File to readImage from.
Returns:
a BufferedImage containing the decoded contents of the input, or null.
Throws:
IllegalArgumentException - if input is null.
IOException - if an error occurs during reading.

readImage

public static IIOImage readImage(ImageInputStream stream)
                          throws IOException
Returns a BufferedImage as the result of decoding a supplied ImageInputStream with an ImageReader chosen automatically from among those currently registered. If no registered ImageReader claims to be able to readImage the stream, null is returned.

Parameters:
stream - an ImageInputStream to readImage from.
Returns:
a BufferedImage containing the decoded contents of the input, or null.
Throws:
IllegalArgumentException - if stream is null.
IOException - if an error occurs during reading.

writeImage

public static boolean writeImage(IIOImage iioImage,
                                 String formatName,
                                 File output)
                          throws IOException
Writes an image using an arbitrary ImageWriter that supports the given format to a File. If there is already a File present, its contents are discarded.

Parameters:
iioImage - the image data to be written.
formatName - a String containg the informal name of the format.
output - a File to be written to.
Returns:
false if no appropriate writer is found.
Throws:
IllegalArgumentException - if any parameter is null.
IOException - if an error occurs during writing.

writeImage

public static boolean writeImage(IIOImage iioImage,
                                 String formatName,
                                 ImageOutputStream output)
                          throws IOException
Writes an image using the an arbitrary ImageWriter that supports the given format to an ImageOutputStream. The image is written to the ImageOutputStream starting at the current stream pointer, overwriting existing stream data from that point forward, if present.

Parameters:
iioImage - the image data to be written.
formatName - a String containg the informal name of the format.
output - an ImageOutputStream to be written to.
Returns:
false if no appropriate writer is found.
Throws:
IllegalArgumentException - if any parameter is null.
IOException - if an error occurs during writing.

getImageWriter

public static ImageWriter getImageWriter(ImageTypeSpecifier imageType,
                                         String imageFormatName)
Gets an image writer suitable to be used for the given image type and image format.

Parameters:
imageType - the type of the image to be written later
imageFormatName - the image format name, e.g. "TIFF"
Returns:
a suitable image writer, or null if no writer is found

getImageWriter

public static ImageWriter getImageWriter(ImageTypeSpecifier imageType,
                                         String imageFormatName,
                                         String metadataFormatName)
Gets an image writer suitable to be used for the given image type, image format and metadata format.

Parameters:
imageType - the type of the image to be written later
imageFormatName - the image format name, e.g. "TIFF"
metadataFormatName - the metadata format name, e.g. "com_sun_media_imageio_plugins_tiff_image_1.0", or null
Returns:
a suitable image writer, or null if no writer is found

getXML

public static String getXML(IIOMetadata metadata)


Copyright © 2002-2012 Brockmann Consult GmbH. All Rights Reserved.