public void setBitDepth(int bitDepth) {
            if (bitDepth != 1 && bitDepth != 2 && bitDepth != 4 &&
                bitDepth != 8 && bitDepth != 16) {
                throw new IllegalArgumentException();
            }
            this.bitDepth = bitDepth;
            bitDepthSet = true;
        }
Sets the desired bit depth for a grayscale image.  The bit
depth must be one of 1, 2, 4, 8, or 16.

<p> When encoding a source image of a greater bit depth,
pixel values will be clamped to the smaller range after
shifting by the value given by <code>getBitShift()</code>.
When encoding a source image of a smaller bit depth, pixel
values will be shifted and left-filled with zeroes.
plugins/svg-plugin/batik-codec-fix/src/main/java/org/apache/batik/ext/awt/image/codec/png/PNGEncodeParam.java