module Eagle::Codecs::PNG

Overview

PNG decoding and encoding. Decodes every standard color type and bit depth, palettes and Adam7 interlacing. Encodes 8-bit RGBA.

Defined in:

eagle/assets/codecs/png.cr

Constant Summary

SIGNATURE = Bytes[137, 80, 78, 71, 13, 10, 26, 10]

The eight bytes every PNG file starts with.

Class Method Summary

Class Method Detail

def self.crc32(data : Bytes, crc : UInt32 = 0_u32) : UInt32 #

CRC-32 as used by PNG chunks.


def self.decode(data : Bytes) : Image #

Decodes PNG bytes into an RGBA image. Raises AssetError on corrupt or unsupported data.


def self.encode(img : Image, level : Int32 = 6) : Bytes #

Encodes an image as an RGBA PNG. level is the zlib compression level from 0 to 9.


def self.png?(data : Bytes) : Bool #

True when data starts with the PNG signature.