module PNG

Defined in:

png.cr
png/canvas.cr
png/chunk.cr
png/colors.cr
png/colors/gray.cr
png/colors/gray_alpha.cr
png/colors/hsv.cr
png/colors/rgb.cr
png/colors/rgba.cr
png/enums/color_type.cr
png/enums/compression_method.cr
png/enums/filter_method.cr
png/enums/filter_type.cr
png/enums/interlacing.cr
png/error.cr
png/filter.cr
png/header.cr
png/heuristic.cr
png/inflater.cr
png/packed_data.cr
png/palette.cr
png/parser.cr
png/pixel_size.cr
png/scanline.cr

Constant Summary

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

MAGIC is the first 8 bytes of a PNG file: "\x89PNG\r\n\x1a\n"

VERSION = {{ (`shards version`).stringify.chomp }}

Class Method Summary

Macro Summary

Class Method Detail

def self.read(path : String) : Canvas #

Reads a png stream returns a PNG::Canvas

canvas = PNG.read("examples/gradient.png")
canvas.header.color_type # => PNG::ColorType::RGB
canvas[0, 0]             # => Bytes[0, 255, 0]

[View source]
def self.read(io : IO) : Canvas #

Reads a png stream returns a PNG::Canvas

canvas = PNG.read("examples/gradient.png")
canvas.header.color_type # => PNG::ColorType::RGB
canvas[0, 0]             # => Bytes[0, 255, 0]

[View source]
def self.write(path : String, canvas : Canvas, &heuristic : Scanline | Nil, Scanline -> Scanline) #

Write a canvas to a .png file given a path

canvas = PNG::Canvas.new(255, 255)
0.upto(canvas.height - 1) do |y|
  0.upto(canvas.width - 1) do |x|
    canvas[x, y] = Bytes[x, 255, y]
  end
end

PNG.write("examples/gradient.png", canvas)

[View source]
def self.write(io : IO, canvas : Canvas, &heuristic : Scanline | Nil, Scanline -> Scanline) #

Write a canvas to a given io in png format.


[View source]
def self.write(path : String, canvas : Canvas) #

[View source]
def self.write(io : IO, canvas : Canvas) #

[View source]

Macro Detail

macro debug(args) #

Only logs messages if built with -Dpng-debug


[View source]