Class RawImageInputStream
- All Implemented Interfaces:
Closeable,DataInput,AutoCloseable,ImageInputStream
ImageInputStream
containing several raw images with the same image type: the number of
the images, the image type, the offset for the first sample of each image,
and the image size information.
ImageInputStream methods are not commented individually.
These methods merely forward the call to the ImageInputStream
specified when the RawImageInputStream is constructed.
-
Constructor Summary
ConstructorsConstructorDescriptionRawImageInputStream(ImageInputStream source, SampleModel sampleModel, long[] imageOffsets, Dimension[] imageDimensions) Constructor.RawImageInputStream(ImageInputStream source, ImageTypeSpecifier type, long[] imageOffsets, Dimension[] imageDimensions) Constructor.RawImageInputStream(ImageInputStream source, InputSource xmlSource) Constructor. -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidflush()voidflushBefore(long pos) intlonggetImageDimension(int imageIndex) Retrieves the dimnsion of theimageIndexth image.longgetImageOffset(int imageIndex) Retrieves the image offset of theimageIndexth image.Retrieves the image type.intRetrieves the number of images in theImageInputStream.longbooleanisCached()booleanbooleanlonglength()voidmark()intread()intread(byte[] b) intread(byte[] b, int off, int len) intreadBit()longreadBits(int numBits) booleanbytereadByte()voidreadBytes(IIOByteBuffer buf, int len) charreadChar()doublefloatvoidreadFully(byte[] b) voidreadFully(byte[] b, int off, int len) voidreadFully(char[] c, int off, int len) voidreadFully(double[] d, int off, int len) voidreadFully(float[] f, int off, int len) voidreadFully(int[] i, int off, int len) voidreadFully(long[] l, int off, int len) voidreadFully(short[] s, int off, int len) intreadInt()readLine()longreadLong()shortintlongintreadUTF()voidreset()voidseek(long pos) voidsetBitOffset(int bitOffset) voidsetByteOrder(ByteOrder byteOrder) intskipBytes(int n) longskipBytes(long n)
-
Constructor Details
-
RawImageInputStream
public RawImageInputStream(ImageInputStream source, ImageTypeSpecifier type, long[] imageOffsets, Dimension[] imageDimensions) Constructor.- Parameters:
source- TheImageInputStreamcontaining all the raw images.type- TheImageTypeSpecifierfor all the images in the stream.imageOffsets- The position of the first sample for each image in the stream.imageDimensions- The image size for each image in the stream.- Throws:
IllegalArgumentException- If the sizes ofimageOffsetsandimageDimensionsare different or if either array is null.
-
RawImageInputStream
public RawImageInputStream(ImageInputStream source, SampleModel sampleModel, long[] imageOffsets, Dimension[] imageDimensions) Constructor.This constructor is the same as
RawImageInputStream(ImageInputStream,ImageTypeSpecifier, long[],Dimension[])except that aSampleModelis supplied instead of anImageTypeSpecifier. This constructor creates aColorModelfor the suppliedSampleModeland then creates anImageTypeSpecifier.Suitable
ColorModels are guaranteed to exist for all instances ofComponentSampleModel. For 1- and 3- bandedSampleModels, theColorModelwill be opaque. For 2- and 4-bandedSampleModels, the output will use alpha transparency which is not premultiplied. 1- and 2-banded data will use a grayscaleColorSpace, and 3- and 4-banded data a sRGBColorSpace. Data with 5 or more bands will use aColorSpacewhich satisfies compatibility constraints but is merely a placeholder and does not perform correct color conversion to and from the C.I.E. XYZ and sRGB color spaces.An instance of
DirectColorModelwill be created for instances ofSinglePixelPackedSampleModelwith no more than 4 bands.An instance of
IndexColorModelwill be created for instances ofMultiPixelPackedSampleModel. The colormap will be a grayscale ramp with1 << numberOfBitsentries ranging from zero to at most 255.- Parameters:
source- TheImageInputStreamcontaining all the raw images.sampleModel- TheSampleModelfor all the images in the stream.imageOffsets- The position of the first sample for each image in the stream.imageDimensions- The image size for each image in the stream.- Throws:
IllegalArgumentException- IfsampleModelis null.IllegalArgumentException- If the sizes ofimageOffsetsandimageDimensionsare different or if either array is null.IllegalArgumentException- If it is not possible to create aColorModelfrom the suppliedSampleModel.
-
RawImageInputStream
public RawImageInputStream(ImageInputStream source, InputSource xmlSource) throws SAXException, IOException Constructor. ThexmlSourcemust adhere to the following DTD:<!DOCTYPE "com_sun_media_imageio_stream_raw_1.0" [ <!ELEMENT com_sun_media_imageio_stream_raw_1.0 (byteOrder?, offset?, width?, height?, (ComponentSampleModel | MultiPixelPackedSampleModel | SinglePixelPackedSampleModel), (ComponentColorModel | DirectColorModel | IndexColorModel)?)> <!ATTLIST com_sun_media_imageio_stream_raw_1.0 xmlns CDATA #FIXED "http://com/sun/media/imageio"> <!ELEMENT byteOrder (#PCDATA)> <!-- Byte order of data stream --> <!-- Either "NETWORK" or "REVERSE" --> <!-- Data type: String --> <!ELEMENT offset (#PCDATA)> <!-- Byte offset to the image data in the stream --> <!-- Data type: long --> <!ELEMENT width (#PCDATA)> <!-- Image width; default value is SampleModel width --> <!-- Data type: int --> <!ELEMENT height (#PCDATA)> <!-- Image height; default value is SampleModel height --> <!-- Data type: int --> <!ELEMENT ComponentSampleModel EMPTY> <!-- ComponentSampleModel --> <!ATTLIST ComponentSampleModel dataType (BYTE | USHORT | SHORT | INT | FLOAT | DOUBLE) #REQUIRED <!-- Data type: String --> w CDATA #REQUIRED <!-- SampleModel width --> <!-- Data type: int --> h CDATA #REQUIRED <!-- SampleModel height --> <!-- Data type: int --> pixelStride CDATA "1" <!-- SampleModel pixel stride --> <!-- Data type: int --> scanlineStride CDATA #REQUIRED <!-- SampleModel line stride --> <!-- Data type: int --> bankIndices CDATA #IMPLIED <!-- SampleModel bank indices --> <!-- Data type: int array --> bandOffsets CDATA #REQUIRED> <!-- SampleModel band offsets --> <!-- Data type: int array --> <!ELEMENT MultiPixelPackedSampleModel EMPTY> <!-- MultiPixelPackedSampleModel --> <!ATTLIST MultiPixelPackedSampleModel dataType (BYTE | USHORT | INT) #REQUIRED <!-- Data type: String --> w CDATA #REQUIRED <!-- SampleModel width --> <!-- Data type: int --> h CDATA #REQUIRED <!-- SampleModel height --> <!-- Data type: int --> numberOfBits CDATA #REQUIRED <!-- Number of bits per pixel --> <!-- Data type: int --> scanlineStride CDATA #REQUIRED <!-- SampleModel line stride --> <!-- Data type: int --> dataBitOffset CDATA "0"> <!-- Offset to first valid bit in a line --> <!-- Data type: int --> <!ELEMENT SinglePixelPackedSampleModel EMPTY> <!-- SinglePixelPackedSampleModel --> <!ATTLIST SinglePixelPackedSampleModel dataType (BYTE | USHORT | INT) #REQUIRED <!-- Data type: String --> w CDATA #REQUIRED <!-- SampleModel width --> <!-- Data type: int --> h CDATA #REQUIRED <!-- SampleModel height --> <!-- Data type: int --> scanlineStride CDATA #REQUIRED <!-- SampleModel line stride --> <!-- Data type: int --> bitMasks CDATA #REQUIRED> <!-- Masks indicating RGBA positions --> <!-- Data type: int --> <!ELEMENT ComponentColorModel EMPTY> <!-- ComponentColorModel --> <!ATTLIST ComponentColorModel colorSpace (CIEXYZ | GRAY | LINEAR_RGB | PYCC | sRGB | URL) #REQUIRED <!-- A string representing a predefined ColorSpace or a URI representing the location of any ICC profile from which a ColorSpace may be created. --> <!-- Data type: String --> bits CDATA #IMPLIED <!-- Number of bits per color component --> <!-- Data type: int --> hasAlpha (true | false) #REQUIRED <!-- Whether an alpha channel is present --> <!-- Data type: boolean --> isAlphaPremultiplied (true | false) #REQUIRED <!-- Whether any alpha channel is premultiplied --> <!-- Data type: boolean --> transparency (BITMASK | OPAQUE | TRANSLUCENT) #REQUIRED <!-- The type of transparency --> transferType (BYTE | USHORT | SHORT | INT | FLOAT | DOUBLE) #REQUIRED> <!-- The data transfer type --> <!ELEMENT DirectColorModel EMPTY> <!-- DirectColorModel --> <!ATTLIST DirectColorModel colorSpace (LINEAR_RGB | sRGB | URL) #IMPLIED <!-- A string representing a predefined RGB ColorSpace or a URL representing the location of any ICC profile from which an RGB ColorSpace may be created. --> <!-- Data type: String --> bits CDATA #REQUIRED <!-- Number of bits per color component --> <!-- Data type: int --> rmask CDATA #REQUIRED <!-- Bitmask of the red component --> <!-- Data type: int --> gmask CDATA #REQUIRED <!-- Bitmask of the grenn component --> <!-- Data type: int --> bmask CDATA #REQUIRED <!-- Bitmask of the blue component --> <!-- Data type: int --> amask CDATA "0"> <!-- Bitmask of the alpha component --> <!-- Data type: int --> <!ELEMENT IndexColorModel EMPTY> <!-- IndexColorModel --> <!ATTLIST IndexColorModel bits CDATA #REQUIRED <!-- Number of bits per color component --> <!-- Data type: int --> size CDATA #REQUIRED <!-- Number of elements in the colormap --> <!-- Data type: int --> r CDATA #REQUIRED <!-- Red elements of the colormap --> <!-- Data type: byte array --> g CDATA #REQUIRED <!-- Green elements of the colormap --> <!-- Data type: byte array --> b CDATA #REQUIRED <!-- Blue elements of the colormap --> <!-- Data type: byte array --> a CDATA #IMPLIED> <!-- Alpha elements of the colormap --> <!-- Data type: byte array --> ]>- Parameters:
source- TheImageInputStreamcontaining all the raw images.xmlSource- Theorg.xml.sax.InputSourceto provide the xml document in which the stream structure is defined.- Throws:
RuntimeException- If the parse configuration isn't correct.IllegalArgumentException- If the number of "width" elements isn't the same as the number of "height" elements.SAXException- If one is thrown in parsing.IOException- If one is thrown in parsing, or creating color space from a URL.
-
-
Method Details
-
getImageType
Retrieves the image type.- Returns:
- the image type
-
getImageOffset
public long getImageOffset(int imageIndex) Retrieves the image offset of theimageIndexth image.- Parameters:
imageIndex- the index of the image of interest.- Returns:
- the offset in the stream to the specified image.
- Throws:
IllegalArgumentException- If the provided parameter is out of range.
-
getImageDimension
Retrieves the dimnsion of theimageIndexth image.- Parameters:
imageIndex- the index of the image of interest.- Returns:
- the size of the specified image.
- Throws:
IllegalArgumentException- If the provided parameter is out of rangle.
-
getNumImages
public int getNumImages()Retrieves the number of images in theImageInputStream.- Returns:
- the number of image in the stream.
-
setByteOrder
- Specified by:
setByteOrderin interfaceImageInputStream
-
getByteOrder
- Specified by:
getByteOrderin interfaceImageInputStream
-
read
- Specified by:
readin interfaceImageInputStream- Throws:
IOException
-
read
- Specified by:
readin interfaceImageInputStream- Throws:
IOException
-
read
- Specified by:
readin interfaceImageInputStream- Throws:
IOException
-
readBytes
- Specified by:
readBytesin interfaceImageInputStream- Throws:
IOException
-
readBoolean
- Specified by:
readBooleanin interfaceDataInput- Specified by:
readBooleanin interfaceImageInputStream- Throws:
IOException
-
readByte
- Specified by:
readBytein interfaceDataInput- Specified by:
readBytein interfaceImageInputStream- Throws:
IOException
-
readUnsignedByte
- Specified by:
readUnsignedBytein interfaceDataInput- Specified by:
readUnsignedBytein interfaceImageInputStream- Throws:
IOException
-
readShort
- Specified by:
readShortin interfaceDataInput- Specified by:
readShortin interfaceImageInputStream- Throws:
IOException
-
readUnsignedShort
- Specified by:
readUnsignedShortin interfaceDataInput- Specified by:
readUnsignedShortin interfaceImageInputStream- Throws:
IOException
-
readChar
- Specified by:
readCharin interfaceDataInput- Specified by:
readCharin interfaceImageInputStream- Throws:
IOException
-
readInt
- Specified by:
readIntin interfaceDataInput- Specified by:
readIntin interfaceImageInputStream- Throws:
IOException
-
readUnsignedInt
- Specified by:
readUnsignedIntin interfaceImageInputStream- Throws:
IOException
-
readLong
- Specified by:
readLongin interfaceDataInput- Specified by:
readLongin interfaceImageInputStream- Throws:
IOException
-
readFloat
- Specified by:
readFloatin interfaceDataInput- Specified by:
readFloatin interfaceImageInputStream- Throws:
IOException
-
readDouble
- Specified by:
readDoublein interfaceDataInput- Specified by:
readDoublein interfaceImageInputStream- Throws:
IOException
-
readLine
- Specified by:
readLinein interfaceDataInput- Specified by:
readLinein interfaceImageInputStream- Throws:
IOException
-
readUTF
- Specified by:
readUTFin interfaceDataInput- Specified by:
readUTFin interfaceImageInputStream- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceDataInput- Specified by:
readFullyin interfaceImageInputStream- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceDataInput- Specified by:
readFullyin interfaceImageInputStream- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceImageInputStream- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceImageInputStream- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceImageInputStream- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceImageInputStream- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceImageInputStream- Throws:
IOException
-
readFully
- Specified by:
readFullyin interfaceImageInputStream- Throws:
IOException
-
getStreamPosition
- Specified by:
getStreamPositionin interfaceImageInputStream- Throws:
IOException
-
getBitOffset
- Specified by:
getBitOffsetin interfaceImageInputStream- Throws:
IOException
-
setBitOffset
- Specified by:
setBitOffsetin interfaceImageInputStream- Throws:
IOException
-
readBit
- Specified by:
readBitin interfaceImageInputStream- Throws:
IOException
-
readBits
- Specified by:
readBitsin interfaceImageInputStream- Throws:
IOException
-
length
- Specified by:
lengthin interfaceImageInputStream- Throws:
IOException
-
skipBytes
- Specified by:
skipBytesin interfaceDataInput- Specified by:
skipBytesin interfaceImageInputStream- Throws:
IOException
-
skipBytes
- Specified by:
skipBytesin interfaceImageInputStream- Throws:
IOException
-
seek
- Specified by:
seekin interfaceImageInputStream- Throws:
IOException
-
mark
public void mark()- Specified by:
markin interfaceImageInputStream
-
reset
- Specified by:
resetin interfaceImageInputStream- Throws:
IOException
-
flushBefore
- Specified by:
flushBeforein interfaceImageInputStream- Throws:
IOException
-
flush
- Specified by:
flushin interfaceImageInputStream- Throws:
IOException
-
getFlushedPosition
public long getFlushedPosition()- Specified by:
getFlushedPositionin interfaceImageInputStream
-
isCached
public boolean isCached()- Specified by:
isCachedin interfaceImageInputStream
-
isCachedMemory
public boolean isCachedMemory()- Specified by:
isCachedMemoryin interfaceImageInputStream
-
isCachedFile
public boolean isCachedFile()- Specified by:
isCachedFilein interfaceImageInputStream
-
close
- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Specified by:
closein interfaceImageInputStream- Throws:
IOException
-