public class RawImageInputStream extends Object implements 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.
| Modifier and Type | Field and Description |
|---|---|
private Dimension[] |
imageDimensions
The image sizes.
|
private long[] |
imageOffsets
The position of the first sample for each image.
|
private static String[] |
preDefinedColorSpaces |
private static int[] |
preDefinedTypes |
private ImageInputStream |
source
The wrapperred
ImageInputStream. |
private ImageTypeSpecifier |
type
The image type for all the images in the stream.
|
| Constructor and Description |
|---|
RawImageInputStream(ImageInputStream source,
ImageTypeSpecifier type,
long[] imageOffsets,
Dimension[] imageDimensions)
Constructor.
|
RawImageInputStream(ImageInputStream source,
InputSource xmlSource)
Constructor.
|
RawImageInputStream(ImageInputStream source,
SampleModel sampleModel,
long[] imageOffsets,
Dimension[] imageDimensions)
Constructor.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
void |
flush() |
void |
flushBefore(long pos) |
private static String |
getAttribute(Node node,
String name)
Gets the attribute from the node.
|
int |
getBitOffset() |
private static boolean |
getBoolean(Node node,
String name)
Gets the boolean type attribute.
|
private static byte[] |
getByteArray(Node node,
String name)
Gets the integer type attribute.
|
ByteOrder |
getByteOrder() |
private static ColorSpace |
getColorSpace(Node node) |
long |
getFlushedPosition() |
Dimension |
getImageDimension(int imageIndex)
Retrieves the dimnsion of the
imageIndexth image. |
long |
getImageOffset(int imageIndex)
Retrieves the image offset of the
imageIndexth image. |
ImageTypeSpecifier |
getImageType()
Retrieves the image type.
|
private static int |
getInt(Node node,
String name)
Gets the integer type attribute.
|
private static int[] |
getIntArray(Node node,
String name)
Gets the integer type attribute.
|
int |
getNumImages()
Retrieves the number of images in the
ImageInputStream. |
long |
getStreamPosition() |
private static int |
getTransparency(String s) |
boolean |
isCached() |
boolean |
isCachedFile() |
boolean |
isCachedMemory() |
long |
length() |
void |
mark() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
int |
readBit() |
long |
readBits(int numBits) |
boolean |
readBoolean() |
byte |
readByte() |
void |
readBytes(IIOByteBuffer buf,
int len) |
char |
readChar() |
double |
readDouble() |
float |
readFloat() |
void |
readFully(byte[] b) |
void |
readFully(byte[] b,
int off,
int len) |
void |
readFully(char[] c,
int off,
int len) |
void |
readFully(double[] d,
int off,
int len) |
void |
readFully(float[] f,
int off,
int len) |
void |
readFully(int[] i,
int off,
int len) |
void |
readFully(long[] l,
int off,
int len) |
void |
readFully(short[] s,
int off,
int len) |
int |
readInt() |
String |
readLine() |
long |
readLong() |
short |
readShort() |
int |
readUnsignedByte() |
long |
readUnsignedInt() |
int |
readUnsignedShort() |
String |
readUTF() |
void |
reset() |
void |
seek(long pos) |
void |
setBitOffset(int bitOffset) |
void |
setByteOrder(ByteOrder byteOrder) |
int |
skipBytes(int n) |
long |
skipBytes(long n) |
private static final String[] preDefinedColorSpaces
private static final int[] preDefinedTypes
private ImageInputStream source
ImageInputStream.private ImageTypeSpecifier type
private long[] imageOffsets
private Dimension[] imageDimensions
public RawImageInputStream(ImageInputStream source, ImageTypeSpecifier type, long[] imageOffsets, Dimension[] imageDimensions)
source - The ImageInputStream containing all the raw
images.type - The ImageTypeSpecifier for 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.IllegalArgumentException - If the sizes of
imageOffsets
and imageDimensions are different or if
either array is null.public RawImageInputStream(ImageInputStream source, SampleModel sampleModel, long[] imageOffsets, Dimension[] imageDimensions)
This constructor is the same as
RawImageInputStream(ImageInputStream,ImageTypeSpecifier,
long[],Dimension[]) except that a SampleModel is
supplied instead of an ImageTypeSpecifier. This
constructor creates a ColorModel for the supplied
SampleModel and then creates an
ImageTypeSpecifier.
Suitable ColorModels are guaranteed to exist
for all instances of ComponentSampleModel.
For 1- and 3- banded SampleModels, the
ColorModel will be opaque. For 2- and 4-banded
SampleModels, the output will use alpha transparency
which is not premultiplied. 1- and 2-banded data will use a
grayscale ColorSpace, and 3- and 4-banded data a sRGB
ColorSpace. Data with 5 or more bands will use a
ColorSpace which 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 DirectColorModel will be created for
instances of SinglePixelPackedSampleModel with no more
than 4 bands.
An instance of IndexColorModel will be created for
instances of MultiPixelPackedSampleModel. The colormap
will be a grayscale ramp with 1 << numberOfBits
entries ranging from zero to at most 255.
source - The ImageInputStream containing all the raw
images.sampleModel - The SampleModel for 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.IllegalArgumentException - If sampleModel is null.IllegalArgumentException - If the sizes of
imageOffsets
and imageDimensions are different or if
either array is null.IllegalArgumentException - If it is not possible to create a
ColorModel from the supplied
SampleModel.public RawImageInputStream(ImageInputStream source, InputSource xmlSource) throws SAXException, IOException
xmlSource must 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 -->
]>
source - The ImageInputStream containing all the raw
images.xmlSource - The org.xml.sax.InputSource to provide
the xml document in which the stream structure is defined.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.private static String getAttribute(Node node, String name)
private static boolean getBoolean(Node node, String name)
private static byte[] getByteArray(Node node, String name)
private static int[] getIntArray(Node node, String name)
private static int getTransparency(String s)
private static ColorSpace getColorSpace(Node node) throws IOException
IOExceptionpublic ImageTypeSpecifier getImageType()
public long getImageOffset(int imageIndex)
imageIndexth image.imageIndex - the index of the image of interest.IllegalArgumentException - If the provided parameter is out of
range.public Dimension getImageDimension(int imageIndex)
imageIndexth image.imageIndex - the index of the image of interest.IllegalArgumentException - If the provided parameter is out of
rangle.public int getNumImages()
ImageInputStream.public void setByteOrder(ByteOrder byteOrder)
setByteOrder in interface ImageInputStreampublic ByteOrder getByteOrder()
getByteOrder in interface ImageInputStreampublic int read()
throws IOException
read in interface ImageInputStreamIOExceptionpublic int read(byte[] b)
throws IOException
read in interface ImageInputStreamIOExceptionpublic int read(byte[] b,
int off,
int len)
throws IOException
read in interface ImageInputStreamIOExceptionpublic void readBytes(IIOByteBuffer buf, int len) throws IOException
readBytes in interface ImageInputStreamIOExceptionpublic boolean readBoolean()
throws IOException
readBoolean in interface DataInputreadBoolean in interface ImageInputStreamIOExceptionpublic byte readByte()
throws IOException
readByte in interface DataInputreadByte in interface ImageInputStreamIOExceptionpublic int readUnsignedByte()
throws IOException
readUnsignedByte in interface DataInputreadUnsignedByte in interface ImageInputStreamIOExceptionpublic short readShort()
throws IOException
readShort in interface DataInputreadShort in interface ImageInputStreamIOExceptionpublic int readUnsignedShort()
throws IOException
readUnsignedShort in interface DataInputreadUnsignedShort in interface ImageInputStreamIOExceptionpublic char readChar()
throws IOException
readChar in interface DataInputreadChar in interface ImageInputStreamIOExceptionpublic int readInt()
throws IOException
readInt in interface DataInputreadInt in interface ImageInputStreamIOExceptionpublic long readUnsignedInt()
throws IOException
readUnsignedInt in interface ImageInputStreamIOExceptionpublic long readLong()
throws IOException
readLong in interface DataInputreadLong in interface ImageInputStreamIOExceptionpublic float readFloat()
throws IOException
readFloat in interface DataInputreadFloat in interface ImageInputStreamIOExceptionpublic double readDouble()
throws IOException
readDouble in interface DataInputreadDouble in interface ImageInputStreamIOExceptionpublic String readLine() throws IOException
readLine in interface DataInputreadLine in interface ImageInputStreamIOExceptionpublic String readUTF() throws IOException
readUTF in interface DataInputreadUTF in interface ImageInputStreamIOExceptionpublic void readFully(byte[] b,
int off,
int len)
throws IOException
readFully in interface DataInputreadFully in interface ImageInputStreamIOExceptionpublic void readFully(byte[] b)
throws IOException
readFully in interface DataInputreadFully in interface ImageInputStreamIOExceptionpublic void readFully(short[] s,
int off,
int len)
throws IOException
readFully in interface ImageInputStreamIOExceptionpublic void readFully(char[] c,
int off,
int len)
throws IOException
readFully in interface ImageInputStreamIOExceptionpublic void readFully(int[] i,
int off,
int len)
throws IOException
readFully in interface ImageInputStreamIOExceptionpublic void readFully(long[] l,
int off,
int len)
throws IOException
readFully in interface ImageInputStreamIOExceptionpublic void readFully(float[] f,
int off,
int len)
throws IOException
readFully in interface ImageInputStreamIOExceptionpublic void readFully(double[] d,
int off,
int len)
throws IOException
readFully in interface ImageInputStreamIOExceptionpublic long getStreamPosition()
throws IOException
getStreamPosition in interface ImageInputStreamIOExceptionpublic int getBitOffset()
throws IOException
getBitOffset in interface ImageInputStreamIOExceptionpublic void setBitOffset(int bitOffset)
throws IOException
setBitOffset in interface ImageInputStreamIOExceptionpublic int readBit()
throws IOException
readBit in interface ImageInputStreamIOExceptionpublic long readBits(int numBits)
throws IOException
readBits in interface ImageInputStreamIOExceptionpublic long length()
throws IOException
length in interface ImageInputStreamIOExceptionpublic int skipBytes(int n)
throws IOException
skipBytes in interface DataInputskipBytes in interface ImageInputStreamIOExceptionpublic long skipBytes(long n)
throws IOException
skipBytes in interface ImageInputStreamIOExceptionpublic void seek(long pos)
throws IOException
seek in interface ImageInputStreamIOExceptionpublic void mark()
mark in interface ImageInputStreampublic void reset()
throws IOException
reset in interface ImageInputStreamIOExceptionpublic void flushBefore(long pos)
throws IOException
flushBefore in interface ImageInputStreamIOExceptionpublic void flush()
throws IOException
flush in interface ImageInputStreamIOExceptionpublic long getFlushedPosition()
getFlushedPosition in interface ImageInputStreampublic boolean isCached()
isCached in interface ImageInputStreampublic boolean isCachedMemory()
isCachedMemory in interface ImageInputStreampublic boolean isCachedFile()
isCachedFile in interface ImageInputStreampublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in interface ImageInputStreamIOExceptionCopyright © 2016 Open Microscopy Environment