]> git.tdb.fi Git - libs/gui.git/blob - source/graphics/image.h
Add decorations for things which should be exported from the library
[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 "mspgui_api.h"
8 #include "pixelformat.h"
9
10 namespace Msp {
11 namespace Graphics {
12
13 class ImageLoader;
14
15 class MSPGUI_API Image
16 {
17 public:
18         struct Data
19         {
20                 PixelFormat fmt = RGB;
21                 unsigned width = 0;
22                 unsigned height = 0;
23                 unsigned stride = 0;
24                 char *owned_pixels = nullptr;
25                 char *pixels = nullptr;
26
27                 Data() = default;
28                 Data(const Data &);
29                 Data &operator=(const Data &);
30                 ~Data();
31         };
32
33 private:
34         Data data;
35
36 public:
37         void load_file(const std::string &);
38         void load_io(IO::Seekable &);
39         void load(ImageLoader &);
40         void load_into(ImageLoader &, void *);
41         void load_headers(ImageLoader &);
42
43         PixelFormat get_format() const { return data.fmt; }
44         unsigned get_width() const { return data.width; }
45         unsigned get_height() const { return data.height; }
46         unsigned get_stride() const { return data.stride; }
47         DEPRECATED const void *get_data() const { return data.pixels; }
48         const void *get_pixels() const { return data.pixels; }
49 };
50
51 } // namespace Graphics
52 } // namespace Msp
53
54 #endif