(type: string, data: Uint8Array)
| 290 | } |
| 291 | |
| 292 | function chunk(type: string, data: Uint8Array): Buffer { |
| 293 | const body = Buffer.alloc(4 + data.length) |
| 294 | body.write(type, 0, 'ascii') |
| 295 | body.set(data, 4) |
| 296 | const out = Buffer.alloc(12 + data.length) |
| 297 | out.writeUInt32BE(data.length, 0) |
| 298 | body.copy(out, 4) |
| 299 | out.writeUInt32BE(crc32(body), 8 + data.length) |
| 300 | return out |
| 301 | } |
| 302 | |
| 303 | /** |
| 304 | * Encode an RGBA pixel buffer as PNG. Minimal encoder: 8-bit depth, |