From 4f2ac0c163d3c57738b1e75f7b5a58e702d1b18a Mon Sep 17 00:00:00 2001 From: Wojciech Jarosz Date: Sun, 25 Feb 2024 22:51:26 +1300 Subject: [PATCH] multi-image load --- src/app.cpp | 15 ++++++--------- src/app.h | 2 +- 2 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/app.cpp b/src/app.cpp index d37289c..e4edbdb 100644 --- a/src/app.cpp +++ b/src/app.cpp @@ -288,7 +288,7 @@ HDRViewApp::HDRViewApp() { vector arg(count); for (int i = 0; i < count; ++i) arg[i] = filenames[i]; - hdrview()->drop_event(arg); + hdrview()->load_images(arg); }); }; #endif @@ -592,17 +592,18 @@ void HDRViewApp::save_as(const string &filename) const } } -void HDRViewApp::drop_event(const std::vector &filenames) +void HDRViewApp::load_images(const std::vector &filenames) { for (auto f : filenames) { - spdlog::trace("dropped file '{}'", f); auto formats = Image::loadable_formats(); if (formats.find(get_extension(f)) != formats.end()) { std::ifstream is{f, std::ios_base::binary}; load_image(is, f); } + else + spdlog::debug("Skipping unsupported file '{}'", f); } } @@ -624,13 +625,9 @@ void HDRViewApp::open_image() #else string extensions = fmt::format("*.{}", fmt::join(Image::loadable_formats(), " *.")); - auto result = pfd::open_file("Open image", "", {"Image files", extensions}).result(); - if (!result.empty()) - { - std::ifstream is{result.front(), std::ios_base::binary}; - load_image(is, result.front()); - } + load_images(pfd::open_file("Open image", "", {"Image files", extensions}, pfd::opt::multiselect).result()); #endif + if (auto img = current_image()) spdlog::trace("Loaded image of size: {}\n", img->size()); } diff --git a/src/app.h b/src/app.h index 9e24f9b..d787f07 100644 --- a/src/app.h +++ b/src/app.h @@ -39,7 +39,7 @@ class HDRViewApp // loading, saving, and closing images //----------------------------------------------------------------------------- void open_image(); - void drop_event(const std::vector &filenames); + void load_images(const std::vector &filenames); void load_image(std::istream &is, const string &filename); void save_as(const string &filename) const; void close_image();