Skip to content

Commit

Permalink
multi-image load
Browse files Browse the repository at this point in the history
  • Loading branch information
wkjarosz committed Feb 25, 2024
1 parent a07565b commit 4f2ac0c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
15 changes: 6 additions & 9 deletions src/app.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ HDRViewApp::HDRViewApp()
{
vector<string> arg(count);
for (int i = 0; i < count; ++i) arg[i] = filenames[i];
hdrview()->drop_event(arg);
hdrview()->load_images(arg);
});
};
#endif
Expand Down Expand Up @@ -592,17 +592,18 @@ void HDRViewApp::save_as(const string &filename) const
}
}

void HDRViewApp::drop_event(const std::vector<std::string> &filenames)
void HDRViewApp::load_images(const std::vector<std::string> &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);
}
}

Expand All @@ -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());
}
Expand Down
2 changes: 1 addition & 1 deletion src/app.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ class HDRViewApp
// loading, saving, and closing images
//-----------------------------------------------------------------------------
void open_image();
void drop_event(const std::vector<std::string> &filenames);
void load_images(const std::vector<std::string> &filenames);
void load_image(std::istream &is, const string &filename);
void save_as(const string &filename) const;
void close_image();
Expand Down

0 comments on commit 4f2ac0c

Please sign in to comment.