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

◆ open()

bool MayaFlux::IO::ImageReader::open ( const std::string &  filepath,
FileReadOptions  options = FileReadOptions::ALL 
)
overridevirtual

Open a file for reading.

Parameters
filepathPath to the file.
optionsReading options (see FileReadOptions).
Returns
true if file was successfully opened.

Implements MayaFlux::IO::FileReader.

Definition at line 271 of file ImageReader.cpp.

272{
273 if (m_is_open) {
274 close();
275 }
276
277 if (!can_read(filepath)) {
278 m_last_error = "Unsupported image format: " + filepath;
280 return false;
281 }
282
283 auto resolved = resolve_path(filepath);
284
286
287 if (!m_image_data) {
288 m_last_error = "Failed to load image data";
289 return false;
290 }
291
292 m_filepath = filepath;
293 m_is_open = true;
294
296 "Opened image: {} ({}x{}, {} channels)",
297 filepath, m_image_data->width, m_image_data->height, m_image_data->channels);
298
299 return true;
300}
#define MF_INFO(comp, ctx,...)
#define MF_ERROR(comp, ctx,...)
static std::string resolve_path(const std::string &filepath)
Resolve a filepath against the project source root if not found as-is.
static std::optional< ImageData > load(const std::string &path, int desired_channels=4, std::optional< Kakshya::Region > region=std::nullopt)
Load image from file (static utility)
std::optional< ImageData > m_image_data
std::optional< Kakshya::Region > m_region
void close() override
Close the currently open file.
bool can_read(const std::string &filepath) const override
Check if a file can be read by this reader.
@ FileIO
Filesystem I/O operations.
@ IO
Networking, file handling, streaming.

References can_read(), close(), MayaFlux::Journal::FileIO, MayaFlux::Journal::IO, load(), m_desired_channels, m_filepath, m_image_data, m_is_open, m_last_error, m_region, MF_ERROR, MF_INFO, and MayaFlux::IO::FileReader::resolve_path().

+ Here is the call graph for this function: