 
 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 ; 

    chunks
    width height bit-depth color-type compression-method
    filter-method interlace-method uncompressed ;

: <loading-png> ( -- image )
    loading-png new


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

