MayaFlux 0.4.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 351 of file IOManager.cpp.

352{
353 auto reader = std::make_shared<IO::ImageReader>();
354
355 if (!reader->open(filepath)) {
357 "Failed to open image: {}", filepath);
358 return nullptr;
359 }
360
361 auto texture_buffer = reader->create_texture_buffer();
362
363 if (!texture_buffer) {
365 "Failed to create texture buffer from: {}", filepath);
366 return nullptr;
367 }
368
369 m_image_readers.push_back(std::move(reader));
370
372 "Loaded image: {} ({}x{})",
373 std::filesystem::path(filepath).filename().string(),
374 texture_buffer->get_width(),
375 texture_buffer->get_height());
376
377 return texture_buffer;
378}
#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.