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 304 of file STBImageWriter.cpp.

305{
306 const auto* src = data.as_float();
307 if (!src) {
308 m_last_error = "HDR requires float ImageData";
310 return false;
311 }
312
313 if (data.channels != 3 && data.channels != 4) {
314 m_last_error = "HDR supports only 3 or 4 channels (got "
315 + std::to_string(data.channels) + ")";
317 return false;
318 }
319
320 std::vector<uint8_t> encoded;
321 const int ok = stbi_write_hdr_to_func(
322 &stbi_memory_writer,
323 &encoded,
324 static_cast<int>(data.width),
325 static_cast<int>(data.height),
326 static_cast<int>(data.channels),
327 src->data());
328
329 if (!ok || encoded.empty()) {
330 m_last_error = "stbi_write_hdr_to_func failed";
332 return false;
333 }
334
335 if (!flush_to_disk(filepath, encoded)) {
336 m_last_error = "Failed to write HDR file: " + filepath;
338 return false;
339 }
340
342 "Wrote HDR: {} ({}x{}, {} channels)", filepath, data.width, data.height, data.channels);
343 return true;
344}
#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: