]> git.tdb.fi Git - libs/gui.git/blob - source/graphics/image.h
29fd288c5634ca96a0b26c604b0cb56968ee89a3
[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();
27         };
28
29 private:
30         Data data;
31
32 public:
33         void load_file(const std::string &);
34         void load_io(IO::Seekable &);
35         void load(ImageLoader &);
36
37         PixelFormat get_format() const { return data.fmt; }
38         unsigned get_width() const { return data.width; }
39         unsigned get_height() const { return data.height; }
40         unsigned get_stride() const { return data.stride; }
41         const void *get_data() const { return data.data; }
42 };
43
44 } // namespace Graphics
45 } // namespace Msp
46
47 #endif