use of com.sun.media.imageioimpl.plugins.jpeg2000.Box in project bioformats by ome.
the class FileFormatReader method readPaletteBox.
/**
* This method reads the content of the palette box
*/
public void readPaletteBox(int length) throws IOException {
// Get current position in file
int pos = in.getPos();
int lutSize = in.readShort();
int numComp = in.readByte();
compSize = new byte[numComp];
for (int i = 0; i < numComp; i++) {
compSize[i] = (byte) in.readByte();
}
lut = new byte[numComp][lutSize];
for (int n = 0; n < lutSize; n++) {
for (int c = 0; c < numComp; c++) {
int depth = 1 + (compSize[c] & 0x7F);
if (depth > 32)
depth = 32;
int numBytes = (depth + 7) >> 3;
int mask = (1 << depth) - 1;
byte[] buf = new byte[numBytes];
in.readFully(buf, 0, numBytes);
int val = 0;
for (int k = 0; k < numBytes; k++) {
val = buf[k] + (val << 8);
}
lut[c][n] = (byte) val;
}
}
if (metadata != null) {
metadata.addNode(new PaletteBox(length, compSize, lut));
}
}
use of com.sun.media.imageioimpl.plugins.jpeg2000.Box in project bioformats by ome.
the class FileFormatReader method readIntPropertyBox.
/**
* This method reads the contents of the Intellectual property box
*/
public void readIntPropertyBox(int length) throws IOException {
if (metadata != null) {
byte[] data = new byte[length];
in.readFully(data, 0, length);
metadata.addNode(new Box(length + 8, 0x6A703269, data));
}
}
use of com.sun.media.imageioimpl.plugins.jpeg2000.Box in project bioformats by ome.
the class FileFormatReader method readUUIDBox.
/**
* This method reads the contents of the Intellectual property box
*/
public void readUUIDBox(int length) throws IOException {
if (metadata != null) {
byte[] data = new byte[length];
in.readFully(data, 0, length);
metadata.addNode(new UUIDBox(data));
}
}
use of com.sun.media.imageioimpl.plugins.jpeg2000.Box in project bioformats by ome.
the class FileFormatReader method readImageHeaderBox.
/**
* This method reads the Image Header box
* @param length The length of the JP2Header box
*
* @return false if the JP2Header box was not found or invalid else true
*
* @exception java.io.IOException If an I/O error ocurred.
*
* @exception java.io.EOFException If the end of file was reached
*/
public boolean readImageHeaderBox(int length) throws IOException, EOFException {
if (// This can not be last box
length == 0)
throw new Error("Zero-length of JP2Header Box");
// Here the JP2Header data (DBox) would be read if we were to use it
height = in.readInt();
width = in.readInt();
numComp = in.readShort();
bitDepth = in.readByte();
compressionType = in.readByte();
unknownColor = in.readByte();
intelProp = in.readByte();
if (metadata != null) {
metadata.addNode(new HeaderBox(height, width, numComp, bitDepth, compressionType, unknownColor, intelProp));
}
return true;
}
use of com.sun.media.imageioimpl.plugins.jpeg2000.Box in project bioformats by ome.
the class FileFormatReader method readChannelDefinitionBox.
/**
* This method reads the Channel Definition box
*
* @exception java.io.IOException If an I/O error ocurred.
*/
public void readChannelDefinitionBox(int length) throws IOException {
int num = in.readShort();
channels = new short[num];
cType = new short[num];
associations = new short[num];
for (int i = 0; i < num; i++) {
channels[i] = in.readShort();
cType[i] = in.readShort();
associations[i] = in.readShort();
}
if (metadata != null) {
metadata.addNode(new ChannelDefinitionBox(channels, cType, associations));
}
}
Aggregations