PNG file

PNG

Used in remaster for high-res textures.

struct Png

A class for reading and writing PNG files.

Public Functions

Png() = default

Default constructor for Png object.

inline Png(const std::filesystem::path &filename, bool flipv = false)

Constructor for Png object.

Parameters:
  • filename – Path to the PNG file.

  • flipv – Flag to indicate if the image should be flipped vertically.

inline auto width() const noexcept

Returns the width of the PNG image.

Returns:

Width of the PNG image

inline auto height() const noexcept

Returns the height of the PNG image.

Returns:

Height of the PNG image

inline auto begin() const noexcept

Returns an iterator to the beginning of the color data.

Returns:

An iterator pointing to the first element of the color data.

inline auto end() const noexcept

Returns an iterator to the end of the color data.

Returns:

An iterator pointing to the element past the end of the color data.

inline auto size() const noexcept

Returns the number of elements in the color data.

Returns:

The number of elements in the color data.

Public Static Functions

template<Color cT = Color32RGBA>
static inline std::optional<std::filesystem::path> save(const std::uint8_t *data, png_uint_32 width, png_uint_32 height, SaveSettings settings) noexcept

Saves an array of color data as a PNG image file.

Template Parameters:

cT – Color type

Parameters:
  • data – Array of color data

  • width – Width of the image

  • height – Height of the image

  • filename – Filename to save the PNG image as

  • title – Optional title for the PNG image

  • prefix – Optional prefix for the filename

Returns:

The saved filename or std::nullopt if saving failed

template<Color cT>
static inline std::optional<std::filesystem::path> save(const std::vector<cT> &data, png_uint_32 width, png_uint_32 height, SaveSettings settings) noexcept

Saves a vector of color data as a PNG image file.

Template Parameters:
  • cT – Color type

  • T – Variadic template parameters

Parameters:
  • data – Vector of color data

  • width – Width of the image

  • height – Height of the image

  • t – Variadic template parameters

Returns:

The saved filename or std::nullopt if saving failed

static inline std::optional<std::filesystem::path> save(const Png &data, png_uint_32 width, png_uint_32 height, SaveSettings settings) noexcept

Saves the color data of a Png object as a PNG image file.

Template Parameters:

T – Variadic template parameters

Parameters:
  • data – Png object

  • t – Variadic template parameters

Returns:

The saved filename or std::nullopt if saving failed

struct SaveSettings