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

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