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

◆ load_image_file()

MAYAFLUX_API std::shared_ptr< Buffers::TextureBuffer > MayaFlux::load_image_file ( const std::string &  filepath)

Loads an image file into a TextureBuffer.

Parameters
filepathPath to the image file to load
Returns
Shared pointer to loaded TextureBuffer, or nullptr on failure

Supports common image formats such as PNG, JPEG, BMP, TGA, PSD, GIF, HDR, PIC, and PNM. Returns nullptr on failure with error details logged to stderr.

Definition at line 117 of file Depot.cpp.

118{
119 IO::ImageReader reader;
120
121 if (!reader.open(filepath)) {
122 MF_ERROR(Journal::Component::API, Journal::Context::FileIO,
123 "Failed to open image: {}", filepath);
124 return nullptr;
125 }
126
127 auto texture_buffer = reader.create_texture_buffer();
128
129 if (!texture_buffer) {
130 MF_ERROR(Journal::Component::API, Journal::Context::FileIO,
131 "Failed to create texture buffer from: {}", filepath);
132 return nullptr;
133 }
134
135 MF_INFO(Journal::Component::API, Journal::Context::FileIO,
136 "Loaded image: {} ({}x{})",
137 fs::path(filepath).filename().string(),
138 texture_buffer->get_width(),
139 texture_buffer->get_height());
140
141 return texture_buffer;
142}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
std::shared_ptr< Buffers::TextureBuffer > create_texture_buffer()
Create a VKBuffer containing the loaded image pixel data.
bool open(const std::string &filepath, FileReadOptions options=FileReadOptions::ALL) override
Open a file for reading.
File reader for image formats (PNG, JPG, BMP, TGA, etc.)

References MayaFlux::Journal::API, MayaFlux::IO::ImageReader::create_texture_buffer(), MayaFlux::Journal::FileIO, MF_ERROR, MF_INFO, and MayaFlux::IO::ImageReader::open().

Referenced by MayaFlux::Creator::load_buffer().

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