APIdia Launch Partner
Top Description Fields Constructors Methods
com.sun.imageio.plugins.wbmp

public Class WBMPImageReader

extends ImageReader
Class Inheritance
Imports
java.awt.Rectangle, java.awt.image.BufferedImage, .DataBufferByte, .MultiPixelPackedSampleModel, .Raster, .WritableRaster, javax.imageio.IIOException, .ImageReader, .ImageReadParam, .ImageTypeSpecifier, javax.imageio.metadata.IIOMetadata, javax.imageio.spi.ImageReaderSpi, javax.imageio.stream.ImageInputStream, java.io.IOException, java.util.ArrayList, .Iterator, com.sun.imageio.plugins.common.I18N, .ReaderUtil

This class is the Java Image IO plugin reader for WBMP images. It may subsample the image, clip the image, and shift the decoded image origin if the proper decoding parameter are set in the provided WBMPImageReadParam.

Field Summary

Modifier and TypeField and Description
private boolean
gotHeader

Indicates whether the header is read.

private int
height

The original image height.

private ImageInputStream
iis

The input stream where reads from

private WBMPMetadata
private int
private int
width

The original image width.

Inherited from javax.imageio.ImageReader:
availableLocalesignoreMetadatainputlocaleminIndexoriginatingProviderprogressListenersseekForwardOnlyupdateListenerswarningListenerswarningLocales

Constructor Summary

AccessConstructor and Description
public
WBMPImageReader(ImageReaderSpi originator)

Constructs WBMPImageReader from the provided ImageReaderSpi.

Method Summary

Modifier and TypeMethod and Description
public boolean
canReadRaster()

Overrides javax.imageio.ImageReader.canReadRaster.

Returns true if this plug-in supports reading just a Raster of pixel data.

private void
checkIndex(int imageIndex)

public ImageReadParam
getDefaultReadParam()

Overrides javax.imageio.ImageReader.getDefaultReadParam.

Returns a default ImageReadParam object appropriate for this format.

public int
getHeight(int imageIndex)

Implements abstract javax.imageio.ImageReader.getHeight.

Returns the height in pixels of the given image within the input source.

public IIOMetadata
getImageMetadata(int imageIndex)

Implements abstract javax.imageio.ImageReader.getImageMetadata.

Returns an IIOMetadata object containing metadata associated with the given image, or null if the reader does not support reading metadata, is set to ignore metadata, or if no metadata is available.

public Iterator<ImageTypeSpecifier>
getImageTypes(int imageIndex)

Implements abstract javax.imageio.ImageReader.getImageTypes.

Returns an Iterator containing possible image types to which the given image may be decoded, in the form of ImageTypeSpecifierss.

public int
getNumImages(boolean allowSearch)

Implements abstract javax.imageio.ImageReader.getNumImages.

Returns the number of images, not including thumbnails, available from the current input source.

public IIOMetadata
getStreamMetadata()

Implements abstract javax.imageio.ImageReader.getStreamMetadata.

Returns an IIOMetadata object representing the metadata associated with the input source as a whole (i.e., not associated with any particular image), or null if the reader does not support reading metadata, is set to ignore metadata, or if no metadata is available.

public int
getWidth(int imageIndex)

Implements abstract javax.imageio.ImageReader.getWidth.

Returns the width in pixels of the given image within the input source.

public boolean
isRandomAccessEasy(int imageIndex)

Overrides javax.imageio.ImageReader.isRandomAccessEasy.

Returns true if the storage format of the given image places no inherent impediment on random access to pixels.

pack-priv boolean
isValidWbmpType(int type)

public BufferedImage
read(int imageIndex, ImageReadParam param)

Implements abstract javax.imageio.ImageReader.read.

Reads the image indexed by imageIndex and returns it as a complete BufferedImage, using a supplied ImageReadParam.

public void
public Raster
readRaster(int imageIndex, ImageReadParam param)

Overrides javax.imageio.ImageReader.readRaster.

Returns a new Raster object containing the raw pixel data from the image stream, without any color conversion applied.

public void
reset()

Overrides javax.imageio.ImageReader.reset.

Restores the ImageReader to its initial state.

