private void validateImage()

in src/main/java/org/apache/xmlgraphics/image/codec/tiff/TIFFImageEncoder.java [949:990]


    private void validateImage(int dataTypeSize, int[] sampleSize, int numBands, int dataType,
            ColorModel colorModel) {
        // Retrieve and verify sample size.
        for (int i = 1; i < sampleSize.length; i++) {
            if (sampleSize[i] != dataTypeSize) {
                throw new RuntimeException(PropertyUtil.getString("TIFFImageEncoder0"));
            }
        }

        // Check low bit limits.
        if ((dataTypeSize == 1 || dataTypeSize == 4) && numBands != 1) {
            throw new RuntimeException(PropertyUtil.getString("TIFFImageEncoder1"));
        }

        // Retrieve and verify data type.
        switch (dataType) {
        case DataBuffer.TYPE_BYTE:
            if (dataTypeSize == 4) {
                throw new RuntimeException(PropertyUtil.getString("TIFFImageEncoder2"));
            }
            break;
        case DataBuffer.TYPE_SHORT:
        case DataBuffer.TYPE_USHORT:
            if (dataTypeSize != 16) {
                throw new RuntimeException(PropertyUtil.getString("TIFFImageEncoder3"));
            }
            break;
        case DataBuffer.TYPE_INT:
        case DataBuffer.TYPE_FLOAT:
            if (dataTypeSize != 32) {
                throw new RuntimeException(PropertyUtil.getString("TIFFImageEncoder4"));
            }
            break;
        default:
            throw new RuntimeException(PropertyUtil.getString("TIFFImageEncoder5"));
        }

        if (colorModel instanceof IndexColorModel && dataType != DataBuffer.TYPE_BYTE) {
            // Don't support (unsigned) short palette-color images.
            throw new RuntimeException(PropertyUtil.getString("TIFFImageEncoder6"));
        }
    }