# `NestGen2.Image`
[🔗](https://github.com/integration-technology/nest_gen2_sdk/blob/v0.6.6/lib/nest_gen2/image.ex#L1)

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.

# `color`

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

# `rgb`

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

# `t`

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

# `color`

```elixir
@spec color(color()) :: rgb()
```

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

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

# `from_raw`

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

Wraps raw BGRX pixel data.

# `new`

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

An image filled with one colour.

# `rgb`

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

Builds a colour tuple.

# `row`

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

Row `y` of the image as a binary.

# `to_png`

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

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

---

*Consult [api-reference.md](api-reference.md) for complete listing*
