1 <!-- Copyright 2008 Lubomir Bourdev and Hailin Jin
3 Distributed under the Boost Software License, Version 1.0.
4 (See accompanying file LICENSE_1_0.txt or copy at
5 http://www.boost.org/LICENSE_1_0.txt)
9 Copyright 2005-2007 Adobe Systems Incorporated
10 Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt
11 or a copy at http://stlab.adobe.com/licenses.html)
13 Some files are held under additional license.
14 Please see "http://stlab.adobe.com/licenses.html" for more information.
17 <!DOCTYPE html PUBLIC
"-//W3C//DTD XHTML 1.0 Transitional//EN"
18 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
19 <html xmlns=
"http://www.w3.org/1999/xhtml" lang=
"en" xml:
lang=
"en">
22 <TITLE>Generic Image Library: channel.hpp Source File
</TITLE>
23 <META HTTP-EQUIV=
"content-type" CONTENT=
"text/html;charset=ISO-8859-1"/>
24 <LINK TYPE=
"text/css" REL=
"stylesheet" HREF=
"adobe_source.css"/>
27 <table border=
"0" cellspacing=
"0" cellpadding=
"0" style='width:
100%; margin:
0; padding:
0'
><tr>
28 <td width=
"100%" valign=
"top" style='padding-left:
10px; padding-right:
10px; padding-bottom:
10px'
>
29 <div class=
"qindex"><a class=
"qindex" href=
"index.html">Modules
</a>
30 |
<a class=
"qindex" href=
"classes.html">Alphabetical List
</a>
31 |
<a class=
"qindex" href=
"annotated.html">Class List
</a>
32 |
<a class=
"qindex" href=
"dirs.html">Directories
</a>
33 |
<a class=
"qindex" href=
"files.html">File List
</a>
34 |
<a class=
"qindex" href=
"../index.html">GIL Home Page
</a>
37 <!-- Generated by Doxygen 1.5.6 -->
38 <div class=
"navpath"><a class=
"el" href=
"g_i_l_0076.html">boost
</a> »
<a class=
"el" href=
"g_i_l_0079.html">gil
</a>
40 <div class=
"contents">
41 <h1>channel.hpp
</h1><a href=
"channel_8hpp.html">Go to the documentation of this file.
</a><div class=
"fragment"><pre class=
"fragment"><a name=
"l00001"></a>00001 <span class=
"comment">/*
</span>
42 <a name=
"l00002"></a>00002 <span class=
"comment"> Copyright
2005-
2007 Adobe Systems Incorporated
</span>
43 <a name=
"l00003"></a>00003 <span class=
"comment"> </span>
44 <a name=
"l00004"></a>00004 <span class=
"comment"> Use, modification and distribution are subject to the Boost Software License,
</span>
45 <a name=
"l00005"></a>00005 <span class=
"comment"> Version
1.0. (See accompanying file LICENSE_1_0.txt or copy at
</span>
46 <a name=
"l00006"></a>00006 <span class=
"comment"> http://www.boost.org/LICENSE_1_0.txt).
</span>
47 <a name=
"l00007"></a>00007 <span class=
"comment"></span>
48 <a name=
"l00008"></a>00008 <span class=
"comment"> See http://stlab.adobe.com/gil for most recent version including documentation.
</span>
49 <a name=
"l00009"></a>00009 <span class=
"comment">*/
</span>
50 <a name=
"l00010"></a>00010
51 <a name=
"l00011"></a>00011 <span class=
"comment">/*************************************************************************************************/
</span>
52 <a name=
"l00012"></a>00012
53 <a name=
"l00013"></a>00013 <span class=
"preprocessor">#ifndef GIL_CHANNEL_HPP
</span>
54 <a name=
"l00014"></a>00014 <span class=
"preprocessor"></span><span class=
"preprocessor">#define GIL_CHANNEL_HPP
</span>
55 <a name=
"l00015"></a>00015 <span class=
"preprocessor"></span>
56 <a name=
"l00026"></a>00026
57 <a name=
"l00027"></a>00027 <span class=
"preprocessor">#include
<limits
></span>
58 <a name=
"l00028"></a>00028 <span class=
"preprocessor">#include
<cassert
></span>
59 <a name=
"l00029"></a>00029 <span class=
"preprocessor">#include
<boost/cstdint.hpp
></span>
60 <a name=
"l00030"></a>00030 <span class=
"preprocessor">#include
"<a class="code
" href="g_i_l_0094.html
" title="GIL configuration file.
">gil_config.hpp</a>"</span>
61 <a name=
"l00031"></a>00031 <span class=
"preprocessor">#include
"<a class="code
" href="utilities_8hpp.html
" title="Various utilities not specific to the image library. Some are non-standard STL extensions...
">utilities.hpp</a>"</span>
62 <a name=
"l00032"></a>00032
63 <a name=
"l00033"></a>00033 <span class=
"keyword">namespace
</span>boost {
<span class=
"keyword">namespace
</span>gil {
64 <a name=
"l00034"></a>00034
65 <a name=
"l00035"></a>00035
66 <a name=
"l00050"></a>00050
67 <a name=
"l00051"></a>00051 <span class=
"keyword">namespace
</span>detail {
68 <a name=
"l00052"></a>00052 <span class=
"keyword">template
</span> <<span class=
"keyword">typename
</span> T,
<span class=
"keywordtype">bool
</span> is_
<span class=
"keyword">class
</span>> <span class=
"keyword">struct
</span>channel_traits_impl;
69 <a name=
"l00053"></a>00053
70 <a name=
"l00054"></a>00054 <span class=
"comment">// channel traits for custom class
</span>
71 <a name=
"l00055"></a>00055 <span class=
"keyword">template
</span> <<span class=
"keyword">typename
</span> T
>
72 <a name=
"l00056"></a>00056 <span class=
"keyword">struct
</span>channel_traits_impl
<T, true
> {
73 <a name=
"l00057"></a>00057 <span class=
"keyword">typedef
</span> <span class=
"keyword">typename
</span> T::value_type value_type;
74 <a name=
"l00058"></a>00058 <span class=
"keyword">typedef
</span> <span class=
"keyword">typename
</span> T::reference reference;
75 <a name=
"l00059"></a>00059 <span class=
"keyword">typedef
</span> <span class=
"keyword">typename
</span> T::pointer pointer;
76 <a name=
"l00060"></a>00060 <span class=
"keyword">typedef
</span> <span class=
"keyword">typename
</span> T::const_reference const_reference;
77 <a name=
"l00061"></a>00061 <span class=
"keyword">typedef
</span> <span class=
"keyword">typename
</span> T::const_pointer const_pointer;
78 <a name=
"l00062"></a>00062 BOOST_STATIC_CONSTANT(
<span class=
"keywordtype">bool
</span>, is_mutable=T::is_mutable);
79 <a name=
"l00063"></a>00063 <span class=
"keyword">static
</span> value_type min_value() {
<span class=
"keywordflow">return
</span> T::min_value(); }
80 <a name=
"l00064"></a>00064 <span class=
"keyword">static
</span> value_type max_value() {
<span class=
"keywordflow">return
</span> T::max_value(); }
81 <a name=
"l00065"></a>00065 };
82 <a name=
"l00066"></a>00066
83 <a name=
"l00067"></a>00067 <span class=
"comment">// channel traits implementation for built-in integral or floating point channel type
</span>
84 <a name=
"l00068"></a>00068 <span class=
"keyword">template
</span> <<span class=
"keyword">typename
</span> T
>
85 <a name=
"l00069"></a>00069 <span class=
"keyword">struct
</span>channel_traits_impl
<T, false
> {
86 <a name=
"l00070"></a>00070 <span class=
"keyword">typedef
</span> T value_type;
87 <a name=
"l00071"></a>00071 <span class=
"keyword">typedef
</span> T
& reference;
88 <a name=
"l00072"></a>00072 <span class=
"keyword">typedef
</span> T* pointer;
89 <a name=
"l00073"></a>00073 <span class=
"keyword">typedef
</span> <span class=
"keyword">const
</span> T
& const_reference;
90 <a name=
"l00074"></a>00074 <span class=
"keyword">typedef
</span> T
<span class=
"keyword">const
</span>* const_pointer;
91 <a name=
"l00075"></a>00075 BOOST_STATIC_CONSTANT(
<span class=
"keywordtype">bool
</span>, is_mutable=
<span class=
"keyword">true
</span>);
92 <a name=
"l00076"></a>00076 <span class=
"keyword">static
</span> value_type min_value() {
<span class=
"keywordflow">return
</span> (std::numeric_limits
<T
>::min)(); }
93 <a name=
"l00077"></a>00077 <span class=
"keyword">static
</span> value_type max_value() {
<span class=
"keywordflow">return
</span> (std::numeric_limits
<T
>::max)(); }
94 <a name=
"l00078"></a>00078 };
95 <a name=
"l00079"></a>00079
96 <a name=
"l00080"></a>00080 <span class=
"comment">// channel traits implementation for constant built-in scalar or floating point type
</span>
97 <a name=
"l00081"></a>00081 <span class=
"keyword">template
</span> <<span class=
"keyword">typename
</span> T
>
98 <a name=
"l00082"></a>00082 <span class=
"keyword">struct
</span>channel_traits_impl
<const T, false
> :
<span class=
"keyword">public
</span> channel_traits_impl
<T, false
> {
99 <a name=
"l00083"></a>00083 <span class=
"keyword">typedef
</span> <span class=
"keyword">const
</span> T
& reference;
100 <a name=
"l00084"></a>00084 <span class=
"keyword">typedef
</span> <span class=
"keyword">const
</span> T* pointer;
101 <a name=
"l00085"></a>00085 BOOST_STATIC_CONSTANT(
<span class=
"keywordtype">bool
</span>, is_mutable=
<span class=
"keyword">false
</span>);
102 <a name=
"l00086"></a>00086 };
103 <a name=
"l00087"></a>00087 }
104 <a name=
"l00088"></a>00088
105 <a name=
"l00107"></a>00107 <span class=
"keyword">template
</span> <<span class=
"keyword">typename
</span> T
>
106 <a name=
"l00108"></a><a class=
"code" href=
"g_i_l_0429.html">00108</a> <span class=
"keyword">struct
</span><a class=
"code" href=
"g_i_l_0429.html" title=
"Traits for channels. Contains the following members:.">channel_traits
</a> :
<span class=
"keyword">public
</span> detail::channel_traits_impl
<T, is_class
<T
>::value
> {};
107 <a name=
"l00109"></a>00109
108 <a name=
"l00110"></a>00110 <span class=
"comment">// Channel traits for C++ reference type - remove the reference
</span>
109 <a name=
"l00111"></a>00111 <span class=
"keyword">template
</span> <<span class=
"keyword">typename
</span> T
> <span class=
"keyword">struct
</span><a class=
"code" href=
"g_i_l_0429.html" title=
"Traits for channels. Contains the following members:.">channel_traits
</a>< T
&> :
<span class=
"keyword">public
</span> <a class=
"code" href=
"g_i_l_0429.html" title=
"Traits for channels. Contains the following members:.">channel_traits
<T
></a> {};
110 <a name=
"l00112"></a>00112
111 <a name=
"l00113"></a>00113 <span class=
"comment">// Channel traits for constant C++ reference type
</span>
112 <a name=
"l00114"></a>00114 <span class=
"keyword">template
</span> <<span class=
"keyword">typename
</span> T
> <span class=
"keyword">struct
</span>channel_traits
<const T
&> :
<span class=
"keyword">public
</span> channel_traits
<T
> {
113 <a name=
"l00115"></a>00115 <span class=
"keyword">typedef
</span> <span class=
"keyword">typename
</span> channel_traits
<T
>::const_reference reference;
114 <a name=
"l00116"></a>00116 <span class=
"keyword">typedef
</span> <span class=
"keyword">typename
</span> channel_traits
<T
>::const_pointer pointer;
115 <a name=
"l00117"></a>00117 BOOST_STATIC_CONSTANT(
<span class=
"keywordtype">bool
</span>, is_mutable=
<span class=
"keyword">false
</span>);
116 <a name=
"l00118"></a>00118 };
117 <a name=
"l00119"></a>00119
118 <a name=
"l00125"></a>00125
119 <a name=
"l00146"></a>00146
120 <a name=
"l00147"></a>00147
121 <a name=
"l00148"></a>00148 <span class=
"keyword">template
</span> <<span class=
"keyword">typename
</span> BaseChannelValue,
<span class=
"comment">// base channel (models ChannelValueConcept)
</span>
122 <a name=
"l00149"></a>00149 <span class=
"keyword">typename
</span> MinVal,
<span class=
"keyword">typename
</span> MaxVal
> <span class=
"comment">// classes with a static apply() function returning the minimum/maximum channel values
</span>
123 <a name=
"l00150"></a><a class=
"code" href=
"g_i_l_0620.html">00150</a> <span class=
"keyword">struct
</span><a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">scoped_channel_value
</a> {
124 <a name=
"l00151"></a>00151 <span class=
"keyword">typedef
</span> <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">scoped_channel_value
</a> <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">value_type
</a>;
125 <a name=
"l00152"></a>00152 <span class=
"keyword">typedef
</span> <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">value_type
</a>& <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">reference
</a>;
126 <a name=
"l00153"></a>00153 <span class=
"keyword">typedef
</span> <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">value_type
</a>*
<a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">pointer
</a>;
127 <a name=
"l00154"></a>00154 <span class=
"keyword">typedef
</span> <span class=
"keyword">const
</span> <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">value_type
</a>& <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">const_reference
</a>;
128 <a name=
"l00155"></a>00155 <span class=
"keyword">typedef
</span> <span class=
"keyword">const
</span> <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">value_type
</a>*
<a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">const_pointer
</a>;
129 <a name=
"l00156"></a>00156 BOOST_STATIC_CONSTANT(
<span class=
"keywordtype">bool
</span>, is_mutable=
<a class=
"code" href=
"g_i_l_0429.html" title=
"Traits for channels. Contains the following members:.">channel_traits
<BaseChannelValue
>::is_mutable
</a>);
130 <a name=
"l00157"></a>00157
131 <a name=
"l00158"></a>00158 <span class=
"keyword">static
</span> <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">value_type
</a> min_value() {
<span class=
"keywordflow">return
</span> MinVal::apply(); }
132 <a name=
"l00159"></a>00159 <span class=
"keyword">static
</span> <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">value_type
</a> max_value() {
<span class=
"keywordflow">return
</span> MaxVal::apply(); }
133 <a name=
"l00160"></a>00160
134 <a name=
"l00161"></a>00161 <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">scoped_channel_value
</a>() {}
135 <a name=
"l00162"></a>00162 <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">scoped_channel_value
</a>(
<span class=
"keyword">const
</span> <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">scoped_channel_value
</a>& c) : _value(c.
<a class=
"code" href=
"g_i_l_0620.html#734cfc58c2d23ec05c26288f29070346">_value
</a>) {}
136 <a name=
"l00163"></a>00163 <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">scoped_channel_value
</a>(BaseChannelValue val) : _value(val) {}
137 <a name=
"l00164"></a>00164
138 <a name=
"l00165"></a>00165 <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">scoped_channel_value
</a>& operator++() { ++_value;
<span class=
"keywordflow">return
</span> *
<span class=
"keyword">this
</span>; }
139 <a name=
"l00166"></a>00166 <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">scoped_channel_value
</a>& operator--() { --_value;
<span class=
"keywordflow">return
</span> *
<span class=
"keyword">this
</span>; }
140 <a name=
"l00167"></a>00167
141 <a name=
"l00168"></a>00168 <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">scoped_channel_value
</a> operator++(
<span class=
"keywordtype">int
</span>) {
<a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">scoped_channel_value
</a> tmp=*
<span class=
"keyword">this
</span>; this-
>operator++();
<span class=
"keywordflow">return
</span> tmp; }
142 <a name=
"l00169"></a>00169 <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">scoped_channel_value
</a> operator--(
<span class=
"keywordtype">int
</span>) {
<a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">scoped_channel_value
</a> tmp=*
<span class=
"keyword">this
</span>; this-
>operator--();
<span class=
"keywordflow">return
</span> tmp; }
143 <a name=
"l00170"></a>00170
144 <a name=
"l00171"></a>00171 <span class=
"keyword">template
</span> <<span class=
"keyword">typename
</span> Scalar2
> <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">scoped_channel_value
</a>& operator+=(Scalar2 v) { _value+=v;
<span class=
"keywordflow">return
</span> *
<span class=
"keyword">this
</span>; }
145 <a name=
"l00172"></a>00172 <span class=
"keyword">template
</span> <<span class=
"keyword">typename
</span> Scalar2
> <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">scoped_channel_value
</a>& operator-=(Scalar2 v) { _value-=v;
<span class=
"keywordflow">return
</span> *
<span class=
"keyword">this
</span>; }
146 <a name=
"l00173"></a>00173 <span class=
"keyword">template
</span> <<span class=
"keyword">typename
</span> Scalar2
> <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">scoped_channel_value
</a>& operator*=(Scalar2 v) { _value*=v;
<span class=
"keywordflow">return
</span> *
<span class=
"keyword">this
</span>; }
147 <a name=
"l00174"></a>00174 <span class=
"keyword">template
</span> <<span class=
"keyword">typename
</span> Scalar2
> <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">scoped_channel_value
</a>& operator/=(Scalar2 v) { _value/=v;
<span class=
"keywordflow">return
</span> *
<span class=
"keyword">this
</span>; }
148 <a name=
"l00175"></a>00175
149 <a name=
"l00176"></a>00176 <a class=
"code" href=
"g_i_l_0620.html" title=
"A channel adaptor that modifies the range of the source channel. Models: ChannelValueConcept...">scoped_channel_value
</a>& operator=(BaseChannelValue v) { _value=v;
<span class=
"keywordflow">return
</span> *
<span class=
"keyword">this
</span>; }
150 <a name=
"l00177"></a>00177 operator BaseChannelValue()
<span class=
"keyword"> const
</span>{
<span class=
"keywordflow">return
</span> _value; }
151 <a name=
"l00178"></a>00178 <span class=
"keyword">private
</span>:
152 <a name=
"l00179"></a>00179 BaseChannelValue _value;
153 <a name=
"l00180"></a>00180 };
154 <a name=
"l00181"></a>00181
155 <a name=
"l00182"></a>00182 <span class=
"keyword">struct
</span>float_zero {
<span class=
"keyword">static
</span> <span class=
"keywordtype">float
</span> apply() {
<span class=
"keywordflow">return
</span> 0.0f; } };
156 <a name=
"l00183"></a>00183 <span class=
"keyword">struct
</span>float_one {
<span class=
"keyword">static
</span> <span class=
"keywordtype">float
</span> apply() {
<span class=
"keywordflow">return
</span> 1.0f; } };
157 <a name=
"l00184"></a>00184
158 <a name=
"l00185"></a>00185
159 <a name=
"l00191"></a>00191
160 <a name=
"l00192"></a>00192 <span class=
"comment">// It is necessary for packed channels to have their own value type. They cannot simply use an integral large enough to store the data. Here is why:
</span>
161 <a name=
"l00193"></a>00193 <span class=
"comment">// - Any operation that requires returning the result by value will otherwise return the built-in integral type, which will have incorrect range
</span>
162 <a name=
"l00194"></a>00194 <span class=
"comment">// That means that after getting the value of the channel we cannot properly do channel_convert, channel_invert, etc.
</span>
163 <a name=
"l00195"></a>00195 <span class=
"comment">// - Two channels are declared compatible if they have the same value type. That means that a packed channel is incorrectly declared compatible with an integral type
</span>
164 <a name=
"l00196"></a>00196 <span class=
"keyword">namespace
</span>detail {
165 <a name=
"l00197"></a>00197 <span class=
"comment">// returns the smallest fast unsigned integral type that has at least NumBits bits
</span>
166 <a name=
"l00198"></a>00198 <span class=
"keyword">template
</span> <<span class=
"keywordtype">int
</span> NumBits
>
167 <a name=
"l00199"></a>00199 <span class=
"keyword">struct
</span>min_fast_uint :
<span class=
"keyword">public
</span> mpl::if_c
< (NumBits
<=
8),
168 <a name=
"l00200"></a>00200 uint_least8_t,
169 <a name=
"l00201"></a>00201 typename mpl::if_c
< (NumBits
<=
16),
170 <a name=
"l00202"></a>00202 uint_least16_t,
171 <a name=
"l00203"></a>00203 typename mpl::if_c
< (NumBits
<=
32),
172 <a name=
"l00204"></a>00204 uint_least32_t,
173 <a name=
"l00205"></a>00205 uintmax_t
174 <a name=
"l00206"></a>00206 >::type
175 <a name=
"l00207"></a>00207 >::type
176 <a name=
"l00208"></a>00208 > {};
177 <a name=
"l00209"></a>00209 }
178 <a name=
"l00210"></a>00210
179 <a name=
"l00227"></a>00227
180 <a name=
"l00228"></a>00228
181 <a name=
"l00229"></a>00229 template
<int NumBits
>
182 <a name=
"l00230"></a><a class=
"code" href=
"g_i_l_0052.html">00230</a> class packed_channel_value {
183 <a name=
"l00231"></a>00231 static const std::size_t num_values =
1<<NumBits;
184 <a name=
"l00232"></a>00232 public:
185 <a name=
"l00233"></a>00233 typedef typename detail::min_fast_uint
<NumBits
>::type integer_t;
186 <a name=
"l00234"></a>00234
187 <a name=
"l00235"></a>00235 typedef packed_channel_value value_type;
188 <a name=
"l00236"></a>00236 typedef value_type
& reference;
189 <a name=
"l00237"></a>00237 typedef const value_type
& const_reference;
190 <a name=
"l00238"></a>00238 typedef value_type* pointer;
191 <a name=
"l00239"></a>00239 typedef const value_type* const_pointer;
192 <a name=
"l00240"></a>00240
193 <a name=
"l00241"></a>00241 static value_type min_value() { return value_type(
0); }
194 <a name=
"l00242"></a>00242 static value_type max_value() { return value_type(num_values-
1); }
195 <a name=
"l00243"></a>00243 BOOST_STATIC_CONSTANT(bool, is_mutable=true);
196 <a name=
"l00244"></a>00244
197 <a name=
"l00245"></a>00245 packed_channel_value() {}
198 <a name=
"l00246"></a>00246 packed_channel_value(integer_t v) : _value(v % num_values) {}
199 <a name=
"l00247"></a>00247 packed_channel_value(const packed_channel_value
& v) : _value(v._value) {}
200 <a name=
"l00248"></a>00248 template
<typename Scalar
> packed_channel_value(Scalar v) : _value(integer_t(v) % num_values) {}
<span class=
"comment">// suppress GCC implicit conversion warnings in channel regression file
</span>
201 <a name=
"l00249"></a>00249
202 <a name=
"l00250"></a>00250 operator integer_t() const { return _value; }
203 <a name=
"l00251"></a>00251 private:
204 <a name=
"l00252"></a>00252 integer_t _value;
205 <a name=
"l00253"></a>00253 };
206 <a name=
"l00254"></a>00254
207 <a name=
"l00255"></a>00255 namespace detail {
208 <a name=
"l00256"></a>00256
209 <a name=
"l00257"></a>00257 template
<std::size_t K
>
210 <a name=
"l00258"></a>00258 struct static_copy_bytes {
211 <a name=
"l00259"></a>00259 void operator()(const unsigned char* from, unsigned char* to) const {
212 <a name=
"l00260"></a>00260 *to = *from;
213 <a name=
"l00261"></a>00261 static_copy_bytes
<K-
1>()(++from,++to);
214 <a name=
"l00262"></a>00262 }
215 <a name=
"l00263"></a>00263 };
216 <a name=
"l00264"></a>00264
217 <a name=
"l00265"></a>00265 template
<>
218 <a name=
"l00266"></a>00266 struct static_copy_bytes
<0> {
219 <a name=
"l00267"></a>00267 void operator()(const unsigned char* , unsigned char*) const {}
220 <a name=
"l00268"></a>00268 };
221 <a name=
"l00269"></a>00269
222 <a name=
"l00270"></a>00270 template
<typename Derived, typename BitField, int NumBits, bool Mutable
>
223 <a name=
"l00271"></a>00271 class packed_channel_reference_base {
224 <a name=
"l00272"></a>00272 protected:
225 <a name=
"l00273"></a>00273 typedef typename mpl::if_c
<Mutable,void*,const void*
>::type data_ptr_t;
226 <a name=
"l00274"></a>00274 public:
227 <a name=
"l00275"></a>00275 data_ptr_t _data_ptr;
<span class=
"comment">// void* pointer to the first byte of the bit range
</span>
228 <a name=
"l00276"></a>00276
229 <a name=
"l00277"></a>00277 typedef packed_channel_value
<NumBits
> value_type;
230 <a name=
"l00278"></a>00278 typedef const Derived reference;
231 <a name=
"l00279"></a>00279 typedef value_type* pointer;
232 <a name=
"l00280"></a>00280 typedef const value_type* const_pointer;
233 <a name=
"l00281"></a>00281 BOOST_STATIC_CONSTANT(int, num_bits=NumBits);
234 <a name=
"l00282"></a>00282 BOOST_STATIC_CONSTANT(bool, is_mutable=Mutable);
235 <a name=
"l00283"></a>00283
236 <a name=
"l00284"></a>00284 static value_type min_value() { return channel_traits
<value_type
>::min_value(); }
237 <a name=
"l00285"></a>00285 static value_type max_value() { return channel_traits
<value_type
>::max_value(); }
238 <a name=
"l00286"></a>00286
239 <a name=
"l00287"></a>00287 typedef BitField bitfield_t;
240 <a name=
"l00288"></a>00288 typedef typename value_type::integer_t integer_t;
241 <a name=
"l00289"></a>00289
242 <a name=
"l00290"></a>00290 packed_channel_reference_base(data_ptr_t data_ptr) : _data_ptr(data_ptr) {}
243 <a name=
"l00291"></a>00291 packed_channel_reference_base(const packed_channel_reference_base
& ref) : _data_ptr(ref._data_ptr) {}
244 <a name=
"l00292"></a>00292 const Derived
& operator=(integer_t v) const { set(v); return derived(); }
245 <a name=
"l00293"></a>00293
246 <a name=
"l00294"></a>00294 const Derived
& operator++() const { set(get()+
1); return derived(); }
247 <a name=
"l00295"></a>00295 const Derived
& operator--() const { set(get()-
1); return derived(); }
248 <a name=
"l00296"></a>00296
249 <a name=
"l00297"></a>00297 Derived operator++(int) const { Derived tmp=derived(); this-
>operator++(); return tmp; }
250 <a name=
"l00298"></a>00298 Derived operator--(int) const { Derived tmp=derived(); this-
>operator--(); return tmp; }
251 <a name=
"l00299"></a>00299
252 <a name=
"l00300"></a>00300 template
<typename Scalar2
> const Derived
& operator+=(Scalar2 v) const { set(get()+v); return derived(); }
253 <a name=
"l00301"></a>00301 template
<typename Scalar2
> const Derived
& operator-=(Scalar2 v) const { set(get()-v); return derived(); }
254 <a name=
"l00302"></a>00302 template
<typename Scalar2
> const Derived
& operator*=(Scalar2 v) const { set(get()*v); return derived(); }
255 <a name=
"l00303"></a>00303 template
<typename Scalar2
> const Derived
& operator/=(Scalar2 v) const { set(get()/v); return derived(); }
256 <a name=
"l00304"></a>00304
257 <a name=
"l00305"></a>00305 operator integer_t() const { return get(); }
258 <a name=
"l00306"></a>00306 data_ptr_t operator
&() const {return _data_ptr;}
259 <a name=
"l00307"></a>00307 protected:
260 <a name=
"l00308"></a>00308 static const integer_t max_val = (
1<<NumBits) -
1;
261 <a name=
"l00309"></a>00309
262 <a name=
"l00310"></a>00310 #ifdef GIL_NONWORD_POINTER_ALIGNMENT_SUPPORTED
263 <a name=
"l00311"></a>00311 const bitfield_t
& get_data() const { return *static_cast
<const bitfield_t*
>(_data_ptr); }
264 <a name=
"l00312"></a>00312 void set_data(const bitfield_t
& val) const { *static_cast
< bitfield_t*
>(_data_ptr) = val; }
265 <a name=
"l00313"></a>00313 #else
266 <a name=
"l00314"></a>00314 bitfield_t get_data() const {
267 <a name=
"l00315"></a>00315 bitfield_t ret;
268 <a name=
"l00316"></a>00316 static_copy_bytes
<sizeof(bitfield_t)
>()(gil_reinterpret_cast_c
<const unsigned char*
>(_data_ptr),gil_reinterpret_cast
<unsigned char*
>(
&ret));
269 <a name=
"l00317"></a>00317 return ret;
270 <a name=
"l00318"></a>00318 }
271 <a name=
"l00319"></a>00319 void set_data(const bitfield_t
& val) const {
272 <a name=
"l00320"></a>00320 static_copy_bytes
<sizeof(bitfield_t)
>()(gil_reinterpret_cast_c
<const unsigned char*
>(
&val),gil_reinterpret_cast
<unsigned char*
>(_data_ptr));
273 <a name=
"l00321"></a>00321 }
274 <a name=
"l00322"></a>00322 #endif
275 <a name=
"l00323"></a>00323
276 <a name=
"l00324"></a>00324 private:
277 <a name=
"l00325"></a>00325 void set(integer_t value) const {
<span class=
"comment">// can this be done faster??
</span>
278 <a name=
"l00326"></a>00326 const integer_t num_values = max_val+
1;
279 <a name=
"l00327"></a>00327 this-
>derived().set_unsafe(((value % num_values) + num_values) % num_values);
280 <a name=
"l00328"></a>00328 }
281 <a name=
"l00329"></a>00329 integer_t get() const { return derived().get(); }
282 <a name=
"l00330"></a>00330 const Derived
& derived() const { return static_cast
<const Derived
&>(*this); }
283 <a name=
"l00331"></a>00331 };
284 <a name=
"l00332"></a>00332 }
<span class=
"comment">// namespace detail
</span>
285 <a name=
"l00333"></a>00333
286 <a name=
"l00350"></a>00350 template
<typename BitField,
<span class=
"comment">// A type that holds the bits of the pixel from which the channel is referenced. Typically an integral type, like boost::uint16_t
</span>
287 <a name=
"l00351"></a>00351 int FirstBit, int NumBits,
<span class=
"comment">// Defines the sequence of bits in the data value that contain the channel
</span>
288 <a name=
"l00352"></a>00352 bool Mutable
> <span class=
"comment">// true if the reference is mutable
</span>
289 <a name=
"l00353"></a>00353 class packed_channel_reference;
290 <a name=
"l00354"></a>00354
291 <a name=
"l00355"></a>00355 template
<typename BitField,
<span class=
"comment">// A type that holds the bits of the pixel from which the channel is referenced. Typically an integral type, like boost::uint16_t
</span>
292 <a name=
"l00356"></a>00356 int NumBits,
<span class=
"comment">// Defines the sequence of bits in the data value that contain the channel
</span>
293 <a name=
"l00357"></a>00357 bool Mutable
> <span class=
"comment">// true if the reference is mutable
</span>
294 <a name=
"l00358"></a>00358 class packed_dynamic_channel_reference;
295 <a name=
"l00359"></a>00359
296 <a name=
"l00362"></a>00362 template
<typename BitField, int FirstBit, int NumBits
>
297 <a name=
"l00363"></a><a class=
"code" href=
"g_i_l_0048.html">00363</a> class packed_channel_reference
<BitField,FirstBit,NumBits,false
>
298 <a name=
"l00364"></a>00364 : public detail::packed_channel_reference_base
<packed_channel_reference
<BitField,FirstBit,NumBits,false
>,BitField,NumBits,false
> {
299 <a name=
"l00365"></a>00365 typedef detail::packed_channel_reference_base
<packed_channel_reference
<BitField,FirstBit,NumBits,false
>,BitField,NumBits,false
> parent_t;
300 <a name=
"l00366"></a>00366 friend class packed_channel_reference
<BitField,FirstBit,NumBits,true
>;
301 <a name=
"l00367"></a>00367
302 <a name=
"l00368"></a>00368 static const BitField channel_mask = parent_t::max_val
<<FirstBit;
303 <a name=
"l00369"></a>00369 void operator=(const packed_channel_reference
&);
304 <a name=
"l00370"></a>00370 public:
305 <a name=
"l00371"></a>00371 typedef const packed_channel_reference
<BitField,FirstBit,NumBits,false
> const_reference;
306 <a name=
"l00372"></a>00372 typedef const packed_channel_reference
<BitField,FirstBit,NumBits,true
> mutable_reference;
307 <a name=
"l00373"></a>00373 typedef typename parent_t::integer_t integer_t;
308 <a name=
"l00374"></a>00374
309 <a name=
"l00375"></a>00375 explicit packed_channel_reference(const void* data_ptr) : parent_t(data_ptr) {}
310 <a name=
"l00376"></a>00376 packed_channel_reference(const packed_channel_reference
& ref) : parent_t(ref._data_ptr) {}
311 <a name=
"l00377"></a>00377 packed_channel_reference(const mutable_reference
& ref) : parent_t(ref._data_ptr) {}
312 <a name=
"l00378"></a>00378
313 <a name=
"l00379"></a>00379 unsigned first_bit() const { return FirstBit; }
314 <a name=
"l00380"></a>00380
315 <a name=
"l00381"></a>00381 integer_t get() const { return integer_t((this-
>get_data()
&channel_mask)
>> FirstBit); }
316 <a name=
"l00382"></a>00382 };
317 <a name=
"l00383"></a>00383
318 <a name=
"l00386"></a>00386 template
<typename BitField, int FirstBit, int NumBits
>
319 <a name=
"l00387"></a><a class=
"code" href=
"g_i_l_0050.html">00387</a> class packed_channel_reference
<BitField,FirstBit,NumBits,true
>
320 <a name=
"l00388"></a>00388 : public detail::packed_channel_reference_base
<packed_channel_reference
<BitField,FirstBit,NumBits,true
>,BitField,NumBits,true
> {
321 <a name=
"l00389"></a>00389 typedef detail::packed_channel_reference_base
<packed_channel_reference
<BitField,FirstBit,NumBits,true
>,BitField,NumBits,true
> parent_t;
322 <a name=
"l00390"></a>00390 friend class packed_channel_reference
<BitField,FirstBit,NumBits,false
>;
323 <a name=
"l00391"></a>00391
324 <a name=
"l00392"></a>00392 static const BitField channel_mask = parent_t::max_val
<<FirstBit;
325 <a name=
"l00393"></a>00393 public:
326 <a name=
"l00394"></a>00394 typedef const packed_channel_reference
<BitField,FirstBit,NumBits,false
> const_reference;
327 <a name=
"l00395"></a>00395 typedef const packed_channel_reference
<BitField,FirstBit,NumBits,true
> mutable_reference;
328 <a name=
"l00396"></a>00396 typedef typename parent_t::integer_t integer_t;
329 <a name=
"l00397"></a>00397
330 <a name=
"l00398"></a>00398 explicit packed_channel_reference(void* data_ptr) : parent_t(data_ptr) {}
331 <a name=
"l00399"></a>00399 packed_channel_reference(const packed_channel_reference
& ref) : parent_t(ref._data_ptr) {}
332 <a name=
"l00400"></a>00400
333 <a name=
"l00401"></a>00401 const packed_channel_reference
& operator=(integer_t value) const { assert(value
<=parent_t::max_val); set_unsafe(value); return *this; }
334 <a name=
"l00402"></a>00402 const packed_channel_reference
& operator=(const mutable_reference
& ref) const { set_from_reference(ref.get_data()); return *this; }
335 <a name=
"l00403"></a>00403 const packed_channel_reference
& operator=(const const_reference
& ref) const { set_from_reference(ref.get_data()); return *this; }
336 <a name=
"l00404"></a>00404
337 <a name=
"l00405"></a>00405 template
<bool Mutable1
>
338 <a name=
"l00406"></a>00406 const packed_channel_reference
& operator=(const packed_dynamic_channel_reference
<BitField,NumBits,Mutable1
>& ref) const { set_unsafe(ref.get()); return *this; }
339 <a name=
"l00407"></a>00407
340 <a name=
"l00408"></a>00408 unsigned first_bit() const { return FirstBit; }
341 <a name=
"l00409"></a>00409
342 <a name=
"l00410"></a>00410 integer_t get() const { return integer_t((this-
>get_data()
&channel_mask)
>> FirstBit); }
343 <a name=
"l00411"></a>00411 void set_unsafe(integer_t value) const { this-
>set_data((this-
>get_data()
& ~channel_mask) | (value
<<FirstBit)); }
344 <a name=
"l00412"></a>00412 private:
345 <a name=
"l00413"></a>00413 void set_from_reference(const BitField
& other_bits) const { this-
>set_data((this-
>get_data()
& ~channel_mask) | (other_bits
& channel_mask)); }
346 <a name=
"l00414"></a>00414 };
347 <a name=
"l00415"></a>00415
348 <a name=
"l00416"></a>00416 } }
<span class=
"comment">// namespace boost::gil
</span>
349 <a name=
"l00417"></a>00417
350 <a name=
"l00418"></a>00418 namespace std {
351 <a name=
"l00419"></a>00419 <span class=
"comment">// We are forced to define swap inside std namespace because on some platforms (Visual Studio
8) STL calls swap qualified.
</span>
352 <a name=
"l00420"></a>00420 <span class=
"comment">// swap with 'left bias':
</span>
353 <a name=
"l00421"></a>00421 <span class=
"comment">// - swap between proxy and anything
</span>
354 <a name=
"l00422"></a>00422 <span class=
"comment">// - swap between value type and proxy
</span>
355 <a name=
"l00423"></a>00423 <span class=
"comment">// - swap between proxy and proxy
</span>
356 <a name=
"l00424"></a>00424
357 <a name=
"l00427"></a>00427 template
<typename BF, int FB, int NB, bool M, typename R
> inline
358 <a name=
"l00428"></a><a class=
"code" href=
"g_i_l_0176.html#g80e89636c0d110249fedf6ea14a477f7">00428</a> void swap(const boost::gil::packed_channel_reference
<BF,FB,NB,M
> x, R
& y) {
359 <a name=
"l00429"></a>00429 boost::gil::swap_proxy
<typename boost::gil::packed_channel_reference
<BF,FB,NB,M
>::value_type
>(x,y);
360 <a name=
"l00430"></a>00430 }
361 <a name=
"l00431"></a>00431
362 <a name=
"l00432"></a>00432
363 <a name=
"l00435"></a>00435 template
<typename BF, int FB, int NB, bool M
> inline
364 <a name=
"l00436"></a><a class=
"code" href=
"g_i_l_0176.html#g9541bc0769202d632e1b869e1cf217e0">00436</a> void swap(typename boost::gil::packed_channel_reference
<BF,FB,NB,M
>::value_type
& x, const boost::gil::packed_channel_reference
<BF,FB,NB,M
> y) {
365 <a name=
"l00437"></a>00437 boost::gil::swap_proxy
<typename boost::gil::packed_channel_reference
<BF,FB,NB,M
>::value_type
>(x,y);
366 <a name=
"l00438"></a>00438 }
367 <a name=
"l00439"></a>00439
368 <a name=
"l00440"></a>00440
369 <a name=
"l00443"></a>00443 template
<typename BF, int FB, int NB, bool M
> inline
370 <a name=
"l00444"></a><a class=
"code" href=
"g_i_l_0176.html#g20a753330c605ac59c89aa784ab89eca">00444</a> void swap(const boost::gil::packed_channel_reference
<BF,FB,NB,M
> x, const boost::gil::packed_channel_reference
<BF,FB,NB,M
> y) {
371 <a name=
"l00445"></a>00445 boost::gil::swap_proxy
<typename boost::gil::packed_channel_reference
<BF,FB,NB,M
>::value_type
>(x,y);
372 <a name=
"l00446"></a>00446 }
373 <a name=
"l00447"></a>00447 }
<span class=
"comment">// namespace std
</span>
374 <a name=
"l00448"></a>00448
375 <a name=
"l00449"></a>00449 namespace boost { namespace gil {
376 <a name=
"l00450"></a>00450
377 <a name=
"l00468"></a>00468
378 <a name=
"l00469"></a>00469
379 <a name=
"l00470"></a>00470
380 <a name=
"l00471"></a>00471 template
<typename BitField, int NumBits
>
381 <a name=
"l00472"></a><a class=
"code" href=
"g_i_l_0054.html">00472</a> class packed_dynamic_channel_reference
<BitField,NumBits,false
>
382 <a name=
"l00473"></a>00473 : public detail::packed_channel_reference_base
<packed_dynamic_channel_reference
<BitField,NumBits,false
>,BitField,NumBits,false
> {
383 <a name=
"l00474"></a>00474 typedef detail::packed_channel_reference_base
<packed_dynamic_channel_reference
<BitField,NumBits,false
>,BitField,NumBits,false
> parent_t;
384 <a name=
"l00475"></a>00475 friend class packed_dynamic_channel_reference
<BitField,NumBits,true
>;
385 <a name=
"l00476"></a>00476
386 <a name=
"l00477"></a>00477 unsigned _first_bit;
<span class=
"comment">//
0.
.7</span>
387 <a name=
"l00478"></a>00478
388 <a name=
"l00479"></a>00479 void operator=(const packed_dynamic_channel_reference
&);
389 <a name=
"l00480"></a>00480 public:
390 <a name=
"l00481"></a>00481 typedef const packed_dynamic_channel_reference
<BitField,NumBits,false
> const_reference;
391 <a name=
"l00482"></a>00482 typedef const packed_dynamic_channel_reference
<BitField,NumBits,true
> mutable_reference;
392 <a name=
"l00483"></a>00483 typedef typename parent_t::integer_t integer_t;
393 <a name=
"l00484"></a>00484
394 <a name=
"l00485"></a>00485 packed_dynamic_channel_reference(const void* data_ptr, unsigned first_bit) : parent_t(data_ptr), _first_bit(first_bit) {}
395 <a name=
"l00486"></a>00486 packed_dynamic_channel_reference(const const_reference
& ref) : parent_t(ref._data_ptr), _first_bit(ref._first_bit) {}
396 <a name=
"l00487"></a>00487 packed_dynamic_channel_reference(const mutable_reference
& ref) : parent_t(ref._data_ptr), _first_bit(ref._first_bit) {}
397 <a name=
"l00488"></a>00488
398 <a name=
"l00489"></a>00489 unsigned first_bit() const { return _first_bit; }
399 <a name=
"l00490"></a>00490
400 <a name=
"l00491"></a>00491 integer_t get() const {
401 <a name=
"l00492"></a>00492 const BitField channel_mask = parent_t::max_val
<<_first_bit;
402 <a name=
"l00493"></a>00493 return (this-
>get_data()
&channel_mask)
>> _first_bit;
403 <a name=
"l00494"></a>00494 }
404 <a name=
"l00495"></a>00495 };
405 <a name=
"l00496"></a>00496
406 <a name=
"l00500"></a>00500 template
<typename BitField, int NumBits
>
407 <a name=
"l00501"></a><a class=
"code" href=
"g_i_l_0056.html">00501</a> class packed_dynamic_channel_reference
<BitField,NumBits,true
>
408 <a name=
"l00502"></a>00502 :
<span class=
"keyword">public
</span> detail::packed_channel_reference_base
<packed_dynamic_channel_reference
<BitField,NumBits,true
>,BitField,NumBits,true
> {
409 <a name=
"l00503"></a>00503 <span class=
"keyword">typedef
</span> detail::packed_channel_reference_base
<packed_dynamic_channel_reference
<BitField,NumBits,true
>,BitField,NumBits,
<span class=
"keyword">true
</span>> parent_t;
410 <a name=
"l00504"></a>00504 <span class=
"keyword">friend
</span> <span class=
"keyword">class
</span>packed_dynamic_channel_reference
<BitField,NumBits,false
>;
411 <a name=
"l00505"></a>00505
412 <a name=
"l00506"></a>00506 <span class=
"keywordtype">unsigned
</span> _first_bit;
413 <a name=
"l00507"></a>00507
414 <a name=
"l00508"></a>00508 <span class=
"keyword">public
</span>:
415 <a name=
"l00509"></a>00509 <span class=
"keyword">typedef
</span> <span class=
"keyword">const
</span> packed_dynamic_channel_reference
<BitField,NumBits,false
> <a class=
"code" href=
"g_i_l_0054.html" title=
"Models a constant subbyte channel reference whose bit offset is a runtime parameter...">const_reference
</a>;
416 <a name=
"l00510"></a>00510 <span class=
"keyword">typedef
</span> <span class=
"keyword">const
</span> packed_dynamic_channel_reference
<BitField,NumBits,true
> <a class=
"code" href=
"g_i_l_0056.html" title=
"Models a mutable subbyte channel reference whose bit offset is a runtime parameter...">mutable_reference
</a>;
417 <a name=
"l00511"></a>00511 <span class=
"keyword">typedef
</span> <span class=
"keyword">typename
</span> parent_t::integer_t integer_t;
418 <a name=
"l00512"></a>00512
419 <a name=
"l00513"></a>00513 packed_dynamic_channel_reference(
<span class=
"keywordtype">void
</span>* data_ptr,
<span class=
"keywordtype">unsigned
</span> first_bit) : parent_t(data_ptr), _first_bit(first_bit) {}
420 <a name=
"l00514"></a>00514 packed_dynamic_channel_reference(
<span class=
"keyword">const
</span> packed_dynamic_channel_reference
& ref) : parent_t(ref._data_ptr), _first_bit(ref._first_bit) {}
421 <a name=
"l00515"></a>00515
422 <a name=
"l00516"></a>00516 <span class=
"keyword">const
</span> packed_dynamic_channel_reference
& operator=(integer_t value)
<span class=
"keyword"> const
</span>{ assert(value
<=parent_t::max_val); set_unsafe(value);
<span class=
"keywordflow">return
</span> *
<span class=
"keyword">this
</span>; }
423 <a name=
"l00517"></a>00517 <span class=
"keyword">const
</span> packed_dynamic_channel_reference
& operator=(
<span class=
"keyword">const
</span> <a class=
"code" href=
"g_i_l_0056.html" title=
"Models a mutable subbyte channel reference whose bit offset is a runtime parameter...">mutable_reference
</a>& ref)
<span class=
"keyword"> const
</span>{ set_unsafe(ref.
<a class=
"code" href=
"g_i_l_0056.html#acb80df4b55e284a1e5cc442604aedea">get
</a>());
<span class=
"keywordflow">return
</span> *
<span class=
"keyword">this
</span>; }
424 <a name=
"l00518"></a>00518 <span class=
"keyword">const
</span> packed_dynamic_channel_reference
& operator=(
<span class=
"keyword">const
</span> <a class=
"code" href=
"g_i_l_0054.html" title=
"Models a constant subbyte channel reference whose bit offset is a runtime parameter...">const_reference
</a>& ref)
<span class=
"keyword"> const
</span>{ set_unsafe(ref.
<a class=
"code" href=
"g_i_l_0054.html#acb80df4b55e284a1e5cc442604aedea">get
</a>());
<span class=
"keywordflow">return
</span> *
<span class=
"keyword">this
</span>; }
425 <a name=
"l00519"></a>00519
426 <a name=
"l00520"></a>00520 <span class=
"keyword">template
</span> <<span class=
"keyword">typename
</span> BitField1,
<span class=
"keywordtype">int
</span> FirstBit1,
<span class=
"keywordtype">bool
</span> Mutable1
>
427 <a name=
"l00521"></a>00521 <span class=
"keyword">const
</span> packed_dynamic_channel_reference
& operator=(
<span class=
"keyword">const
</span> packed_channel_reference
<BitField1, FirstBit1, NumBits, Mutable1
>& ref)
<span class=
"keyword"> const
</span>
428 <a name=
"l00522"></a>00522 <span class=
"keyword"> </span>{ set_unsafe(ref.get());
<span class=
"keywordflow">return
</span> *
<span class=
"keyword">this
</span>; }
429 <a name=
"l00523"></a>00523
430 <a name=
"l00524"></a>00524 <span class=
"keywordtype">unsigned
</span> first_bit()
<span class=
"keyword"> const
</span>{
<span class=
"keywordflow">return
</span> _first_bit; }
431 <a name=
"l00525"></a>00525
432 <a name=
"l00526"></a>00526 integer_t
<span class=
"keyword">get
</span>()
<span class=
"keyword">const
</span> {
433 <a name=
"l00527"></a>00527 <span class=
"keyword">const
</span> BitField channel_mask = parent_t::max_val
<<_first_bit;
434 <a name=
"l00528"></a>00528 <span class=
"keywordflow">return
</span> (this-
>get_data()
&channel_mask)
>> _first_bit;
435 <a name=
"l00529"></a>00529 }
436 <a name=
"l00530"></a>00530 <span class=
"keywordtype">void
</span> set_unsafe(integer_t value)
<span class=
"keyword"> const
</span>{
437 <a name=
"l00531"></a>00531 <span class=
"keyword">const
</span> BitField channel_mask = parent_t::max_val
<<_first_bit;
438 <a name=
"l00532"></a>00532 this-
>set_data((this-
>get_data()
& ~channel_mask) | value
<<_first_bit);
439 <a name=
"l00533"></a>00533 }
440 <a name=
"l00534"></a>00534 };
441 <a name=
"l00535"></a>00535 } }
<span class=
"comment">// namespace boost::gil
</span>
442 <a name=
"l00536"></a>00536
443 <a name=
"l00537"></a>00537 <span class=
"keyword">namespace
</span>std {
444 <a name=
"l00538"></a>00538 <span class=
"comment">// We are forced to define swap inside std namespace because on some platforms (Visual Studio
8) STL calls swap qualified.
</span>
445 <a name=
"l00539"></a>00539 <span class=
"comment">// swap with 'left bias':
</span>
446 <a name=
"l00540"></a>00540 <span class=
"comment">// - swap between proxy and anything
</span>
447 <a name=
"l00541"></a>00541 <span class=
"comment">// - swap between value type and proxy
</span>
448 <a name=
"l00542"></a>00542 <span class=
"comment">// - swap between proxy and proxy
</span>
449 <a name=
"l00543"></a>00543
450 <a name=
"l00544"></a>00544
451 <a name=
"l00547"></a>00547 <span class=
"keyword">template
</span> <<span class=
"keyword">typename
</span> BF,
<span class=
"keywordtype">int
</span> NB,
<span class=
"keywordtype">bool
</span> M,
<span class=
"keyword">typename
</span> R
> <span class=
"keyword">inline
</span>
452 <a name=
"l00548"></a><a class=
"code" href=
"g_i_l_0175.html#g45affd7c290ef9a24ac79edbd6f9ca7f">00548</a> <span class=
"keywordtype">void
</span> swap(
<span class=
"keyword">const
</span> boost::gil::packed_dynamic_channel_reference
<BF,NB,M
> x, R
& y) {
453 <a name=
"l00549"></a>00549 boost::gil::swap_proxy
<typename boost::gil::packed_dynamic_channel_reference
<BF,NB,M
>::value_type
>(x,y);
454 <a name=
"l00550"></a>00550 }
455 <a name=
"l00551"></a>00551
456 <a name=
"l00552"></a>00552
457 <a name=
"l00555"></a>00555 <span class=
"keyword">template
</span> <<span class=
"keyword">typename
</span> BF,
<span class=
"keywordtype">int
</span> NB,
<span class=
"keywordtype">bool
</span> M
> <span class=
"keyword">inline
</span>
458 <a name=
"l00556"></a><a class=
"code" href=
"g_i_l_0175.html#gc25302c1ae9ad02851565565fd95e03e">00556</a> <span class=
"keywordtype">void
</span> swap(
<span class=
"keyword">typename
</span> boost::gil::packed_dynamic_channel_reference
<BF,NB,M
>::value_type
& x,
<span class=
"keyword">const
</span> boost::gil::packed_dynamic_channel_reference
<BF,NB,M
> y) {
459 <a name=
"l00557"></a>00557 boost::gil::swap_proxy
<typename boost::gil::packed_dynamic_channel_reference
<BF,NB,M
>::value_type
>(x,y);
460 <a name=
"l00558"></a>00558 }
461 <a name=
"l00559"></a>00559
462 <a name=
"l00560"></a>00560
463 <a name=
"l00563"></a>00563 <span class=
"keyword">template
</span> <<span class=
"keyword">typename
</span> BF,
<span class=
"keywordtype">int
</span> NB,
<span class=
"keywordtype">bool
</span> M
> <span class=
"keyword">inline
</span>
464 <a name=
"l00564"></a><a class=
"code" href=
"g_i_l_0175.html#gd5c9bdabc34d65825f30d2ae71cb07dc">00564</a> <span class=
"keywordtype">void
</span> swap(
<span class=
"keyword">const
</span> boost::gil::packed_dynamic_channel_reference
<BF,NB,M
> x,
<span class=
"keyword">const
</span> boost::gil::packed_dynamic_channel_reference
<BF,NB,M
> y) {
465 <a name=
"l00565"></a>00565 boost::gil::swap_proxy
<typename boost::gil::packed_dynamic_channel_reference
<BF,NB,M
>::value_type
>(x,y);
466 <a name=
"l00566"></a>00566 }
467 <a name=
"l00567"></a>00567 }
<span class=
"comment">// namespace std
</span>
468 <a name=
"l00568"></a>00568
469 <a name=
"l00569"></a>00569 <span class=
"keyword">namespace
</span>boost {
<span class=
"keyword">namespace
</span>gil {
470 <a name=
"l00575"></a>00575
471 <a name=
"l00579"></a>00579
472 <a name=
"l00581"></a>00581 <span class=
"keyword">typedef
</span> uint8_t bits8;
473 <a name=
"l00582"></a>00582
474 <a name=
"l00586"></a>00586
475 <a name=
"l00588"></a>00588 <span class=
"keyword">typedef
</span> uint16_t bits16;
476 <a name=
"l00589"></a>00589
477 <a name=
"l00593"></a>00593
478 <a name=
"l00595"></a>00595 <span class=
"keyword">typedef
</span> uint32_t bits32;
479 <a name=
"l00596"></a>00596
480 <a name=
"l00600"></a>00600
481 <a name=
"l00602"></a>00602 <span class=
"keyword">typedef
</span> int8_t bits8s;
482 <a name=
"l00603"></a>00603
483 <a name=
"l00607"></a>00607
484 <a name=
"l00609"></a>00609 <span class=
"keyword">typedef
</span> int16_t bits16s;
485 <a name=
"l00610"></a>00610
486 <a name=
"l00614"></a>00614
487 <a name=
"l00616"></a>00616 <span class=
"keyword">typedef
</span> int32_t bits32s;
488 <a name=
"l00617"></a>00617
489 <a name=
"l00621"></a>00621
490 <a name=
"l00623"></a>00623 <span class=
"keyword">typedef
</span> scoped_channel_value
<float,float_zero,float_one
> bits32f;
491 <a name=
"l00624"></a>00624
492 <a name=
"l00625"></a>00625 } }
<span class=
"comment">// namespace boost::gil
</span>
493 <a name=
"l00626"></a>00626
494 <a name=
"l00627"></a>00627 <span class=
"keyword">namespace
</span>boost {
495 <a name=
"l00628"></a>00628
496 <a name=
"l00629"></a>00629 <span class=
"keyword">template
</span> <<span class=
"keywordtype">int
</span> NumBits
>
497 <a name=
"l00630"></a>00630 <span class=
"keyword">struct
</span>is_integral
<gil::packed_channel_value
<NumBits
> > :
<span class=
"keyword">public
</span> mpl::true_ {};
498 <a name=
"l00631"></a>00631
499 <a name=
"l00632"></a>00632 <span class=
"keyword">template
</span> <<span class=
"keyword">typename
</span> BitField,
<span class=
"keywordtype">int
</span> FirstBit,
<span class=
"keywordtype">int
</span> NumBits,
<span class=
"keywordtype">bool
</span> IsMutable
>
500 <a name=
"l00633"></a>00633 <span class=
"keyword">struct
</span>is_integral
<gil::packed_channel_reference
<BitField,FirstBit,NumBits,IsMutable
> > :
<span class=
"keyword">public
</span> mpl::true_ {};
501 <a name=
"l00634"></a>00634
502 <a name=
"l00635"></a>00635 <span class=
"keyword">template
</span> <<span class=
"keyword">typename
</span> BitField,
<span class=
"keywordtype">int
</span> NumBits,
<span class=
"keywordtype">bool
</span> IsMutable
>
503 <a name=
"l00636"></a>00636 <span class=
"keyword">struct
</span>is_integral
<gil::packed_dynamic_channel_reference
<BitField,NumBits,IsMutable
> > :
<span class=
"keyword">public
</span> mpl::true_ {};
504 <a name=
"l00637"></a>00637
505 <a name=
"l00638"></a>00638 <span class=
"keyword">template
</span> <<span class=
"keyword">typename
</span> BaseChannelValue,
<span class=
"keyword">typename
</span> MinVal,
<span class=
"keyword">typename
</span> MaxVal
>
506 <a name=
"l00639"></a>00639 <span class=
"keyword">struct
</span>is_integral
<gil::scoped_channel_value
<BaseChannelValue,MinVal,MaxVal
> > :
<span class=
"keyword">public
</span> is_integral
<BaseChannelValue
> {};
507 <a name=
"l00640"></a>00640
508 <a name=
"l00641"></a>00641 }
509 <a name=
"l00642"></a>00642
510 <a name=
"l00643"></a>00643 <span class=
"preprocessor">#endif
</span>
512 <hr size=
"1"><address style=
"text-align: right;"><small>Generated on Sat May
2 13:
50:
13 2009 for Generic Image Library by
513 <a href=
"http://www.doxygen.org/index.html">
514 <img src=
"doxygen.png" alt=
"doxygen" align=
"middle" border=
"0"></a> 1.5.6 </small></address>