public void
setInput(Object input, boolean seekForwardOnly, boolean ignoreMetadata)

Overrides javax.imageio.ImageReader.setInput.

Sets the input source to use to the given ImageInputStream or other Object.

Inherited from javax.imageio.ImageReader:
abortabortRequestedaddIIOReadProgressListeneraddIIOReadUpdateListeneraddIIOReadWarningListenercheckReadParamBandSettingsclearAbortRequestcomputeRegionsdisposegetAspectRatiogetAvailableLocalesgetDestinationgetFormatNamegetImageMetadatagetInputgetLocalegetMinIndexgetNumThumbnailsgetOriginatingProvidergetRawImageTypegetSourceRegiongetStreamMetadatagetThumbnailHeightgetThumbnailWidthgetTileGridXOffsetgetTileGridYOffsetgetTileHeightgetTileWidthhasThumbnailsisIgnoringMetadataisImageTiledisSeekForwardOnlyprocessImageCompleteprocessImageProgressprocessImageStartedprocessImageUpdateprocessPassCompleteprocessPassStartedprocessReadAbortedprocessSequenceCompleteprocessSequenceStartedprocessThumbnailCompleteprocessThumbnailPassCompleteprocessThumbnailPassStartedprocessThumbnailProgressprocessThumbnailStartedprocessThumbnailUpdateprocessWarningOccurredprocessWarningOccurredreadreadAllreadAllreadAsRenderedImagereaderSupportsThumbnailsreadThumbnailreadTilereadTileRasterremoveAllIIOReadProgressListenersremoveAllIIOReadUpdateListenersremoveAllIIOReadWarningListenersremoveIIOReadProgressListenerremoveIIOReadUpdateListenerremoveIIOReadWarningListenersetInputsetInputsetLocale

Field Detail

gotHeaderback to summary
private boolean gotHeader

Indicates whether the header is read.

heightback to summary
private int height

The original image height.

iisback to summary
private ImageInputStream iis

The input stream where reads from

metadataback to summary
private WBMPMetadata metadata
wbmpTypeback to summary
private int wbmpType
widthback to summary
private int width

The original image width.

Constructor Detail

WBMPImageReaderback to summary
public WBMPImageReader(ImageReaderSpi originator)

Constructs WBMPImageReader from the provided ImageReaderSpi.

Method Detail

canReadRasterback to summary
public boolean canReadRaster()

Overrides javax.imageio.ImageReader.canReadRaster.

Doc from javax.imageio.ImageReader.canReadRaster.

Returns true if this plug-in supports reading just a Raster of pixel data. If this method returns false, calls to readRaster or readTileRaster will throw an UnsupportedOperationException.

The default implementation returns false.

Annotations
@Override
checkIndexback to summary
private void checkIndex(int imageIndex)
getDefaultReadParamback to summary
public ImageReadParam getDefaultReadParam()

Overrides javax.imageio.ImageReader.getDefaultReadParam.

Doc from javax.imageio.ImageReader.getDefaultReadParam.

Returns a default ImageReadParam object appropriate for this format. All subclasses should define a set of default values for all parameters and return them with this call. This method may be called before the input source is set.

