Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
ph::io_utils Namespace Reference

Helpers for data I/O. More...

Namespaces

namespace  detail
 

Functions

 PH_DEFINE_INTERNAL_LOG_GROUP (IOUtils, DataIO)
 
std::string load_text (const Path &filePath)
 Read the whole file as a formatted string.
 
bool has_LDR_support (std::string_view filenameExt)
 Checks whether the provided picture format supports LDR by filename extension.
 
bool has_HDR_support (std::string_view filenameExt)
 Checks whether the provided picture format supports HDR by filename extension.
 
bool load_picture_meta (const Path &picturePath, PictureMeta *out_meta, math::Vector2S *out_sizePx=nullptr, std::size_t *out_numChannels=nullptr)
 Load general information that describes the picture. For most formats, this parses the image header without loading actual pixel data.
 
void save (const LdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta=nullptr)
 Saves a LDR frame to the specified file. Similar to save(4), except file name and format are deduced from path.
 
void save (const HdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta=nullptr)
 Saves a HDR frame to the specified file. Similar to save(4), except file name and format are deduced from path.
 
void save (const LdrRgbFrame &frame, const Path &fileDirectory, const std::string &name, EPictureFile format, const PictureMeta *meta=nullptr)
 Saves a LDR frame to the specified file. Notice that if the specified format is HDR, values will be promoted to higher precision types which can have extra storage cost.
 
void save (const HdrRgbFrame &frame, const Path &fileDirectory, const std::string &name, EPictureFile format, const PictureMeta *meta=nullptr)
 Saves a HDR frame to the specified file. Notice that if the specified format is LDR, values outside [0, 1] will be clamped (this may result in significant data loss depending on the values stored).
 
void save_png (const LdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta=nullptr)
 Saves a frame in PNG format.
 
void save_jpg (const LdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta=nullptr)
 Saves a frame in JPG format.
 
void save_bmp (const LdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta=nullptr)
 Saves a frame in BMP format.
 
void save_tga (const LdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta=nullptr)
 Saves a frame in TGA format.
 
void save_hdr (const HdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta=nullptr)
 Saves a frame in HDR format.
 
void save_exr (const HdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta=nullptr)
 Saves a frame in EXR format.
 
void save_exr_high_precision (const HdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta=nullptr)
 Saves a frame in EXR format with high precision encoding.
 
void save_pfm (const HdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta=nullptr)
 Saves a frame in PFM format.
 
void save_exr (const HdrRgbFrame &frame, ByteBuffer &buffer, const PictureMeta *meta=nullptr)
 Saves a frame in EXR format to memory.
 
RegularPicture load_picture (const Path &picturePath, std::size_t layerIdx=0)
 Loads common picture types from file. Format is deduced from filename extension. Tries to load the specified layer into a regular picture.
 
RegularPicture load_LDR_picture (const Path &picturePath, std::size_t layerIdx)
 
RegularPicture load_HDR_picture (const Path &picturePath, std::size_t layerIdx)
 

Detailed Description

Helpers for data I/O.

Function Documentation

◆ has_HDR_support()

bool ph::io_utils::has_HDR_support ( std::string_view filenameExt)

Checks whether the provided picture format supports HDR by filename extension.

Note that the check is from the engine's perspective–a format may not support HDR here while it actually does from its original spec.

Parameters
filenameExtFilename extension (the leading dot should be included).

◆ has_LDR_support()

bool ph::io_utils::has_LDR_support ( std::string_view filenameExt)

Checks whether the provided picture format supports LDR by filename extension.

Note that the check is from the engine's perspective–a format may not support LDR here while it actually does from its original spec.

Parameters
filenameExtFilename extension (the leading dot should be included).

◆ load_HDR_picture()

RegularPicture ph::io_utils::load_HDR_picture ( const Path & picturePath,
std::size_t layerIdx )

◆ load_LDR_picture()

RegularPicture ph::io_utils::load_LDR_picture ( const Path & picturePath,
std::size_t layerIdx )

◆ load_picture()

RegularPicture ph::io_utils::load_picture ( const Path & picturePath,
std::size_t layerIdx = 0 )

