PNG I/O

inline std::pair<Image<RGB>, Image<float>> huira::read_image_png(const fs::path &filepath, bool read_alpha)

Reads a PNG file and returns linear RGB + alpha data.

Convenience overload that reads the file into memory and forwards to the buffer-based implementation.

inline std::pair<Image<RGB>, Image<float>> huira::read_image_png(const unsigned char *data, std::size_t size, bool read_alpha)

Reads a PNG from an in-memory buffer and returns linear RGB + alpha data.

Parameters:
  • data – Pointer to the PNG data in memory

  • size – Size of the data in bytes

  • read_alpha – Whether to load the alpha channel if present (default: true)

Returns:

A pair containing the linear RGB image and an optional alpha image.

inline std::pair<Image<float>, Image<float>> huira::read_image_png_mono(const fs::path &filepath, bool read_alpha)

Reads a PNG file and returns linear mono + alpha data.

Convenience overload that reads the file into memory and forwards to the buffer-based implementation.

inline std::pair<Image<float>, Image<float>> huira::read_image_png_mono(const unsigned char *data, std::size_t size, bool read_alpha)

Reads a PNG from an in-memory buffer and returns linear mono + alpha data.

Parameters:
  • data – Pointer to the PNG data in memory

  • size – Size of the data in bytes

  • read_alpha – Whether to load the alpha channel if present (default: true)

Returns:

A pair containing the linear mono image and an optional alpha image.

inline void huira::write_image_png(const fs::path &filepath, const Image<RGB> &image, int bit_depth = 8)
inline void huira::write_image_png(const fs::path &filepath, const Image<RGB> &image, const Image<float> &alpha, int bit_depth = 8)
inline void huira::write_image_png(const fs::path &filepath, const Image<float> &image, int bit_depth = 8)
inline void huira::write_image_png(const fs::path &filepath, const Image<float> &image, const Image<float> &alpha, int bit_depth = 8)