1 #ifndef MSP_GRAPHICS_IMAGELOADER_H_
2 #define MSP_GRAPHICS_IMAGELOADER_H_
9 class unsupported_image_format: public std::runtime_error
12 unsupported_image_format(const std::string &w): std::runtime_error(w) { }
13 virtual ~unsupported_image_format() throw() { }
16 class bad_image_data: public std::runtime_error
19 bad_image_data(const std::string &w): std::runtime_error(w) { }
20 virtual ~bad_image_data() throw() { }
40 virtual ~RegisterBase() { }
42 virtual unsigned get_signature_size() const = 0;
43 virtual bool detect(const std::string &) const = 0;
44 virtual ImageLoader *create(IO::Seekable &) const = 0;
48 class RegisteredLoader: public RegisterBase
51 virtual unsigned get_signature_size() const { return T::get_signature_size(); }
52 virtual bool detect(const std::string &s) const { return T::detect(s); }
53 virtual ImageLoader *create(IO::Seekable &io) const { return new T(io); }
58 std::list<RegisterBase *> loaders;
72 virtual ~ImageLoader();
74 static ImageLoader *open_file(const std::string &);
75 static ImageLoader *open_io(IO::Seekable &);
77 virtual void load(Image::Data &);
78 virtual void load_headers(Image::Data &);
80 virtual void load_headers_(Image::Data &) = 0;
81 virtual void load_pixels_(Image::Data &) = 0;
84 State get_state() const { return state; }
87 static void register_loader();
89 static Registry &get_registry();
91 static bool signature_size_compare(RegisterBase *, RegisterBase *);
95 void ImageLoader::register_loader()
97 Registry ®istry = get_registry();
98 registry.loaders.push_back(new RegisteredLoader<T>);
99 registry.changed = true;
102 } // namespace Graphics