# ZImage

class Tui::ZImage

  ZImage allows keeping terminal output in a memory buffer for later usage or to store and load.

  ZSymbol is copyable, movable, assignable and supports equality comparisons.

  It is undefined behaviour when a image with outstanding painter is moved from or access anything else than the assignment operators and destructor on the moved from state.

  Constructors

  `ZImage(const Tui::ZTerminal *terminal, int width, int height)>`

  Static Functions

  `ZTerminal *terminal, const QString &fileName)`
  `ZTerminal *terminal, QByteArray data)`

  Functions

  `height() const`
  `painter()`
  `peekAttributes(int x, int y) const`
  `peekBackground(int x, int y) const`
  `peekDecoration(int x, int y) const`
  `peekForground(int x, int y) const`
  `peekSoftwrapMarker(int x, int y) const`
  `peekText(int x, int y, int *left, int *right) const`
  `save(const QString &fileName) const`
  `saveToByteArray() const`
  `size() const`
  `swap(Tui::ZImage &other)`
  `width() const`

## Members

ZImage(const Tui::ZTerminal *terminal, int width, int height)

  Construct an empty image using terminal characteristics from `terminal` with the width `width` and height `height`.

std::unique_ptr<Tui::ZImage> fromFile(const Tui::ZTerminal *terminal, const QString &fileName)

  Load an terminal image from the file named `fileName` and using the terminal characteristics from `terminal`.

  Returns nullptr if the file could not be read or parsing failed.

std::unique_ptr<Tui::ZImage> fromByteArray(const Tui::ZTerminal *terminal, QByteArray data)

  Load an terminal image from memory buffer `data` and using the terminal characteristics from `terminal`.

  Returns nullptr if the parsing failed.

int width() const

int height() const

QSize size() const

  Returns the size of the buffer.

bool save(const QString &fileName) const

  Save the contents of the image to file `fileName`.

  Returns true on success.

QByteArray saveToByteArray() const

  Save the contents of the image to a memory buffer and returns it as `QByteArray`.

QString peekText(int x, int y, int *left, int *right) const

  Get text of cluster covering the cell at position `x`, `y`.

  If not nullptr, `left` and `right` will be set to the left most respectivly right most cell covered by the cluster.

Tui::ZColor peekForground(int x, int y) const

  Get the foreground color of the cell at position `x`, `y`.

Tui::ZColor peekBackground(int x, int y) const

  Get the background color of the cell at position `x`, `y`.

Tui::ZColor peekDecoration(int x, int y) const

  Get the decoration color of the cell at position `x`, `y`.

bool peekSoftwrapMarker(int x, int y) const

  Returns true if the cell at position `x`, `y` contains a softwrap marker.

Tui::ZTextAttributes peekAttributes(int x, int y) const

  Get the attributes of the cell at position `x`, `y`.

Tui::ZPainter painter()

  Returns a `Tui::ZPainter` for painting on the image.

void swap(Tui::ZImage &other)

  Like `std::swap` for `Tui::ZImage`.