From b96dd619fe0bc09f31da8bf23f195a2a9916b839 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Tue, 2 Nov 2021 11:56:23 +0200 Subject: [PATCH] Add a function to detect image signature without creating a loader --- source/graphics/imageloader.cpp | 9 +++++++++ source/graphics/imageloader.h | 1 + 2 files changed, 10 insertions(+) diff --git a/source/graphics/imageloader.cpp b/source/graphics/imageloader.cpp index d2d3ef9..859a34c 100644 --- a/source/graphics/imageloader.cpp +++ b/source/graphics/imageloader.cpp @@ -32,6 +32,15 @@ ImageLoader::~ImageLoader() delete source; } +bool ImageLoader::detect_signature(const std::string &sig) +{ + Registry ®istry = get_registry(); + for(list::const_iterator i=registry.loaders.begin(); i!=registry.loaders.end(); ++i) + if((*i)->detect(sig)) + return true; + return false; +} + ImageLoader *ImageLoader::open_file(const string &fn) { try diff --git a/source/graphics/imageloader.h b/source/graphics/imageloader.h index 1ad6cc8..fbfd4d6 100644 --- a/source/graphics/imageloader.h +++ b/source/graphics/imageloader.h @@ -71,6 +71,7 @@ protected: public: virtual ~ImageLoader(); + static bool detect_signature(const std::string &); static ImageLoader *open_file(const std::string &); static ImageLoader *open_io(IO::Seekable &); -- 2.45.2