Loads common picture types from file. Format is deduced from filename extension. Tries to load the specified layer into a regular picture.

Parameters
layerIdxIndex of the layer to load. For most picture type, left the layer index as default should be good.
Exceptions
FileIOErrorIf any error occurred.

◆ load_picture_meta()

bool ph::io_utils::load_picture_meta ( const Path & picturePath,
PictureMeta * out_meta,
math::Vector2S * out_sizePx = nullptr,
std::size_t * out_numChannels = nullptr )

Load general information that describes the picture. For most formats, this parses the image header without loading actual pixel data.

Parameters
out_metaStores the loaded picture meta. Can be set to nullptr if only the selected information is required (use the more specific output variable instead).

◆ load_text()

std::string ph::io_utils::load_text ( const Path & filePath)

Read the whole file as a formatted string.

◆ PH_DEFINE_INTERNAL_LOG_GROUP()

ph::io_utils::PH_DEFINE_INTERNAL_LOG_GROUP ( IOUtils ,
DataIO  )

◆ save() [1/4]

void ph::io_utils::save ( const HdrRgbFrame & frame,
const Path & fileDirectory,
const std::string & name,
EPictureFile format,
const PictureMeta * meta = nullptr )

Saves a HDR frame to the specified file. Notice that if the specified format is LDR, values outside [0, 1] will be clamped (this may result in significant data loss depending on the values stored).

Parameters
metaGeneral information for storing the frame as a picture. The information given may or may not be considered (depending on the file format).

◆ save() [2/4]

void ph::io_utils::save ( const HdrRgbFrame & frame,
const Path & filePath,
const PictureMeta * meta )

Saves a HDR frame to the specified file. Similar to save(4), except file name and format are deduced from path.

◆ save() [3/4]

void ph::io_utils::save ( const LdrRgbFrame & frame,
const Path & fileDirectory,
const std::string & name,
EPictureFile format,
const PictureMeta * meta = nullptr )

Saves a LDR frame to the specified file. Notice that if the specified format is HDR, values will be promoted to higher precision types which can have extra storage cost.

Parameters
metaGeneral information for storing the frame as a picture. The information given may or may not be considered (depending on the file format).

◆ save() [4/4]

void ph::io_utils::save ( const LdrRgbFrame & frame,
const Path & filePath,
const PictureMeta * meta )

Saves a LDR frame to the specified file. Similar to save(4), except file name and format are deduced from path.

◆ save_bmp()

void ph::io_utils::save_bmp ( const LdrRgbFrame & frame,
const Path & filePath,
const PictureMeta * meta )

Saves a frame in BMP format.

◆ save_exr() [1/2]

void ph::io_utils::save_exr ( const HdrRgbFrame & frame,
ByteBuffer & buffer,
const PictureMeta * meta )

Saves a frame in EXR format to memory.

◆ save_exr() [2/2]

void ph::io_utils::save_exr ( const HdrRgbFrame & frame,
const Path & filePath,
const PictureMeta * meta )

Saves a frame in EXR format.

◆ save_exr_high_precision()

void ph::io_utils::save_exr_high_precision ( const HdrRgbFrame & frame,
const Path & filePath,
const PictureMeta * meta )

Saves a frame in EXR format with high precision encoding.

◆ save_hdr()

void ph::io_utils::save_hdr ( const HdrRgbFrame & frame,
const Path & filePath,
const PictureMeta * meta )

Saves a frame in HDR format.

◆ save_jpg()

void ph::io_utils::save_jpg ( const LdrRgbFrame & frame,
const Path & filePath,
const PictureMeta * meta )

Saves a frame in JPG format.

◆ save_pfm()

void ph::io_utils::save_pfm ( const HdrRgbFrame & frame,
const Path & filePath,
const PictureMeta * meta )

Saves a frame in PFM format.

◆ save_png()

void ph::io_utils::save_png ( const LdrRgbFrame & frame,
const Path & filePath,
const PictureMeta * meta )

Saves a frame in PNG format.

◆ save_tga()

void ph::io_utils::save_tga ( const LdrRgbFrame & frame,
const Path & filePath,
const PictureMeta * meta )

Saves a frame in TGA format.