From: Mikko Rasa Date: Tue, 2 Nov 2021 09:56:23 +0000 (+0200) Subject: Add a function to detect image signature without creating a loader X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=b96dd619fe0bc09f31da8bf23f195a2a9916b839;p=libs%2Fgui.git Add a function to detect image signature without creating a loader --- 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 &);