interface PngChunkUnknown

Generic PNG chunk structure.

Each PNG chunk consists of a 4-byte length field, 4-byte type field, variable-length data, and 4-byte CRC checksum. The length field specifies the number of bytes in the data field.

Examples

Creating a PNG chunk

import { assertEquals } from "@std/assert";
import type { PngChunkUnknown } from "@binstruct/png";

const chunk: PngChunkUnknown = {
  length: 13,
  type: new Uint8Array([73, 72, 68, 82]), // "IHDR"
  data: new Uint8Array([0, 0, 0, 1, 0, 0, 0, 1, 8, 2, 0, 0, 0]),
  crc: 0x12345678,
};

assertEquals(chunk.length, chunk.data.length);
assertEquals(chunk.type.length, 4);

Properties

length: number

Length of the data field in bytes (4-byte big-endian)

Type (4 bytes)

Data (variable length)

crc: number

CRC (4 bytes)

Usage

import { type PngChunkUnknown } from ".";