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

◆ write_tga()

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

Definition at line 272 of file STBImageWriter.cpp.

273{
274 const auto* src = data.as_uint8();
275 if (!src) {
276 m_last_error = "TGA requires uint8 ImageData";
278 return false;
279 }
280
281 std::vector<uint8_t> encoded;
282 const int ok = stbi_write_tga_to_func(
283 &stbi_memory_writer,
284 &encoded,
285 static_cast<int>(data.width),
286 static_cast<int>(data.height),
287 static_cast<int>(data.channels),
288 src->data());
289
290 if (!ok || encoded.empty()) {
291 m_last_error = "stbi_write_tga_to_func failed";
293 return false;
294 }
295
296 if (!flush_to_disk(filepath, encoded)) {
297 m_last_error = "Failed to write TGA file: " + filepath;
299 return false;
300 }
301
303 "Wrote TGA: {} ({}x{}, {} channels)", filepath, data.width, data.height, data.channels);
304 return true;
305}
#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: