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 599 of file IOManager.cpp.

600{
601 auto reader = std::make_shared<IO::ImageReader>();
602
603 if (!reader->open(filepath)) {
605 "Failed to open image: {}", filepath);
606 return nullptr;
607 }
608
609 auto texture_buffer = reader->create_texture_buffer();
610
611 if (!texture_buffer) {
613 "Failed to create texture buffer from: {}", filepath);
614 return nullptr;
615 }
616
617 m_image_readers.push_back(std::move(reader));
618
620 "Loaded image: {} ({}x{})",
621 std::filesystem::path(filepath).filename().string(),
622 texture_buffer->get_width(),
623 texture_buffer->get_height());
624
625 return texture_buffer;
626}
#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.