The default implementation constructs and returns a new ImageReadParam object that does not allow source scaling (i.e., it returns new ImageReadParam().

Annotations
@Override
getHeightback to summary
public int getHeight(int imageIndex) throws IOException

Implements abstract javax.imageio.ImageReader.getHeight.

Doc from javax.imageio.ImageReader.getHeight.

Returns the height in pixels of the given image within the input source.

If the image can be rendered to a user-specified size, then this method returns the default height.

Annotations
@Override
Exceptions
IOException:
if an error occurs reading the height information from the input source.
getImageMetadataback to summary
public IIOMetadata getImageMetadata(int imageIndex) throws IOException

Implements abstract javax.imageio.ImageReader.getImageMetadata.

Doc from javax.imageio.ImageReader.getImageMetadata.

Returns an IIOMetadata object containing metadata associated with the given image, or null if the reader does not support reading metadata, is set to ignore metadata, or if no metadata is available.

Annotations
@Override
Exceptions
IOException:
if an error occurs during reading.
getImageTypesback to summary
public Iterator<ImageTypeSpecifier> getImageTypes(int imageIndex) throws IOException

Implements abstract javax.imageio.ImageReader.getImageTypes.

Doc from javax.imageio.ImageReader.getImageTypes.

Returns an Iterator containing possible image types to which the given image may be decoded, in the form of ImageTypeSpecifierss. At least one legal image type will be returned.

The first element of the iterator should be the most "natural" type for decoding the image with as little loss as possible. For example, for a JPEG image the first entry should be an RGB image, even though the image data is stored internally in a YCbCr color space.

Annotations
@Override
Exceptions
IOException:
if an error occurs reading the format information from the input source.
getNumImagesback to summary
public int getNumImages(boolean allowSearch) throws IOException

Implements abstract javax.imageio.ImageReader.getNumImages.

Doc from javax.imageio.ImageReader.getNumImages.

Returns the number of images, not including thumbnails, available from the current input source.

Note that some image formats (such as animated GIF) do not specify how many images are present in the stream. Thus determining the number of images will require the entire stream to be scanned and may require memory for buffering. If images are to be processed in order, it may be more efficient to simply call read with increasing indices until an IndexOutOfBoundsException is thrown to indicate that no more images are available. The allowSearch parameter may be set to false to indicate that an exhaustive search is not desired; the return value will be -1 to indicate that a search is necessary. If the input has been specified with seekForwardOnly set to true, this method throws an IllegalStateException if allowSearch is set to true.

Annotations
@Override
Exceptions
IOException:
if an error occurs reading the information from the input source.
getStreamMetadataback to summary
public IIOMetadata getStreamMetadata() throws IOException

Implements abstract javax.imageio.ImageReader.getStreamMetadata.

Doc from javax.imageio.ImageReader.getStreamMetadata.

Returns an IIOMetadata object representing the metadata associated with the input source as a whole (i.e., not associated with any particular image), or null if the reader does not support reading metadata, is set to ignore metadata, or if no metadata is available.

Annotations
@Override
Exceptions
IOException:
if an error occurs during reading.
getWidthback to summary
public int getWidth(int imageIndex) throws IOException

Implements abstract javax.imageio.ImageReader.getWidth.

Doc from javax.imageio.ImageReader.getWidth.

Returns the width in pixels of the given image within the input source.

If the image can be rendered to a user-specified size, then this method returns the default width.

Annotations
@Override
Exceptions
IOException:
if an error occurs reading the width information from the input source.
isRandomAccessEasyback to summary
public boolean isRandomAccessEasy(int imageIndex) throws IOException

Overrides javax.imageio.ImageReader.isRandomAccessEasy.

Doc from javax.imageio.ImageReader.isRandomAccessEasy.

Returns true if the storage format of the given image places no inherent impediment on random access to pixels. For most compressed formats, such as JPEG, this method should return false, as a large section of the image in addition to the region of interest may need to be decoded.

This is merely a hint for programs that wish to be efficient; all readers must be able to read arbitrary regions as specified in an ImageReadParam.

Note that formats that return false from this method may nonetheless allow tiling (e.g. Restart Markers in JPEG), and random access will likely be reasonably efficient on tiles. See isImageTiled.

A reader for which all images are guaranteed to support easy random access, or are guaranteed not to support easy random access, may return true or false respectively without accessing any image data. In such cases, it is not necessary to throw an exception even if no input source has been set or the image index is out of bounds.

The default implementation returns false.

Annotations
@Override
Exceptions
IOException:
if an error occurs during reading.
isValidWbmpTypeback to summary
pack-priv boolean isValidWbmpType(int type)
readback to summary
public BufferedImage read(int imageIndex, ImageReadParam param) throws IOException

Implements abstract javax.imageio.ImageReader.read.

Doc from javax.imageio.ImageReader.read.

Reads the image indexed by imageIndex and returns it as a complete BufferedImage, using a supplied ImageReadParam.

The actual BufferedImage returned will be chosen using the algorithm defined by the getDestination method.

Any registered IIOReadProgressListener objects will be notified by calling their imageStarted method, followed by calls to their imageProgress method as the read progresses. Finally their imageComplete method will be called. IIOReadUpdateListener objects may be updated at other times during the read as pixels are decoded. Finally, IIOReadWarningListener objects will receive notification of any non-fatal warnings that occur during decoding.

The set of source bands to be read and destination bands to be written is determined by calling getSourceBands and getDestinationBands on the supplied ImageReadParam. If the lengths of the arrays returned by these methods differ, the set of source bands contains an index larger that the largest available source index, or the set of destination bands contains an index larger than the largest legal destination index, an IllegalArgumentException is thrown.

If the supplied ImageReadParam contains optional setting values not supported by this reader (e.g. source render size or any format-specific settings), they will be ignored.

Annotations
@Override
Exceptions
IOException:
if an error occurs during reading.
readHeaderback to summary
public void readHeader() throws IOException
readRasterback to summary
public Raster readRaster(int imageIndex, ImageReadParam param) throws IOException

Overrides javax.imageio.ImageReader.readRaster.

Doc from javax.imageio.ImageReader.readRaster.

Returns a new Raster object containing the raw pixel data from the image stream, without any color conversion applied. The application must determine how to interpret the pixel data by other means. Any destination or image-type parameters in the supplied ImageReadParam object are ignored, but all other parameters are used exactly as in the read method, except that any destination offset is used as a logical rather than a physical offset. The size of the returned Raster will always be that of the source region clipped to the actual image. Logical offsets in the stream itself are ignored.

This method allows formats that normally apply a color conversion, such as JPEG, and formats that do not normally have an associated colorspace, such as remote sensing or medical imaging data, to provide access to raw pixel data.

Any registered readUpdateListeners are ignored, as there is no BufferedImage, but all other listeners are called exactly as they are for the read method.

If canReadRaster() returns false, this method throws an UnsupportedOperationException.

If the supplied ImageReadParam contains optional setting values not supported by this reader (e.g. source render size or any format-specific settings), they will be ignored.

The default implementation throws an UnsupportedOperationException.

Annotations
@Override
Exceptions
IOException:
if an error occurs during reading.
resetback to summary
public void reset()

Overrides javax.imageio.ImageReader.reset.

Doc from javax.imageio.ImageReader.reset.

Restores the ImageReader to its initial state.

The default implementation calls setInput(null, false), setLocale(null), removeAllIIOReadUpdateListeners(), removeAllIIOReadWarningListeners(), removeAllIIOReadProgressListeners(), and clearAbortRequest.

Annotations
@Override
setInputback to summary
public void setInput(Object input, boolean seekForwardOnly, boolean ignoreMetadata)

Overrides javax.imageio.ImageReader.setInput.

Doc from javax.imageio.ImageReader.setInput.

Sets the input source to use to the given ImageInputStream or other Object. The input source must be set before any of the query or read methods are used. If input is null, any currently set input source will be removed. In any case, the value of minIndex will be initialized to 0.

The seekForwardOnly parameter controls whether the value returned by getMinIndex will be increased as each image (or thumbnail, or image metadata) is read. If seekForwardOnly is true, then a call to read(index) will throw an IndexOutOfBoundsException if index < this.minIndex; otherwise, the value of minIndex will be set to index. If seekForwardOnly is false, the value of minIndex will remain 0 regardless of any read operations.

The ignoreMetadata parameter, if set to true, allows the reader to disregard any metadata encountered during the read. Subsequent calls to the getStreamMetadata and getImageMetadata methods may return null, and an IIOImage returned from readAll may return null from their getMetadata method. Setting this parameter may allow the reader to work more efficiently. The reader may choose to disregard this setting and return metadata normally.

Subclasses should take care to remove any cached information based on the previous stream, such as header information or partially decoded image data.

Use of a general Object other than an ImageInputStream is intended for readers that interact directly with a capture device or imaging protocol. The set of legal classes is advertised by the reader's service provider's getInputTypes method; most readers will return a single-element array containing only ImageInputStream.class to indicate that they accept only an ImageInputStream.

The default implementation checks the input argument against the list returned by originatingProvider.getInputTypes() and fails if the argument is not an instance of one of the classes in the list. If the originating provider is set to null, the input is accepted only if it is an ImageInputStream.

Annotations
@Override