Class RawImageInputStream
- java.lang.Object
-
- com.sun.media.imageio.stream.RawImageInputStream
-
- All Implemented Interfaces:
java.io.Closeable,java.io.DataInput,java.lang.AutoCloseable,javax.imageio.stream.ImageInputStream
public class RawImageInputStream extends java.lang.Object implements javax.imageio.stream.ImageInputStreamThis class defines the content of theImageInputStreamcontaining 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.ImageInputStreammethods are not commented individually. These methods merely forward the call to theImageInputStreamspecified when theRawImageInputStreamis constructed.
-
-
Constructor Summary
Constructors Constructor Description RawImageInputStream(javax.imageio.stream.ImageInputStream source, java.awt.image.SampleModel sampleModel, long[] imageOffsets, java.awt.Dimension[] imageDimensions)Constructor.RawImageInputStream(javax.imageio.stream.ImageInputStream source, javax.imageio.ImageTypeSpecifier type, long[] imageOffsets, java.awt.Dimension[] imageDimensions)Constructor.RawImageInputStream(javax.imageio.stream.ImageInputStream source, org.xml.sax.InputSource xmlSource)Constructor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidflush()voidflushBefore(long pos)intgetBitOffset()java.nio.ByteOrdergetByteOrder()longgetFlushedPosition()java.awt.DimensiongetImageDimension(int imageIndex)Retrieves the dimnsion of theimageIndexth image.longgetImageOffset(int imageIndex)Retrieves the image offset of theimageIndexth image.javax.imageio.ImageTypeSpecifiergetImageType()Retrieves the image type.intgetNumImages()Retrieves the number of images in theImageInputStream.longgetStreamPosition()booleanisCached()booleanisCachedFile()booleanisCachedMemory()longlength()voidmark()intread()intread(byte[] b)intread(byte[] b, int off, int len)intreadBit()longreadBits(int numBits)booleanreadBoolean()bytereadByte()voidreadBytes(javax.imageio.stream.IIOByteBuffer buf, int len)charreadChar()doublereadDouble()floatreadFloat()voidreadFully(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()java.lang.StringreadLine()longreadLong()shortreadShort()intreadUnsignedByte()longreadUnsignedInt()intreadUnsignedShort()java.lang.StringreadUTF()voidreset()voidseek(long pos)voidsetBitOffset(int bitOffset)voidsetByteOrder(java.nio.ByteOrder byteOrder)intskipBytes(int n)longskipBytes(long n)
-
-
-
Constructor Detail
-
RawImageInputStream
public RawImageInputStream(javax.imageio.stream.ImageInputStream source, javax.imageio.ImageTypeSpecifier type, long[] imageOffsets, java.awt.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:
java.lang.IllegalArgumentException- If the sizes ofimageOffsetsandimageDimensionsare different or if either array is null.
-
RawImageInputStream
public RawImageInputStream(javax.imageio.stream.ImageInputStream source, java.awt.image.SampleModel sampleModel, long[] imageOffsets, java.awt.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:
java.lang.IllegalArgumentException- IfsampleModelis null.java.lang.IllegalArgumentException- If the sizes ofimageOffsetsandimageDimensionsare different or if either array is null.java.lang.IllegalArgumentException- If it is not possible to create aColorModelfrom the suppliedSampleModel.
-
RawImageInputStream
public RawImageInputStream(javax.imageio.stream.ImageInputStream source, org.xml.sax.InputSource xmlSource) throws org.xml.sax.SAXException, java.io.IOExceptionConstructor. 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:
java.lang.RuntimeException- If the parse configuration isn't correct.java.lang.IllegalArgumentException- If the number of "width" elements isn't the same as the number of "height" elements.org.xml.sax.SAXException- If one is thrown in parsing.java.io.IOException- If one is thrown in parsing, or creating color space from a URL.
-
-
Method Detail
-
getImageType
public javax.imageio.ImageTypeSpecifier 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:
java.lang.IllegalArgumentException- If the provided parameter is out of range.
-
getImageDimension
public java.awt.Dimension getImageDimension(int imageIndex)
Retrieves the dimnsion of theimageIndexth image.- Parameters:
imageIndex- the index of the image of interest.- Returns:
- the size of the specified image.
- Throws:
java.lang.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
public void setByteOrder(java.nio.ByteOrder byteOrder)
- Specified by:
setByteOrderin interfacejavax.imageio.stream.ImageInputStream
-
getByteOrder
public java.nio.ByteOrder getByteOrder()
- Specified by:
getByteOrderin interfacejavax.imageio.stream.ImageInputStream
-
read
public int read() throws java.io.IOException- Specified by:
readin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b) throws java.io.IOException- Specified by:
readin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Specified by:
readin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readBytes
public void readBytes(javax.imageio.stream.IIOByteBuffer buf, int len) throws java.io.IOException- Specified by:
readBytesin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readBoolean
public boolean readBoolean() throws java.io.IOException- Specified by:
readBooleanin interfacejava.io.DataInput- Specified by:
readBooleanin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readByte
public byte readByte() throws java.io.IOException- Specified by:
readBytein interfacejava.io.DataInput- Specified by:
readBytein interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readUnsignedByte
public int readUnsignedByte() throws java.io.IOException- Specified by:
readUnsignedBytein interfacejava.io.DataInput- Specified by:
readUnsignedBytein interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readShort
public short readShort() throws java.io.IOException- Specified by:
readShortin interfacejava.io.DataInput- Specified by:
readShortin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readUnsignedShort
public int readUnsignedShort() throws java.io.IOException- Specified by:
readUnsignedShortin interfacejava.io.DataInput- Specified by:
readUnsignedShortin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readChar
public char readChar() throws java.io.IOException- Specified by:
readCharin interfacejava.io.DataInput- Specified by:
readCharin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readInt
public int readInt() throws java.io.IOException- Specified by:
readIntin interfacejava.io.DataInput- Specified by:
readIntin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readUnsignedInt
public long readUnsignedInt() throws java.io.IOException- Specified by:
readUnsignedIntin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readLong
public long readLong() throws java.io.IOException- Specified by:
readLongin interfacejava.io.DataInput- Specified by:
readLongin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readFloat
public float readFloat() throws java.io.IOException- Specified by:
readFloatin interfacejava.io.DataInput- Specified by:
readFloatin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readDouble
public double readDouble() throws java.io.IOException- Specified by:
readDoublein interfacejava.io.DataInput- Specified by:
readDoublein interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readLine
public java.lang.String readLine() throws java.io.IOException- Specified by:
readLinein interfacejava.io.DataInput- Specified by:
readLinein interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readUTF
public java.lang.String readUTF() throws java.io.IOException- Specified by:
readUTFin interfacejava.io.DataInput- Specified by:
readUTFin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readFully
public void readFully(byte[] b, int off, int len) throws java.io.IOException- Specified by:
readFullyin interfacejava.io.DataInput- Specified by:
readFullyin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readFully
public void readFully(byte[] b) throws java.io.IOException- Specified by:
readFullyin interfacejava.io.DataInput- Specified by:
readFullyin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readFully
public void readFully(short[] s, int off, int len) throws java.io.IOException- Specified by:
readFullyin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readFully
public void readFully(char[] c, int off, int len) throws java.io.IOException- Specified by:
readFullyin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readFully
public void readFully(int[] i, int off, int len) throws java.io.IOException- Specified by:
readFullyin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readFully
public void readFully(long[] l, int off, int len) throws java.io.IOException- Specified by:
readFullyin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readFully
public void readFully(float[] f, int off, int len) throws java.io.IOException- Specified by:
readFullyin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readFully
public void readFully(double[] d, int off, int len) throws java.io.IOException- Specified by:
readFullyin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
getStreamPosition
public long getStreamPosition() throws java.io.IOException- Specified by:
getStreamPositionin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
getBitOffset
public int getBitOffset() throws java.io.IOException- Specified by:
getBitOffsetin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
setBitOffset
public void setBitOffset(int bitOffset) throws java.io.IOException- Specified by:
setBitOffsetin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readBit
public int readBit() throws java.io.IOException- Specified by:
readBitin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
readBits
public long readBits(int numBits) throws java.io.IOException- Specified by:
readBitsin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
length
public long length() throws java.io.IOException- Specified by:
lengthin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
skipBytes
public int skipBytes(int n) throws java.io.IOException- Specified by:
skipBytesin interfacejava.io.DataInput- Specified by:
skipBytesin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
skipBytes
public long skipBytes(long n) throws java.io.IOException- Specified by:
skipBytesin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
seek
public void seek(long pos) throws java.io.IOException- Specified by:
seekin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
mark
public void mark()
- Specified by:
markin interfacejavax.imageio.stream.ImageInputStream
-
reset
public void reset() throws java.io.IOException- Specified by:
resetin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
flushBefore
public void flushBefore(long pos) throws java.io.IOException- Specified by:
flushBeforein interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
flush
public void flush() throws java.io.IOException- Specified by:
flushin interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
getFlushedPosition
public long getFlushedPosition()
- Specified by:
getFlushedPositionin interfacejavax.imageio.stream.ImageInputStream
-
isCached
public boolean isCached()
- Specified by:
isCachedin interfacejavax.imageio.stream.ImageInputStream
-
isCachedMemory
public boolean isCachedMemory()
- Specified by:
isCachedMemoryin interfacejavax.imageio.stream.ImageInputStream
-
isCachedFile
public boolean isCachedFile()
- Specified by:
isCachedFilein interfacejavax.imageio.stream.ImageInputStream
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Specified by:
closein interfacejavax.imageio.stream.ImageInputStream- Throws:
java.io.IOException
-
-