libLAS API Reference (svn-trunk)
color.hpp
Go to the documentation of this file.
1/******************************************************************************
2 * $Id$
3 *
4 * Project: libLAS - http://liblas.org - A BSD library for LAS format data.
5 * Purpose: LAS color class
6 * Author: Howard Butler, hobu.inc@gmail.com
7 *
8 ******************************************************************************
9 * Copyright (c) 2008, Howard Butler
10 *
11 * All rights reserved.
12 *
13 * Redistribution and use in source and binary forms, with or without
14 * modification, are permitted provided that the following
15 * conditions are met:
16 *
17 * * Redistributions of source code must rede following disclaimer.
18 * * Redistributions in binary form must reproduce the above copyright
19 * notice, this list of conditions and the following disclaimer in
20 * the documentation and/or other materials provided
21 * with the distribution.
22 * * Neither the name of the Martin Isenburg or Iowa Department
23 * of Natural Resources nor the names of its contributors may be
24 * used to endorse or promote products derived from this software
25 * without specific prior written permission.
26 *
27 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
28 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
29 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
30 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
31 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
32 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
33 * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
34 * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
35 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
36 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
37 * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
38 * OF SUCH DAMAGE.
39 ****************************************************************************/
40
41#ifndef LIBLAS_LASCOLOR_HPP_INCLUDED
42#define LIBLAS_LASCOLOR_HPP_INCLUDED
43
44#include <liblas/export.hpp>
45#include <stdint.h>
46
47// boost
48#include <boost/array.hpp>
49// std
50#include <cstdlib> // std::size_t
51
52namespace liblas {
53
56{
57public:
58
59 typedef uint16_t value_type;
60
64
68 Color(uint32_t red, uint32_t green, uint32_t blue);
69
73 Color(boost::array<value_type, 3> const& color);
74
76 Color(Color const& other);
77
79 Color& operator=(Color const& rhs);
80
82 value_type GetRed() const;
83
85 void SetRed(value_type const& value);
86
88 value_type GetBlue() const;
89
91 void SetBlue(value_type const& value);
92
94 value_type GetGreen() const;
95
97 void SetGreen(value_type const& value);
98
102 value_type& operator[](std::size_t const& index);
103
107 value_type const& operator[](std::size_t const& index) const;
108
109private:
110
111 typedef boost::array<value_type, 3> base_type;
112 base_type m_color;
113
114 void throw_index_out_of_range() const;
115 void throw_invalid_color_component() const;
116};
117
119{
120 return m_color[0];
121}
122
123inline void Color::SetRed(Color::value_type const& value)
124{
125 m_color[0] = value;
126}
127
129{
130 return m_color[1];
131}
132
133inline void Color::SetGreen(Color::value_type const& value)
134{
135 m_color[1] = value;
136}
137
139{
140 return m_color[2];
141}
142
143inline void Color::SetBlue(Color::value_type const& value)
144{
145 m_color[2] = value;
146}
147
148inline Color::value_type& Color::operator[](std::size_t const& index)
149{
150 return m_color[index];
151}
152
153inline Color::value_type const& Color::operator[](std::size_t const& index) const
154{
155 return m_color[index];
156}
157
158inline bool operator==(Color const& lhs, Color const& rhs)
159{
160 return lhs[0] == rhs[0] && lhs[1] == rhs[1] && lhs[2] == rhs[2];
161}
162
163inline bool operator!=(Color const& lhs, Color const& rhs)
164{
165 return !(lhs == rhs);
166}
167
168} // namespace liblas
169
170#endif // LIBLAS_LASCOLOR_HPP_INCLUDED
RGB color container.
Definition color.hpp:56
value_type GetBlue() const
Fetch value of the blue image channel.
Definition color.hpp:138
uint16_t value_type
Definition color.hpp:59
Color()
Default constructor.
Color(boost::array< value_type, 3 > const &color)
User-defined constructor.
Color & operator=(Color const &rhs)
Assignment opreator.
Color(Color const &other)
Copy constructor.
Color(uint32_t red, uint32_t green, uint32_t blue)
User-defined constructor.
void SetBlue(value_type const &value)
Set value of the blue image channel.
Definition color.hpp:143
value_type GetGreen() const
Fetch value of the green image channel.
Definition color.hpp:128
value_type GetRed() const
Fetch value of the red image channel.
Definition color.hpp:118
void SetGreen(value_type const &value)
Set value of the red image channel.
Definition color.hpp:133
value_type & operator[](std::size_t const &index)
Index operator providing access to RGB values.
Definition color.hpp:148
void SetRed(value_type const &value)
Set value of the red image channel.
Definition color.hpp:123
#define LAS_DLL
Definition export.hpp:58
Namespace grouping all elements of libLAS public interface.
Definition bounds.hpp:60
bool operator!=(Classification const &lhs, Classification const &rhs)
Not-equal-to operator implemented in terms of Classification::equal.
Definition classification.hpp:232
bool operator==(Classification const &lhs, Classification const &rhs)
Equal-to operator implemented in terms of Classification::equal.
Definition classification.hpp:226
Definition schema.hpp:80