]> git.tdb.fi Git - libs/gui.git/blob - source/graphics/image.h
Proper support for copying images
[libs/gui.git] / source / graphics / image.h
1 #ifndef MSP_GRAPHICS_IMAGE_H_
2 #define MSP_GRAPHICS_IMAGE_H_
3
4 #include <stdexcept>
5 #include <string>
6 #include <msp/io/seekable.h>
7 #include "pixelformat.h"
8
9 namespace Msp {
10 namespace Graphics {
11
12 class ImageLoader;
13
14 class Image
15 {
16 public:
17         struct Data
18         {
19                 PixelFormat fmt;
20                 unsigned width;
21                 unsigned height;
22                 unsigned stride;
23                 char *data;
24
25                 Data();
26                 Data(const Data &);
27                 Data &operator=(const Data &);
28                 ~Data();
29         };
30
31 private:
32         Data data;
33
34 public:
35         void load_file(const std::string &);
36         void load_io(IO::Seekable &);
37         void load(ImageLoader &);
38
39         PixelFormat get_format() const { return data.fmt; }
40         unsigned get_width() const { return data.width; }
41         unsigned get_height() const { return data.height; }
42         unsigned get_stride() const { return data.stride; }
43         const void *get_data() const { return data.data; }
44 };
45
46 } // namespace Graphics
47 } // namespace Msp
48
49 #endif