class

PNG::Canvas

Inherits Drawable / Reference / Object

A canvas holds all of the PNG data including the header and other chunk information

Constructors

new(width : UInt32, height : UInt32, palette : PNG::Palette | Nil = nil)
Source
new(header : PNG::Header, data : Bytes | Nil = nil, palette : PNG::Palette | Nil = nil)
Source

Class methods

make(width : UInt32, height : UInt32, palette : Palette | Nil = nil, &)
Source
make(header : Header, palette : Palette | Nil = nil, &)
Source

Instance methods

[](x : UInt32, y : UInt32)

Get the data at x, y into the canvas. This returns the Bytes that represent the pixel.

Source
[](x : Number, y : Number)

Get the data at x, y into the canvas. This returns the Bytes that represent the pixel.

Source
[]=(x : UInt32, y : UInt32, c : Int, value : UInt8)

Set an individual channel in a color at x,y

Source
[]=(x : UInt32, y : UInt32, values : Indexable(UInt8))

Set the pixel at x, y on the canvas via bytes that correspond to the color type and bit depth.

For example, an image with 8bits per channel in RGB (PNG::ColorType::TrueColor) would be set with 3 bytes: canvas[0, 0] = Bytes[255, 0, 255]

A canvas with 16bits in RGB would accept 6 bytes, (2 bytes per channel): canvas[0, 0] = Bytes[255, 255, 0, 0, 255, 255]

Source
[]=(x, y, values : Indexable(UInt8))
Source
[]=(x, y, values : Indexable(UInt16))
Source
[]=(x, y, values : Indexable(Number))
Source
[]=(x : Number, y : Number, value : Int)
Source
bg_color
Source
bg_color=(bg_color : Bytes | Nil)
Source
bit_depth(*args, **options)
Source
bit_depth(*args, **options, &)
Source
bit_index(x : UInt32, y : UInt32)

Calculates the index into the canvas that a value would be at, accounting for padding that would exist at the end of a scanline where bit depth < 8

Source
bits_per_pixel(*args, **options)
Source
bits_per_pixel(*args, **options, &)
Source
byte_index(x : UInt32, y : UInt32)
Source
bytes_per_pixel(*args, **options)
Source
bytes_per_pixel(*args, **options, &)
Source
bytes_per_row(*args, **options)
Source
bytes_per_row(*args, **options, &)
Source
clone

Return a deep clone of this canvas

Source
color(x, y) : Enumerable

Get the color at x, y

Source
color_type(*args, **options)
Source
color_type(*args, **options, &)
Source
copy_ancilarry(to : Canvas)

Copy the ancillarry data to a new canvas

Source
crop(start_x : Int, start_y : Int, end_x : Int, end_y : Int)

Crop a canvas in absolute coordinates

Source
data
Source
data=(data : Bytes)
Source
gama
Source
gama=(gama : UInt32 | Nil)
Source
header
Source
header=(header : Header)
Source
height(*args, **options)
Source
height(*args, **options, &)
Source
interlaced?
Source
last_modified
Source
last_modified=(last_modified : Time | Nil)
Source
palette
Source
palette=(palette : Palette | Nil)
Source
pixel_size
Source
pixel_size=(pixel_size : PixelSize | Nil)
Source
resize_bilinear(width, height)
Source
resize_nearest_neighbor(width, height)
Source
scanline(y)

Return the bytes corresponding to scanline

Source
set_color(x, y, color : Enumerable)

Set a color at x, y

Source
transparency
Source
transparency=(transparency : Bytes | Nil)
Source
width(*args, **options)
Source
width(*args, **options, &)
Source