throw new IllegalArgumentException("Input file is missing " +
"(use PCDCodec.setInput(RandomAccessFile).");
}
if (in.length() < 16 * 1024)
{
throw new WrongFileFormatException("Not a PCD file.");
}
byte[] sector = new byte[SECTOR_SIZE];
// read first sector; first 7 bytes must be 0xff
in.readFully(sector);
for (int i = 0; i < 7; i++)
{
if (sector[i] != -1)
{
throw new WrongFileFormatException("Input is not a valid PCD " +
"file (wrong magic byte sequence).");
}
}
// read second sector and check more magic bytes
in.readFully(sector);
for (int i = 0; i < MAGIC.length; i++)
{
if (sector[i] != MAGIC[i])
{
throw new WrongFileFormatException("Input is not a valid PCD " +
"file (wrong magic byte sequence).");
}
}
// get image orientation and resolution
int rotationAngle = sector[0x602] & 0x03;