Png.png.unfilter.row: def of gralha-png-decode@0.1.0.1 Import: import gralha-png-decode@0.1.0.1/png.bend as Png Lines 70-78 of gralha-png-decode@0.1.0.1/png.bend: https://jend.leeeet.dev/read.txt?path=gralha-png-decode@0.1.0.1/png.bend&start_line=70&end_line=78 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 def png.unfilter.row(n: Nat, +raw: Bin.Bytes, +at: U32, +x: U32, +stride: U32, +bpp: U32, +kind: U32, +out: Bin.Bytes) -> Bin.Bytes: match n: case 0n: out case 1n+d: +pos = Bin.bytes.size(out) +a = U.choose(U32, U32.is_ge(x, bpp), Bin.bytes.get(out, (pos - bpp : U32)), 0) +b = U.choose(U32, U32.is_ge(pos, stride), Bin.bytes.get(out, (pos - stride : U32)), 0) +c = U.choose(U32, U32.is_ge(x, bpp) && U32.is_ge(pos, stride), Bin.bytes.get(out, (pos - stride - bpp : U32)), 0) png.unfilter.row(d, raw, U32.inc(at), U32.inc(x), stride, bpp, kind, Bin.bytes.push(out, ((Bin.bytes.get(raw, at) + png.predict(kind, a, b, c)) % 256 : U32))) Uses (14): https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Bool.and https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=Nat https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32 https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.add https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.inc https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.is_ge https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.mod https://jend.leeeet.dev/definition.txt?path=Base/base.bend&name=U32.sub https://jend.leeeet.dev/definition.txt?path=gralha-bytes@0.1.0.1/bytes.bend&name=Bytes https://jend.leeeet.dev/definition.txt?path=gralha-bytes@0.1.0.1/bytes.bend&name=bytes.get https://jend.leeeet.dev/definition.txt?path=gralha-bytes@0.1.0.1/bytes.bend&name=bytes.push https://jend.leeeet.dev/definition.txt?path=gralha-bytes@0.1.0.1/bytes.bend&name=bytes.size https://jend.leeeet.dev/definition.txt?path=gralha-png-decode@0.1.0.1/png.bend&name=png.predict https://jend.leeeet.dev/definition.txt?path=gralha-text-scan@0.1.0.1/scan.bend&name=choose