/*
@see http://www.w3.org/TR/PNG-Chunks.html

Color    Allowed      Interpretation
Type     Bit Depths
0       1,2,4,8,16  Each pixel is a grayscale sample.
2       8,16        Each pixel is an R,G,B triple.
3       1,2,4,8     Each pixel is a palette index;
a PLTE chunk must appear.
4       8,16        Each pixel is a grayscale sample,
followed by an alpha sample.
6       8,16        Each pixel is an R,G,B triple,
followed by an alpha sample.
 /*
PNG filter method types

@see http://www.w3.org/TR/PNG-Filters.html
@see http://www.libpng.org/pub/png/book/chapter09.html

This is what the value 'Predictor' in decode params relates to

15 is "optimal prediction", which means the prediction algorithm can change from line to line.
In that case, you actually have to read the first byte off each line for the prediction algorthim (which should be 0-4, corresponding to PDF 10-14) and select the appropriate unprediction algorithm based on that byte.

0       None
1       Sub
2       Up
3       Average
4       Paeth
function adler32(array, param) {
    var adler = 1;
    var s1 = adler & 0xffff,
        s2 = adler >>> 16 & 0xffff;
    var len = array.length;
    var tlen;
    var i = 0;

    while (len > 0) {
      tlen = len > param ? param : len;
      len -= tlen;

      do {
        s1 += array[i++];
        s2 += s1;
      } while (--tlen);

      s1 %= 65521;
      s2 %= 65521;
    }

    return (s2 << 16 | s1) >>> 0;
  }