def png.sample

gralha-png-decode@0.1.0.1 · png.bend:87

import gralha-png-decode@0.1.0.1/png.bend as Png
import Base
import gralha-text-scan@0.1.0.1/scan.bend as U
import gralha-bytes@0.1.0.1/bytes.bend as Bin

87def png.sample(+raw: Bin.Bytes, +row: U32, +index: U32, +depth: U32) -> U32:
88  +bit = (index * depth : U32)
89  +at = (row + bit / 8 : U32)
90  U.branch(U32, U32.is_eq(depth, 16), _ => Bin.bytes.be(raw, at, 2n, 0), _ => U32.and(U32.shrn(Bin.bytes.get(raw, at), U32.to_nat((8 - depth - bit % 8 : U32))), (U32.shln(1, U32.to_nat(depth)) - 1 : U32)))

Uses (15)

Used by (1)