class

PNGChunks::PNGChunk

Inherits Reference < Object

PNGChunk represents a single PNG chunk, which is effectively the pair of the type (such as IHDR) and the data.

Constructors

new(type_bytes : Slice(UInt8), data : Slice(UInt8))

Creates a new PNGChunk out of a type and data, both Bytes.

type_bytes = "IHDR".bytes
data = make_ihdr_bytes
chunk = PNGChunks::PNGChunk(type_bytes, data)

Instance methods

crc

The chunk's CRC32 checksum, calculated from the chunk's type and data.

data

The chunk's data.

type

The chunk's type as a string.

type_bytes

The chunk's type as Bytes. For example, IHDR is Bytes[0x49, 0x48, 0x44, 0x52].

valid?

A boolean representing whether the chunk is valid. A chunk is valid if its type is made up of ASCII letters (A-Z and a-z) and if its data will fit in a PNG's maximum chunk size.