private static int paethPredictor(int a, int b, int c) {
        int p = a + b - c;
        int pa = Math.abs(p - a);
        int pb = Math.abs(p - b);
        int pc = Math.abs(p - c);

        if ((pa <= pb) && (pa <= pc)) {
            return a;
        } else if (pb <= pc) {
            return b;
        } else {
            return c;
        }
    }
A convenience method to create an instance of
<code>ComponentColorModel</code> suitable for use with the
given <code>SampleModel</code>.  The <code>SampleModel</code>
should have a data type of <code>DataBuffer.TYPE_BYTE</code>,
<code>TYPE_USHORT</code>, or <code>TYPE_INT</code> and between
1 and 4 bands.  Depending on the number of bands of the
<code>SampleModel</code>, either a gray, gray+alpha, rgb, or
rgb+alpha <code>ColorModel</code> is returned.
plugins/svg-plugin/batik-codec-fix/src/main/java/org/apache/batik/ext/awt/image/codec/png/PNGRed.java