Vocabulary
images.png

Inputs
byte-readeran object
loading-pngan object
widthan object
heightan object


Outputs
arrayan object


Definition


:: read-scanlines
( byte-reader loading-png width height -- array )
loading-png png-components-per-pixel :> #components
loading-png bit-depth>> :> bit-depth bit-depth :> depth!
#components width * :> count! #components bit-depth *
width * 8 align 8 /i :> stride height
[ stride 1 + byte-reader stream-read ] replicate
#components bit-depth 16 = [ 2 * ] when reverse-png-filter
bit-depth 16 = [ 8 depth! count 2 * count! ] when
<msb0-bit-reader> :> br height
[ count [ depth br read ] B{ } replicate-as 8 br align ]
replicate concat ;