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

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