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

◆ write_bmp()

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

Definition at line 234 of file STBImageWriter.cpp.

235{
236 const auto* src = data.as_uint8();
237 if (!src) {
238 m_last_error = "BMP requires uint8 ImageData";
240 return false;
241 }
242
243 std::vector<uint8_t> encoded;
244 const int ok = stbi_write_bmp_to_func(
245 &stbi_memory_writer,
246 &encoded,
247 static_cast<int>(data.width),
248 static_cast<int>(data.height),
249 static_cast<int>(data.channels),
250 src->data());
251
252 if (!ok || encoded.empty()) {
253 m_last_error = "stbi_write_bmp_to_func failed";
255 return false;
256 }
257
258 if (!flush_to_disk(filepath, encoded)) {
259 m_last_error = "Failed to write BMP file: " + filepath;
261 return false;
262 }
263
265 "Wrote BMP: {} ({}x{}, {} channels)", filepath, data.width, data.height, data.channels);
266 return true;
267}
#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_uint8(), 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: