APIdia Launch Partner
Top Description Inners Fields Constructors Methods
javax.imageio

public final Class ImageIO

extends Object
Class Inheritance
Imports
java.awt.image.BufferedImage, .RenderedImage, java.io.File, .InputStream, .IOException, .OutputStream, java.lang.reflect.Method, java.net.URL, java.util.Arrays, .Collections, .HashSet, .Iterator, javax.imageio.spi.IIORegistry, .ImageReaderSpi, .ImageReaderWriterSpi, .ImageWriterSpi, .ImageInputStreamSpi, .ImageOutputStreamSpi, .ImageTranscoderSpi, .ServiceRegistry, javax.imageio.stream.ImageInputStream, .ImageOutputStream

A class containing static convenience methods for locating ImageReaders and ImageWriters, and performing simple encoding and decoding.

Nested and Inner Type Summary

Modifier and TypeClass and Description
pack-priv static class
ImageIO.CacheInfo

A class to hold information about caching.

pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
pack-priv static class
private static enum
pack-priv static class

Field Summary

Modifier and TypeField and Description
private static final ImageIO.CacheInfo
private static Method
private static Method
private static Method
private static final IIORegistry
private static Method
private static Method
private static Method

Constructor Summary

AccessConstructor and Description
private
ImageIO()

Constructor is private to prevent instantiation.

Method Summary

Modifier and TypeMethod and Description
private static boolean
contains(String[] names, String name)

public static ImageInputStream

Returns:

an ImageInputStream, or null.
createImageInputStream
(Object
an Object to be used as an input source, such as a File, readable RandomAccessFile, or InputStream.
input
)

Returns an ImageInputStream that will take its input from the given Object.

public static ImageOutputStream

Returns:

an ImageOutputStream, or null.
createImageOutputStream
(Object
an Object to be used as an output destination, such as a File, writable RandomAccessFile, or OutputStream.
output
)

Returns an ImageOutputStream that will send its output to the given Object.

private static boolean
doWrite(RenderedImage im, ImageWriter writer, ImageOutputStream output)

Writes image to output stream using given image writer.

public static File

Returns:

a File indicating the directory where cache files will be created, or null to indicate the system-dependent default temporary-file directory.
getCacheDirectory
()

Returns the current value set by setCacheDirectory, or null if no explicit setting has been made.

private static synchronized ImageIO.CacheInfo
getCacheInfo()

Returns the CacheInfo object.

public static ImageReader

Returns:

an ImageReader, or null.
getImageReader
(ImageWriter
an instance of a registered ImageWriter.
writer
)

Returns an ImageReader corresponding to the given ImageWriter, if there is one, or null if the plug-in for this ImageWriter does not specify a corresponding ImageReader, or if the given ImageWriter is not registered.

public static Iterator<ImageReader>

Returns:

an Iterator containing ImageReaders.
getImageReaders
(Object
an ImageInputStream or other Object containing encoded image data.
input
)

Returns an Iterator containing all currently registered ImageReaders that claim to be able to decode the supplied Object, typically an ImageInputStream.

public static Iterator<ImageReader>

Returns:

