100 detail::homogeneous_color_base
104 mp11::mp_size<typename Layout::color_space_t>::value
108 using channel_t = ChannelValue;
109 using parent_t = detail::homogeneous_color_base
113 mp11::mp_size<typename Layout::color_space_t>::value
119 static constexpr bool is_mutable = channel_traits<channel_t>::is_mutable;
122 explicit pixel(channel_t v) : parent_t(v) {}
123 pixel(channel_t v0, channel_t v1) : parent_t(v0, v1) {}
124 pixel(channel_t v0, channel_t v1, channel_t v2) : parent_t(v0, v1, v2) {}
126 pixel(channel_t v0, channel_t v1, channel_t v2, channel_t v3)
127 : parent_t(v0, v1, v2, v3)
130 pixel(channel_t v0, channel_t v1, channel_t v2, channel_t v3, channel_t v4)
131 : parent_t(v0, v1, v2, v3, v4)
134 pixel(channel_t v0, channel_t v1, channel_t v2, channel_t v3, channel_t v4, channel_t v5)
135 : parent_t(v0, v1, v2, v3, v4, v5)
142 static_copy(p,*
this);
147 template <
typename Pixel>
148 pixel(Pixel
const& p,
149 typename std::enable_if<is_pixel<Pixel>::value>::type* =
nullptr)
152 check_compatible<Pixel>();
155 template <
typename Pixel>
156 pixel& operator=(Pixel
const& p)
158 assign(p, is_pixel<Pixel>());
162 template <
typename Pixel>
163 bool operator==(Pixel
const& p)
const {
return equal(p, is_pixel<Pixel>()); }
165 template <
typename Pixel>
166 bool operator!=(Pixel
const& p)
const {
return !(*
this == p); }
169 auto operator[](std::size_t index)
170 ->
typename channel_traits<channel_t>::reference
172 return dynamic_at_c(*
this, index);
175 auto operator[](std::size_t index)
const
176 ->
typename channel_traits<channel_t>::const_reference
178 return dynamic_at_c(*
this, index);
182 template <
typename Pixel>
183 void assign(Pixel
const& p, std::true_type)
185 check_compatible<Pixel>();
186 static_copy(p, *
this);
189 template <
typename Pixel>
190 bool equal(Pixel
const& p, std::true_type)
const
192 check_compatible<Pixel>();
193 return static_equal(*
this, p);
196 template <
typename Pixel>
197 void check_compatible()
const
199 gil_function_requires<PixelsCompatibleConcept<Pixel, pixel>>();
205 static void check_gray()
207 static_assert(std::is_same<typename Layout::color_space_t, gray_t>::value,
"");
210 template <
typename Channel>
211 void assign(Channel
const& channel, std::false_type)
214 gil::at_c<0>(*
this) = channel;
217 template <
typename Channel>
218 bool equal (Channel
const& channel, std::false_type)
const
221 return gil::at_c<0>(*
this) == channel;
225 pixel& operator= (channel_t channel)
228 gil::at_c<0>(*
this) = channel;
232 bool operator==(channel_t channel)
const
235 return gil::at_c<0>(*
this) == channel;