)
{
/*
NOTE: Big-endian data expected.
*/
IInputStream stream = getStream();
// Ensure that data is read using the proper endianness!
stream.setByteOrder(ByteOrder.BIG_ENDIAN);
try
{
int index = 4;
stream.seek(index);
byte[] markerBytes = new byte[2];
while(true)
{
index += stream.readUnsignedShort();
stream.seek(index);
stream.read(markerBytes);
index += 2;
// Frame header?
if(markerBytes[0] == (byte)0xFF
&& markerBytes[1] == (byte)0xC0)
{
stream.skip(2);
// Get the image bits per color component (sample precision)!
setBitsPerComponent(stream.readUnsignedByte());
// Get the image size!
setHeight(stream.readUnsignedShort());
setWidth(stream.readUnsignedShort());
break;
}
}
}