 compression.inflate fry grouping images images.loader io
 io.binary io.encodings.ascii io.encodings.string kernel locals
 math math.bitwise math.ranges sequences sorting assocs
-math.functions math.order ;
+math.functions math.order byte-arrays ;
 QUALIFIED-WITH: bitstreams bs
 IN: images.png
 

            validate-greyscale-alpha decode-greyscale-alpha LA
        ] }
        { truecolor-alpha [
            validate-truecolor-alpha raw-bytes RGBA
        ] }
        [ unknown-color-type ]
    } case ;

    } case ;

: decode-greyscale ( loading-png -- byte-array )
    [ uncompress-bytes ] keep scale-greyscale ;

: decode-greyscale-alpha ( loading-image -- byte-array )
    [ uncompress-bytes ] [ bit-depth>> ] bi 16 = [
        4 group [ first4 [ swap ] 2dip 4array ] map B{ } concat-as
    ] when ;

