]> git.tdb.fi Git - libs/gui.git/blobdiff - source/graphics/image.h
Make the image loading code more modular
[libs/gui.git] / source / graphics / image.h
index 137f856f21f5736d40dbecae6275a26919c42536..bfaeef84a00fbf7b945dbac8cc51d0fc593673bd 100644 (file)
@@ -9,39 +9,34 @@
 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;
 
 class Image
 {
 public:
-       struct Private;
+       struct Data
+       {
+               PixelFormat fmt;
+               unsigned width;
+               unsigned height;
+               char *data;
+
+               Data();
+               ~Data();
+       };
 
 private:
-       Private *priv;
+       Data data;
 
 public:
-       Image();
-       ~Image();
-
        void load_file(const std::string &);
        void load_io(IO::Base &);
-       PixelFormat get_format() const;
-       unsigned get_width() const;
-       unsigned get_height() const;
-       const void *get_data() const;
+       void load(ImageLoader &);
+
+       PixelFormat get_format() const { return data.fmt; }
+       unsigned get_width() const { return data.width; }
+       unsigned get_height() const { return data.height; }
+       const void *get_data() const { return data.data; }
 };
 
 } // namespace Graphics