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

◆ load_image()

std::shared_ptr< Buffers::TextureBuffer > MayaFlux::IO::IOManager::load_image ( const std::string &  filepath)

Load an image file into a TextureBuffer.

Opens the file via ImageReader, decodes to RGBA8, and creates a TextureBuffer containing the pixel data. The reader is retained for the lifetime of IOManager.

Parameters
filepathPath to the image file (PNG, JPG, BMP, TGA, etc.).
Returns
TextureBuffer with pixel data, or nullptr on failure.

Definition at line 296 of file IOManager.cpp.

297{
298 auto reader = std::make_shared<IO::ImageReader>();
299
300 if (!reader->open(filepath)) {
302 "Failed to open image: {}", filepath);
303 return nullptr;
304 }
305
306 auto texture_buffer = reader->create_texture_buffer();
307
308 if (!texture_buffer) {
310 "Failed to create texture buffer from: {}", filepath);
311 return nullptr;
312 }
313
314 m_image_readers.push_back(std::move(reader));
315
317 "Loaded image: {} ({}x{})",
318 std::filesystem::path(filepath).filename().string(),
319 texture_buffer->get_width(),
320 texture_buffer->get_height());
321
322 return texture_buffer;
323}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
std::vector< std::shared_ptr< ImageReader > > m_image_readers
@ FileIO
Filesystem I/O operations.
@ API
MayaFlux/API Wrapper and convenience functions.

References MayaFlux::Journal::API, MayaFlux::Journal::FileIO, m_image_readers, MF_ERROR, and MF_INFO.