Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
io_utils.cpp File Reference
#include "DataIO/io_utils.h"
#include "DataIO/EXR/ExrFileReader.h"
#include "DataIO/EXR/ExrFileWriter.h"
#include "Frame/frame_utils.h"
#include "Frame/RegularPicture.h"
#include "Frame/PictureMeta.h"
#include "DataIO/FileSystem/Path.h"
#include "DataIO/PfmFile.h"
#include "Math/TVector2.h"
#include "DataIO/sdl_picture_file_type.h"
#include "Utility/ByteBuffer.h"
#include "Common/ThirdParty/lib_stb.h"
#include <Common/assertion.h>
#include <Common/logging.h>
#include <Common/profiling.h>
#include <Common/io_exceptions.h>
#include <fstream>
#include <sstream>
#include <climits>
#include <type_traits>

Namespaces

namespace  ph
 The root for all renderer implementations.
 
namespace  ph::io_utils
 Helpers for data I/O.
 
namespace  ph::io_utils::detail
 

Functions

 ph::io_utils::PH_DEFINE_INTERNAL_LOG_GROUP (IOUtils, DataIO)
 
bool ph::io_utils::detail::init_picture_IO ()
 
std::string ph::io_utils::load_text (const Path &filePath)
 Read the whole file as a formatted string.
 
bool ph::io_utils::has_LDR_support (std::string_view filenameExt)
 Checks whether the provided picture format supports LDR by filename extension.
 
bool ph::io_utils::has_HDR_support (std::string_view filenameExt)
 Checks whether the provided picture format supports HDR by filename extension.
 
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.
 
void ph::io_utils::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 ph::io_utils::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 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.
 
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).
 
void ph::io_utils::save_png (const LdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta=nullptr)
 Saves a frame in PNG format.
 
void ph::io_utils::save_jpg (const LdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta=nullptr)
 Saves a frame in JPG format.
 
void ph::io_utils::save_bmp (const LdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta=nullptr)
 Saves a frame in BMP format.
 
void ph::io_utils::save_tga (const LdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta=nullptr)
 Saves a frame in TGA format.
 
void ph::io_utils::save_hdr (const HdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta=nullptr)
 Saves a frame in HDR format.
 
void ph::io_utils::save_exr (const HdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta=nullptr)
 Saves a frame in EXR format.
 
void ph::io_utils::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 ph::io_utils::save_pfm (const HdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta=nullptr)
 Saves a frame in PFM format.
 
void ph::io_utils::save_exr (const HdrRgbFrame &frame, ByteBuffer &buffer, const PictureMeta *meta=nullptr)
 Saves a frame in EXR format to memory.
 
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.
 
RegularPicture ph::io_utils::load_LDR_picture (const Path &picturePath, std::size_t layerIdx)
 
RegularPicture ph::io_utils::load_HDR_picture (const Path &picturePath, std::size_t layerIdx)