MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ write_hdr()

bool MayaFlux::IO::STBImageWriter::write_hdr ( const std::string &  filepath,
const ImageData data 
)
private

Definition at line 307 of file STBImageWriter.cpp.

308{
309 const auto* src = data.as_float();
310 if (!src) {
311 m_last_error = "HDR requires float ImageData";
313 return false;
314 }
315
316 if (data.channels != 3 && data.channels != 4) {
317 m_last_error = "HDR supports only 3 or 4 channels (got "
318 + std::to_string(data.channels) + ")";
320 return false;
321 }
322
323 std::vector<uint8_t> encoded;
324 const int ok = stbi_write_hdr_to_func(
325 &stbi_memory_writer,
326 &encoded,
327 static_cast<int>(data.width),
328 static_cast<int>(data.height),
329 static_cast<int>(data.channels),
330 src->data());
331
332 if (!ok || encoded.empty()) {
333 m_last_error = "stbi_write_hdr_to_func failed";
335 return false;
336 }
337
338 if (!flush_to_disk(filepath, encoded)) {
339 m_last_error = "Failed to write HDR file: " + filepath;
341 return false;
342 }
343
345 "Wrote HDR: {} ({}x{}, {} channels)", filepath, data.width, data.height, data.channels);
346 return true;
347}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
@ FileIO
Filesystem I/O operations.
@ IO
Networking, file handling, streaming.

References MayaFlux::IO::ImageData::as_float(), MayaFlux::IO::ImageData::channels, MayaFlux::Journal::FileIO, MayaFlux::IO::ImageData::height, MayaFlux::Journal::IO, m_last_error, MF_ERROR, MF_INFO, and MayaFlux::IO::ImageData::width.

Referenced by write().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: