class PNGChunks::PNGChunk

Overview

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

Defined in:

png-chunks.cr

Constructors

Instance Method Summary

Constructor Detail

def self.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)

[View source]

Instance Method Detail

def crc : UInt32 #

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


[View source]
def data : Bytes #

The chunk's data.


[View source]
def type #

The chunk's type as a string.


[View source]
def type_bytes : Bytes #

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


[View source]
def valid? : Bool #

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.


[View source]