Rpi-hw  0.7.2
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Pages
base.hpp
1 /*
2  Title --- image/base.hpp
3 
4  Copyright (C) 2013 Giacomo Trudu - wicker25[at]gmail[dot]com
5 
6  This file is part of Rpi-hw.
7 
8  Rpi-hw is free software: you can redistribute it and/or modify
9  it under the terms of the GNU Lesser General Public License as published by
10  the Free Software Foundation version 3 of the License.
11 
12  Rpi-hw is distributed in the hope that it will be useful,
13  but WITHOUT ANY WARRANTY; without even the implied warranty of
14  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  GNU Lesser General Public License for more details.
16 
17  You should have received a copy of the GNU Lesser General Public License
18  along with Rpi-hw. If not, see <http://www.gnu.org/licenses/>.
19 */
20 
21 
22 #ifndef _RPI_HW_IMAGE_BASE_HPP_
23 #define _RPI_HW_IMAGE_BASE_HPP_
24 
25 #include <vector>
26 
27 #include <rpi-hw/types.hpp>
28 #include <rpi-hw/exception.hpp>
29 
30 namespace rpihw { // Begin main namespace
31 
32 /*!
33  @namespace rpihw::image
34  @brief Namespace of the fonts.
35 */
36 
37 namespace image { // Begin images namespace
38 
39 /*!
40  @class base
41  @brief Generic image.
42 */
43 template < typename T >
44 class base {
45 
46 public:
47 
48  //! Returns the width of the image.
49  virtual uint16_t getWidth() const = 0;
50 
51  //! Returns the height of the image.
52  virtual uint16_t getHeight() const = 0;
53 
54  //! Returns the number of image channels.
55  virtual uint8_t getSpectrum() const = 0;
56 
57  /*!
58  @brief Returns the color of a pixel.
59  @param[in] x The horizontal position of the pixel.
60  @param[in] y The vertical position of the pixel.
61  @return An iterator to the color data.
62  */
63  virtual color_iterator< T > getData( uint16_t x, uint16_t y ) const = 0;
64 
65  /*!
66  @brief Returns the channel value of a pixel.
67  @param[in] x The horizontal position of the pixel.
68  @param[in] y The vertical position of the pixel.
69  @param[in] c The color channel.
70  @return The channel value of the pixel.
71  */
72  virtual T getData( uint16_t x, uint16_t y, uint8_t c ) const = 0;
73 };
74 
75 } // End of images namespace
76 
77 } // End of main namespace
78 
79 #endif /* _RPI_HW_IMAGE_BASE_HPP_ */
virtual uint16_t getHeight() const =0
Returns the height of the image.
virtual uint16_t getWidth() const =0
Returns the width of the image.
typename std::vector< T >::const_iterator color_iterator
Color iterator.
Definition: types.hpp:45
virtual uint8_t getSpectrum() const =0
Returns the number of image channels.
virtual color_iterator< T > getData(uint16_t x, uint16_t y) const =0
Returns the color of a pixel.
Generic image.
Definition: base.hpp:44