DISTRHO Plugin Framework
 All Classes Functions Variables Enumerations Enumerator Groups Pages
ImageBase.hpp
1 /*
2  * DISTRHO Plugin Framework (DPF)
3  * Copyright (C) 2012-2019 Filipe Coelho <falktx@falktx.com>
4  *
5  * Permission to use, copy, modify, and/or distribute this software for any purpose with
6  * or without fee is hereby granted, provided that the above copyright notice and this
7  * permission notice appear in all copies.
8  *
9  * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD
10  * TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN
11  * NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
12  * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
13  * IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
14  * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
15  */
16 
17 #ifndef DGL_IMAGE_BASE_HPP_INCLUDED
18 #define DGL_IMAGE_BASE_HPP_INCLUDED
19 
20 #include "Geometry.hpp"
21 
22 START_NAMESPACE_DGL
23 
24 // -----------------------------------------------------------------------
25 
26 /**
27  Base DGL Image class.
28 
29  This is an Image class that handles raw image data in pixels.
30  It is an abstract class that provides the common methods to build on top.
31  Cairo and OpenGL Image classes are based upon this one.
32 
33  @see Image
34  */
35 class ImageBase
36 {
37 protected:
38  /**
39  Constructor for a null Image.
40  */
41  ImageBase();
42 
43  /**
44  Constructor using raw image data.
45  @note @a rawData must remain valid for the lifetime of this Image.
46  */
47  ImageBase(const char* const rawData, const uint width, const uint height);
48 
49  /**
50  Constructor using raw image data.
51  @note @a rawData must remain valid for the lifetime of this Image.
52  */
53  ImageBase(const char* const rawData, const Size<uint>& size);
54 
55  /**
56  Constructor using another image data.
57  */
58  ImageBase(const ImageBase& image);
59 
60 public:
61  /**
62  Destructor.
63  */
64  virtual ~ImageBase();
65 
66  /**
67  Check if this image is valid.
68  */
69  bool isValid() const noexcept;
70 
71  /**
72  Get width.
73  */
74  uint getWidth() const noexcept;
75 
76  /**
77  Get height.
78  */
79  uint getHeight() const noexcept;
80 
81  /**
82  Get size.
83  */
84  const Size<uint>& getSize() const noexcept;
85 
86  /**
87  Get the raw image data.
88  */
89  const char* getRawData() const noexcept;
90 
91  /**
92  Draw this image at (0, 0) point.
93  */
94  void draw();
95 
96  /**
97  Draw this image at (x, y) point.
98  */
99  void drawAt(const int x, const int y);
100 
101  /**
102  Draw this image at position @a pos.
103  */
104  void drawAt(const Point<int>& pos);
105 
106  /**
107  TODO document this.
108  */
109  ImageBase& operator=(const ImageBase& image) noexcept;
110  bool operator==(const ImageBase& image) const noexcept;
111  bool operator!=(const ImageBase& image) const noexcept;
112 
113 protected:
114  /** @internal */
115  virtual void _drawAt(const Point<int>& pos) = 0;
116 
117  const char* fRawData;
118  Size<uint> fSize;
119 };
120 
121 // -----------------------------------------------------------------------
122 
123 END_NAMESPACE_DGL
124 
125 #endif // DGL_IMAGE_HPP_INCLUDED
bool isValid() const noexcept
void drawAt(const int x, const int y)
uint getHeight() const noexcept
ImageBase & operator=(const ImageBase &image) noexcept
virtual ~ImageBase()
Definition: ImageBase.hpp:35
const Size< uint > & getSize() const noexcept
uint getWidth() const noexcept
void draw()
const char * getRawData() const noexcept