Photon Engine 2.0.0-beta
A physically based renderer.
Loading...
Searching...
No Matches
io_utils.h
Go to the documentation of this file.
1#pragma once
2
8#include "Frame/frame_fwd.h"
9#include "Math/math_fwd.h"
10#include "DataIO/EPictureFile.h"
11
12#include <Common/primitive_type.h>
13
14#include <cstddef>
15#include <string_view>
16#include <string>
17
18namespace ph { class Path; }
19namespace ph { class RegularPicture; }
20namespace ph { class RegularPictureFormat; }
21namespace ph { class PictureMeta; }
22namespace ph { class ByteBuffer; }
23
24namespace ph::io_utils
25{
26
29std::string load_text(const Path& filePath);
30
31// TODO: loadBytes()
32
40bool has_LDR_support(std::string_view filenameExt);
41
49bool has_HDR_support(std::string_view filenameExt);
50
58RegularPicture load_picture(const Path& picturePath, std::size_t layerIdx = 0);
59RegularPicture load_LDR_picture(const Path& picturePath, std::size_t layerIdx = 0);
60RegularPicture load_HDR_picture(const Path& picturePath, std::size_t layerIdx = 0);
62
69 const Path& picturePath,
70 PictureMeta* out_meta,
71 math::Vector2S* out_sizePx = nullptr,
72 std::size_t* out_numChannels = nullptr);
73
77void save(const LdrRgbFrame& frame, const Path& filePath, const PictureMeta* meta = nullptr);
78
82void save(const HdrRgbFrame& frame, const Path& filePath, const PictureMeta* meta = nullptr);
83
90void save(
91 const LdrRgbFrame& frame,
92 const Path& fileDirectory,
93 const std::string& name,
94 EPictureFile format,
95 const PictureMeta* meta = nullptr);
96
103void save(
104 const HdrRgbFrame& frame,
105 const Path& fileDirectory,
106 const std::string& name,
107 EPictureFile format,
108 const PictureMeta* meta = nullptr);
109
112void save_png(const LdrRgbFrame& frame, const Path& filePath, const PictureMeta* meta = nullptr);
113
116void save_jpg(const LdrRgbFrame& frame, const Path& filePath, const PictureMeta* meta = nullptr);
117
120void save_bmp(const LdrRgbFrame& frame, const Path& filePath, const PictureMeta* meta = nullptr);
121
124void save_tga(const LdrRgbFrame& frame, const Path& filePath, const PictureMeta* meta = nullptr);
125
128void save_hdr(const HdrRgbFrame& frame, const Path& filePath, const PictureMeta* meta = nullptr);
129
132void save_exr(const HdrRgbFrame& frame, const Path& filePath, const PictureMeta* meta = nullptr);
133
136void save_exr_high_precision(const HdrRgbFrame& frame, const Path& filePath, const PictureMeta* meta = nullptr);
137
140void save_pfm(const HdrRgbFrame& frame, const Path& filePath, const PictureMeta* meta = nullptr);
141
144void save_exr(const HdrRgbFrame& frame, ByteBuffer& buffer, const PictureMeta* meta = nullptr);
145
146namespace detail
147{
148
149bool init_picture_IO();
150
151}// end namespace detail
152
153}// end namespace ph::io_utils
bool init_picture_IO()
Definition io_utils.cpp:33
Helpers for data I/O.
Definition io_utils.cpp:26
bool has_LDR_support(const std::string_view filenameExt)
Checks whether the provided picture format supports LDR by filename extension.
Definition io_utils.cpp:401
RegularPicture load_LDR_picture(const Path &picturePath, std::size_t layerIdx)
Definition io_utils.cpp:296
void save_tga(const LdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta)
Saves a frame in TGA format.
Definition io_utils.cpp:651
std::string load_text(const Path &filePath)
Read the whole file as a formatted string.
Definition io_utils.cpp:242
void save_hdr(const HdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta)
Saves a frame in HDR format.
Definition io_utils.cpp:672
void 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 ...
Definition io_utils.cpp:473
void save_pfm(const HdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta)
Saves a frame in PFM format.
Definition io_utils.cpp:711
void save_png(const LdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta)
Saves a frame in PNG format.
Definition io_utils.cpp:583
void save_exr(const HdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta)
Saves a frame in EXR format.
Definition io_utils.cpp:693
void save_bmp(const LdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta)
Saves a frame in BMP format.
Definition io_utils.cpp:630
RegularPicture load_HDR_picture(const Path &picturePath, std::size_t layerIdx)
Definition io_utils.cpp:319
void save_jpg(const LdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta)
Saves a frame in JPG format.
Definition io_utils.cpp:605
RegularPicture load_picture(const Path &picturePath, std::size_t layerIdx)
Loads common picture types from file. Format is deduced from filename extension. Tries to load the sp...
Definition io_utils.cpp:257
void save_exr_high_precision(const HdrRgbFrame &frame, const Path &filePath, const PictureMeta *meta)
Saves a frame in EXR format with high precision encoding.
Definition io_utils.cpp:702
bool has_HDR_support(const std::string_view filenameExt)
Checks whether the provided picture format supports HDR by filename extension.
Definition io_utils.cpp:415
bool load_picture_meta(const Path &picturePath, PictureMeta *out_meta, math::Vector2S *out_sizePx, std::size_t *out_numChannels)
Load general information that describes the picture. For most formats, this parses the image header w...
Definition io_utils.cpp:425
TVector2< std::size_t > Vector2S
Definition math_fwd.h:48
The root for all renderer implementations.
Definition EEngineProject.h:6
TFrame< HdrComponent, 3 > HdrRgbFrame
Definition frame_fwd.h:17
TFrame< LdrComponent, 3 > LdrRgbFrame
Definition frame_fwd.h:16
EPictureFile
Definition EPictureFile.h:9