Assembles a PNG chunk with length, type, data, and CRC32 checksum over type and data.
function chunk(type: string, data: Uint8Array): Uint8Array {
const typeB = TYPE_BYTES(type);
const crcSrc = concat([typeB, data]);
return concat([u32be(data.length), typeB, data, u32be(crc32(crcSrc))]);
}
See the full source, get the GitHub permalink, and search 40K more like it.
Get a free API key