an Iterator containing ImageReaders.
getImageReadersByFormatName
(String
a String containing the informal name of a format (e.g., "jpeg" or "tiff".
formatName
)

Returns an Iterator containing all currently registered ImageReaders that claim to be able to decode the named format.

public static Iterator<ImageReader>

Returns:

an Iterator containing ImageReaders.
getImageReadersByMIMEType
(String
a String containing a file suffix (e.g., "image/jpeg" or "image/x-bmp").
MIMEType
)

Returns an Iterator containing all currently registered ImageReaders that claim to be able to decode files with the given MIME type.

public static Iterator<ImageReader>

Returns:

an Iterator containing ImageReaders.
getImageReadersBySuffix
(String
a String containing a file suffix (e.g., "jpg" or "tiff").
fileSuffix
)

Returns an Iterator containing all currently registered ImageReaders that claim to be able to decode files with the given suffix.

public static Iterator<ImageTranscoder>

Returns:

an Iterator containing ImageTranscoders.
getImageTranscoders
(ImageReader
an ImageReader.
reader
,
ImageWriter
an ImageWriter.
writer
)

Returns an Iterator containing all currently registered ImageTranscoders that claim to be able to transcode between the metadata of the given ImageReader and ImageWriter.

public static ImageWriter

Returns:

an ImageWriter, or null.
getImageWriter
(ImageReader
an instance of a registered ImageReader.
reader
)

Returns an ImageWriter corresponding to the given ImageReader, if there is one, or null if the plug-in for this ImageReader does not specify a corresponding ImageWriter, or if the given ImageReader is not registered.

public static Iterator<ImageWriter>

Returns:

an Iterator containing ImageWriters.
getImageWriters
(ImageTypeSpecifier
an ImageTypeSpecifier indicating the layout of the image to be written.
type
,
String
the informal name of the format.
formatName
)

Returns an Iterator containing all currently registered ImageWriters that claim to be able to encode images of the given layout (specified using an ImageTypeSpecifier) in the given format.

public static Iterator<ImageWriter>

Returns:

an Iterator containing ImageWriters.
getImageWritersByFormatName
(String
a String containing the informal name of a format (e.g., "jpeg" or "tiff".
formatName
)

Returns an Iterator containing all currently registered ImageWriters that claim to be able to encode the named format.

public static Iterator<ImageWriter>

Returns:

an Iterator containing ImageWriters.
getImageWritersByMIMEType
(String
a String containing a file suffix (e.g., "image/jpeg" or "image/x-bmp").
MIMEType
)

Returns an Iterator containing all currently registered ImageWriters that claim to be able to encode files with the given MIME type.

public static Iterator<ImageWriter>

Returns:

an Iterator containing ImageWriters.
getImageWritersBySuffix
(String
a String containing a file suffix (e.g., "jpg" or "tiff").
fileSuffix
)

Returns an Iterator containing all currently registered ImageWriters that claim to be able to encode files with the given suffix.

public static String[]

Returns:

an array of Strings.
getReaderFileSuffixes
()

Returns an array of Strings listing all of the file suffixes associated with the formats understood by the current set of registered readers.

public static String[]

Returns:

an array of Strings.
getReaderFormatNames
()

Returns an array of Strings listing all of the informal format names understood by the current set of registered readers.

public static String[]

Returns:

an array of Strings.
getReaderMIMETypes
()

Returns an array of Strings listing all of the MIME types understood by the current set of registered readers.

private static <S extends ImageReaderWriterSpi> String[]
getReaderWriterInfo(Class<S> spiClass, ImageIO.SpiInfo spiInfo)

private static String
getTempDir()

Returns the default temporary (cache) directory as defined by the java.io.tmpdir system property.

public static boolean

Returns:

true if a disk-based cache may be used for ImageInputStreams and ImageOutputStreams.
getUseCache
()

Returns the current value set by setUseCache, or true if no explicit setting has been made.

private static ImageWriter
getWriter(RenderedImage im, String formatName)

Returns ImageWriter instance according to given rendered image and image format or null if there is no appropriate writer.

public static String[]

Returns:

an array of Strings.
getWriterFileSuffixes
()

Returns an array of Strings listing all of the file suffixes associated with the formats understood by the current set of registered writers.

public static String[]

Returns:

an array of Strings.
getWriterFormatNames
()

Returns an array of Strings listing all of the informal format names understood by the current set of registered writers.

public static String[]

Returns:

an array of Strings.
getWriterMIMETypes
()

Returns an array of Strings listing all of the MIME types understood by the current set of registered writers.

private static boolean
hasCachePermission()

Determines whether the caller has write access to the cache directory, stores the result in the CacheInfo object, and returns the decision.

public static BufferedImage

Returns:

a BufferedImage containing the decoded contents of the input, or null.
read
(File
a File to read from.
input
)

Returns a BufferedImage as the result of decoding a supplied File with an ImageReader chosen automatically from among those currently registered.

public static BufferedImage

Returns:

a BufferedImage containing the decoded contents of the input, or null.
read
(InputStream
an InputStream to read from.
input
)

Returns a BufferedImage as the result of decoding a supplied InputStream with an ImageReader chosen automatically from among those currently registered.

public static BufferedImage

Returns:

a BufferedImage containing the decoded contents of the input, or null.
read
(URL
a URL to read from.
input
)

Returns a BufferedImage as the result of decoding a supplied URL with an ImageReader chosen automatically from among those currently registered.

public static BufferedImage

Returns:

a BufferedImage containing the decoded contents of the input, or null.
read
(ImageInputStream
an ImageInputStream to read from.
stream
)

Returns a BufferedImage as the result of decoding a supplied ImageInputStream with an ImageReader chosen automatically from among those currently registered.

public static void
scanForPlugins()

Scans for plug-ins on the application class path, loads their service provider classes, and registers a service provider instance for each one found with the IIORegistry.

public static void
setCacheDirectory(File
a File specifying a directory.
cacheDirectory
)

Sets the directory where cache files are to be created.

public static void
setUseCache(boolean
a boolean indicating whether a cache file should be used, in cases where it is optional.
useCache
)

Sets a flag indicating whether a disk-based cache file should be used when creating ImageInputStreams and ImageOutputStreams.

public static boolean

Returns:

false if no appropriate writer is found.
write
(RenderedImage
a RenderedImage to be written.
im
,
String
a String containing the informal name of the format.
formatName
,
ImageOutputStream
an ImageOutputStream to be written to.
output
)

Writes an image using an arbitrary ImageWriter that supports the given format to an ImageOutputStream.

public static boolean

Returns:

false if no appropriate writer is found.
write
(RenderedImage
a RenderedImage to be written.
im
,
String
a String containing the informal name of the format.
formatName
,
File
a File to be written to.
output
)

Writes an image using an arbitrary ImageWriter that supports the given format to a File.

public static boolean

Returns:

false if no appropriate writer is found.
write
(RenderedImage
a RenderedImage to be written.
im
,
String
a String containing the informal name of the format.
formatName
,
OutputStream
an OutputStream to be written to.
output
)

Writes an image using an arbitrary ImageWriter that supports the given format to an OutputStream.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait