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

◆ save_image()

bool MayaFlux::IO::save_image ( const std::shared_ptr< Core::VKImage > &  image,
const std::string &  filepath,
const ImageWriteOptions options = {} 
)

Save a VKImage directly to disk via the ImageWriter registry.

Combines download_image() with ImageWriterRegistry::create_writer(). The file extension selects the writer. Format-variant compatibility is the writer's responsibility: saving a float VKImage as PNG will fail at the writer (uint8 mismatch), saving a uint8 VKImage as EXR will fail too.

Parameters
imageVKImage to save.
filepathDestination path with extension.
optionsFormat-specific writer options.
Returns
True on success.

Definition at line 148 of file ImageExport.cpp.

152{
153 auto data = download_image(image);
154 if (!data) {
155 return false;
156 }
157
158 auto writer = ImageWriterRegistry::instance().create_writer(filepath);
159 if (!writer) {
160 MF_ERROR(Journal::Component::IO, Journal::Context::FileIO,
161 "save_image: no writer registered for extension of '{}'", filepath);
162 return false;
163 }
164
165 const bool ok = writer->write(filepath, *data, options);
166 if (!ok) {
167 MF_ERROR(Journal::Component::IO, Journal::Context::FileIO,
168 "save_image: writer failed: {}", writer->get_last_error());
169 }
170 return ok;
171}
#define MF_ERROR(comp, ctx,...)
IO::ImageData image
std::optional< ImageData > download_image(const std::shared_ptr< Core::VKImage > &image)
Download pixel data from a GPU-resident VKImage into host ImageData.

References MayaFlux::IO::ImageWriterRegistry::create_writer(), download_image(), MayaFlux::Journal::FileIO, image, MayaFlux::IO::ImageWriterRegistry::instance(), MayaFlux::Journal::IO, and MF_ERROR.

Referenced by save_texture_buffer().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: