         [ unknown-color-type ]
     } case ;
 
+: filter-png ( groups loading-png -- byte-array )
+    filter-method>> {
+        { filter-none [ reverse-png-filter ] }
+        [ unknown-filter-method ]
+    } case ;
+
 : png-image-bytes ( loading-png -- byte-array )
-    [ inflate-data ] [ png-group-width ] bi group
-    reverse-png-filter ;
+    [ [ inflate-data ] [ png-group-width ] bi group ]
+    [ filter-png ] bi ;
 
 : decode-greyscale ( loading-png -- loading-png )
     unimplemented-color-type ;

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

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


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 ; 
