# `Plushie.Automation.Screenshot`
[🔗](https://github.com/plushie-ui/plushie-elixir/blob/v0.6.0/lib/plushie/automation/screenshot.ex#L1)

Pixel screenshot for automation and renderer inspection.

Captures pixel-level rendering data for visual regression testing.
The `:windowed` backend uses GPU rendering via iced/wgpu and captures real
RGBA pixel data through `iced::window::screenshot()`. The `:headless`
backend uses tiny-skia software rendering to produce real RGBA pixel data
without a display server. The wire protocol uses native msgpack binary
for pixel data (no base64 overhead) or base64 for JSON mode. The `:mock`
backend returns empty stubs (hash `""`, no pixel data) because mock
mode has no real renderer.

Note that headless screenshots use software rendering (tiny-skia), so
pixels will not match GPU-rendered output (`:windowed` backend) exactly.
Use headless screenshots for catching layout regressions and verifying
rendering pipeline correctness; use full screenshots for pixel-perfect
visual regression against GPU output.

`save_png/2` writes raw RGBA data as a minimal valid PNG file using
pure Elixir (`:zlib` for deflate, `:erlang.crc32` for chunk CRCs).

# `t`

```elixir
@type t() :: %Plushie.Automation.Screenshot{
  backend: Plushie.Automation.backend_mode() | nil,
  hash: String.t(),
  name: String.t(),
  rgba_data: binary() | nil,
  size: {non_neg_integer(), non_neg_integer()}
}
```

# `from_response`

```elixir
@spec from_response(
  msg :: map(),
  format :: Plushie.Protocol.format(),
  backend :: Plushie.Automation.backend_mode() | nil
) :: t()
```

Builds a screenshot from a renderer `screenshot_response` message.

# `save_png`

```elixir
@spec save_png(screenshot :: t(), path :: String.t()) :: :ok
```

Save the screenshot as a PNG file.

Writes a minimal but valid PNG with 8-bit RGBA color. Returns `:ok`.
No-op when `rgba_data` is nil (mock backend stubs).

---

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