Class ImageIO
java.lang.Object
javax.imageio.ImageIO
A class containing static convenience methods for locating
ImageReader
s and ImageWriter
s, and
performing simple encoding and decoding.-
Method Summary
Modifier and TypeMethodDescriptionstatic ImageInputStream
createImageInputStream
(Object input) Returns anImageInputStream
that will take its input from the givenObject
.static ImageOutputStream
createImageOutputStream
(Object output) Returns anImageOutputStream
that will send its output to the givenObject
.static File
Returns the current value set bysetCacheDirectory
, ornull
if no explicit setting has been made.static ImageReader
getImageReader
(ImageWriter writer) Returns anImageReader
corresponding to the givenImageWriter
, if there is one, ornull
if the plug-in for thisImageWriter
does not specify a correspondingImageReader
, or if the givenImageWriter
is not registered.static Iterator
<ImageReader> getImageReaders
(Object input) Returns anIterator
containing all currently registeredImageReader
s that claim to be able to decode the suppliedObject
, typically anImageInputStream
.static Iterator
<ImageReader> getImageReadersByFormatName
(String formatName) Returns anIterator
containing all currently registeredImageReader
s that claim to be able to decode the named format.static Iterator
<ImageReader> getImageReadersByMIMEType
(String MIMEType) Returns anIterator
containing all currently registeredImageReader
s that claim to be able to decode files with the given MIME type.static Iterator
<ImageReader> getImageReadersBySuffix
(String fileSuffix) Returns anIterator
containing all currently registeredImageReader
s that claim to be able to decode files with the given suffix.static Iterator
<ImageTranscoder> getImageTranscoders
(ImageReader reader, ImageWriter writer) Returns anIterator
containing all currently registeredImageTranscoder
s that claim to be able to transcode between the metadata of the givenImageReader
andImageWriter
.static ImageWriter
getImageWriter
(ImageReader reader) Returns anImageWriter
corresponding to the givenImageReader
, if there is one, ornull
if the plug-in for thisImageReader
does not specify a correspondingImageWriter
, or if the givenImageReader
is not registered.static Iterator
<ImageWriter> getImageWriters
(ImageTypeSpecifier type, String formatName) Returns anIterator
containing all currently registeredImageWriter
s that claim to be able to encode images of the given layout (specified using anImageTypeSpecifier
) in the given format.static Iterator
<ImageWriter> getImageWritersByFormatName
(String formatName) Returns anIterator
containing all currently registeredImageWriter
s that claim to be able to encode the named format.static Iterator
<ImageWriter> getImageWritersByMIMEType
(String MIMEType) Returns anIterator
containing all currently registeredImageWriter
s that claim to be able to encode files with the given MIME type.static Iterator
<ImageWriter> getImageWritersBySuffix
(String fileSuffix) Returns anIterator
containing all currently registeredImageWriter
s that claim to be able to encode files with the given suffix.static String[]
Returns an array ofString
s listing all of the file suffixes associated with the formats understood by the current set of registered readers.static String[]
Returns an array ofString
s listing all of the informal format names understood by the current set of registered readers.static String[]
Returns an array ofString
s listing all of the MIME types understood by the current set of registered readers.static boolean
Returns the current value set bysetUseCache
, ortrue
if no explicit setting has been made.static String[]
Returns an array ofString
s listing all of the file suffixes associated with the formats understood by the current set of registered writers.static String[]
Returns an array ofString
s listing all of the informal format names understood by the current set of registered writers.static String[]
Returns an array ofString
s listing all of the MIME types understood by the current set of registered writers.static BufferedImage
Returns aBufferedImage
as the result of decoding a suppliedFile
with anImageReader
chosen automatically from among those currently registered.static BufferedImage
read
(InputStream input) Returns aBufferedImage
as the result of decoding a suppliedInputStream
with anImageReader
chosen automatically from among those currently registered.static BufferedImage
Returns aBufferedImage
as the result of decoding a suppliedURL
with anImageReader
chosen automatically from among those currently registered.static BufferedImage
read
(ImageInputStream stream) Returns aBufferedImage
as the result of decoding a suppliedImageInputStream
with anImageReader
chosen automatically from among those currently registered.static void
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 theIIORegistry
.static void
setCacheDirectory
(File cacheDirectory) Sets the directory where cache files are to be created.static void
setUseCache
(boolean useCache) Sets a flag indicating whether a disk-based cache file should be used when creatingImageInputStream
s andImageOutputStream
s.static boolean
write
(RenderedImage im, String formatName, File output) Writes an image using an arbitraryImageWriter
that supports the given format to aFile
.static boolean
write
(RenderedImage im, String formatName, OutputStream output) Writes an image using an arbitraryImageWriter
that supports the given format to anOutputStream
.static boolean
write
(RenderedImage im, String formatName,