loadHeader();
//System.out.println(width + " x " + height + ", color=" + colorMode + ", channels=" + channels + ", depth=" + depth);
// check values
if (width < 1 || height < 1)
{
throw new InvalidFileStructureException("Cannot load image. " +
"Invalid pixel resolution in PSD file header (" + width +
" x " + height + ").");
}
if (colorMode != COLOR_MODE_RGB_TRUECOLOR &&
colorMode != COLOR_MODE_GRAYSCALE &&
colorMode != COLOR_MODE_INDEXED)
{
throw new UnsupportedTypeException("Cannot load image. Only RGB" +
" truecolor and indexed color are supported for PSD files. " +
"Found: " +getColorTypeName(colorMode));
}
if (depth != 8)
{
throw new UnsupportedTypeException("Cannot load image. Only a depth of 8 bits " +
"per channel is supported (found " + depth +
" bits).");
}
// COLOR MODE DATA
int colorModeSize = in.readInt();
//System.out.println("colorModeSize=" + colorModeSize);
byte[] colorMap = null;
if (colorMode == COLOR_MODE_INDEXED)
{
if (colorModeSize != 768)
{
throw new InvalidFileStructureException("Cannot load image." +
" Color map length was expected to be 768 (found " +
colorModeSize + ").");
}
colorMap = new byte[colorModeSize];
in.readFully(colorMap);