     chunks
     width height bit-depth color-type compression-method
     filter-method interlace-method uncompressed ;
+
+CONSTANT: filter-none 0
+CONSTANT: filter-sub 1
+CONSTANT: filter-up 2
+CONSTANT: filter-average 3
+CONSTANT: filter-paeth 4
+
+CONSTANT: greyscale 0
+CONSTANT: truecolor 2
+CONSTANT: indexed-color 3
+CONSTANT: greyscale-alpha 4
+CONSTANT: truecolor-alpha 6
 
 : <loading-png> ( -- image )
     loading-png new


: decode-png ( loading-png -- loading-png ) 
    dup color-type>> {
        { 0 [ validate-greyscale decode-greyscale ] }
        { 2 [ validate-truecolor decode-truecolor ] }
        { 3 [ validate-indexed-color decode-indexed-color ] }
        { 4 [ validate-greyscale-alpha decode-greyscale-alpha ] }
        { 6 [ validate-truecolor-alpha decode-truecolor-alpha ] }
        [ unknown-color-type ]
    } case ;



ERROR: unknown-color-type n ;
ERROR: unimplemented-color-type image ;
ERROR: unknown-filter-method image ;

: inflate-data ( loading-png -- bytes )
    find-compressed-bytes zlib-inflate ; 
