NestGen2.Image (nest_gen2 v0.6.6)

Copy Markdown View Source

A block of pixels in the framebuffer's own format: 4 bytes per pixel, BGRX.

Colours can be given as a hex string ("#1C1C1E", "1c1c1e") or an {red, green, blue} tuple of 0..255, anywhere the SDK takes a colour.

Summary

Functions

Normalises a colour to an {r, g, b} tuple.

Wraps raw BGRX pixel data.

An image filled with one colour.

Builds a colour tuple.

Row y of the image as a binary.

Encodes the image as a PNG (8-bit RGB), e.g. for a screenshot.

Types

color()

@type color() :: rgb() | String.t()

rgb()

@type rgb() :: {0..255, 0..255, 0..255}

t()

@type t() :: %NestGen2.Image{
  data: binary(),
  height: pos_integer(),
  width: pos_integer()
}

Functions

color(rgb)

@spec color(color()) :: rgb()

Normalises a colour to an {r, g, b} tuple.

iex> NestGen2.Image.color("#1C1C1E")
{28, 28, 30}

from_raw(width, height, data)

@spec from_raw(pos_integer(), pos_integer(), binary()) :: t()

Wraps raw BGRX pixel data.

new(width, height, color)

@spec new(pos_integer(), pos_integer(), color()) :: t()

An image filled with one colour.

rgb(r, g, b)

@spec rgb(0..255, 0..255, 0..255) :: rgb()

Builds a colour tuple.

row(image, y)

@spec row(t(), non_neg_integer()) :: binary()

Row y of the image as a binary.

to_png(image)

@spec to_png(t()) :: binary()

Encodes the image as a PNG (8-bit RGB), e.g. for a screenshot.