]> git.tdb.fi Git - libs/gui.git/blobdiff - source/graphics/imageloader.h
Make the image loading code more modular
[libs/gui.git] / source / graphics / imageloader.h
diff --git a/source/graphics/imageloader.h b/source/graphics/imageloader.h
new file mode 100644 (file)
index 0000000..0653275
--- /dev/null
@@ -0,0 +1,43 @@
+#ifndef MSP_GRAPHICS_IMAGELOADER_H_
+#define MSP_GRAPHICS_IMAGELOADER_H_
+
+#include "image.h"
+
+namespace Msp {
+namespace Graphics {
+
+class unsupported_image_format: public std::runtime_error
+{
+public:
+       unsupported_image_format(const std::string &w): std::runtime_error(w) { }
+       virtual ~unsupported_image_format() throw() { }
+};
+
+class bad_image_data: public std::runtime_error
+{
+public:
+       bad_image_data(const std::string &w): std::runtime_error(w) { }
+       virtual ~bad_image_data() throw() { }
+};
+
+
+class ImageLoader
+{
+private:
+       IO::Base *source;
+protected:
+
+       ImageLoader();
+public:
+       virtual ~ImageLoader();
+
+       static ImageLoader *open_file(const std::string &);
+       static ImageLoader *open_io(IO::Base &);
+
+       virtual void load(Image::Data &) = 0;
+};
+
+} // namespace Graphics
+} // namespace Msp
+
+#endif