27 #include <boost/type_traits.hpp>
28 #include <boost/utility/enable_if.hpp>
29 #include <boost/concept_check.hpp>
30 #include <boost/iterator/iterator_concepts.hpp>
31 #include <boost/mpl/and.hpp>
32 #include <boost/mpl/size.hpp>
34 namespace boost {
namespace gil {
36 #if defined(__GNUC__) && (__GNUC__ >= 4)
37 #pragma GCC diagnostic push
38 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
41 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
43 #pragma warning(disable:4510) //default constructor could not be generated
44 #pragma warning(disable:4512) //assignment operator could not be generated
45 #pragma warning(disable:4610) //can never be instantiated - user defined constructor required
48 template <
typename T>
struct channel_traits;
49 template <
typename P>
struct is_pixel;
50 template <
typename dstT,
typename srcT>
51 typename channel_traits<dstT>::value_type
channel_convert(
const srcT& val);
53 template <std::
size_t K,
typename T>
const T& axis_value(
const point2<T>& p);
54 template <std::
size_t K,
typename T> T& axis_value(
point2<T>& p);
55 template <
typename ColorBase,
int K>
struct kth_element_type;
56 template <
typename ColorBase,
int K>
struct kth_element_reference_type;
57 template <
typename ColorBase,
int K>
struct kth_element_const_reference_type;
60 template <
typename ColorBase>
struct size;
62 template <
typename T>
struct channel_type;
63 template <
typename T>
struct color_space_type;
64 template <
typename T>
struct channel_mapping_type;
65 template <
typename T>
struct is_planar;
76 namespace detail {
template <
typename Element,
typename Layout,
int K>
struct homogeneous_color_base; }
77 template <
int K,
typename E,
typename L,
int N>
78 typename add_reference<E>::type at_c( detail::homogeneous_color_base<E,L,N>& p);
80 template <
int K,
typename E,
typename L,
int N>
81 typename add_reference<typename add_const<E>::type>::type at_c(
const detail::homogeneous_color_base<E,L,N>& p);
84 template <
int K,
typename P,
typename C,
typename L>
85 typename kth_element_reference_type<packed_pixel<P,C,L>, K>::type
88 template <
int K,
typename P,
typename C,
typename L>
89 typename kth_element_const_reference_type<packed_pixel<P,C,L>,K>::type
94 template <
int K,
typename B,
typename C,
typename L,
bool M>
inline
95 typename kth_element_reference_type<bit_aligned_pixel_reference<B,C,L,M>, K>::type
99 template <
int K,
typename ColorBase>
100 typename disable_if<is_const<ColorBase>,
typename kth_semantic_element_reference_type<ColorBase,K>::type>::type
semantic_at_c(ColorBase& p);
101 template <
int K,
typename ColorBase>
102 typename kth_semantic_element_const_reference_type<ColorBase,K>::type
semantic_at_c(
const ColorBase& p);
104 template <
typename T>
struct dynamic_x_step_type;
105 template <
typename T>
struct dynamic_y_step_type;
106 template <
typename T>
struct transposed_type;
109 template <
typename T>
110 void initialize_it(T&) {}
113 template <
typename T>
114 struct remove_const_and_reference :
public remove_const<typename remove_reference<T>::type> {};
116 #ifdef BOOST_GIL_USE_CONCEPT_CHECK
117 #define GIL_CLASS_REQUIRE(type_var, ns, concept) BOOST_CLASS_REQUIRE(type_var, ns, concept);
118 template <
typename C>
void gil_function_requires() { function_requires<C>(); }
120 #define GIL_CLASS_REQUIRE(T,NS,C)
121 template <
typename C>
void gil_function_requires() {}
132 template <
typename T>
135 function_requires<boost::DefaultConstructibleConcept<T> >();
147 template <
typename T>
150 function_requires<boost::CopyConstructibleConcept<T> >();
163 template <
typename T>
166 function_requires<boost::AssignableConcept<T> >();
178 template <
typename T>
181 function_requires<boost::EqualityComparableConcept<T> >();
192 template <
typename T,
typename U>
195 BOOST_STATIC_ASSERT((boost::is_same<T,U>::value_core));
207 template <
typename T>
224 template <
typename T>
227 gil_function_requires< boost::DefaultConstructibleConcept<T> >();
228 gil_function_requires< boost::CopyConstructibleConcept<T> >();
229 gil_function_requires< boost::EqualityComparableConcept<T> >();
230 gil_function_requires< boost::AssignableConcept<T> >();
231 gil_function_requires< Swappable<T> >();
243 template <
typename T>
246 typedef typename T::type type;
272 template <
typename P>
275 gil_function_requires< Regular<P> >();
277 typedef typename P::value_type value_type;
278 static const std::size_t N=P::num_dimensions; ignore_unused_variable_warning(N);
279 typedef typename P::template axis<0>::coord_t FT;
280 typedef typename P::template axis<N-1>::coord_t LT;
281 FT ft=gil::axis_value<0>(point);
282 axis_value<0>(point)=ft;
283 LT lt=axis_value<N-1>(point);
284 axis_value<N-1>(point)=lt;
309 template <
typename P>
312 gil_function_requires< PointNDConcept<P> >();
313 BOOST_STATIC_ASSERT(P::num_dimensions == 2);
330 struct ForwardIteratorIsMutableConcept {
338 struct BidirectionalIteratorIsMutableConcept {
340 gil_function_requires< ForwardIteratorIsMutableConcept<TT> >();
347 struct RandomAccessIteratorIsMutableConcept {
349 gil_function_requires< BidirectionalIteratorIsMutableConcept<TT> >();
350 typename std::iterator_traits<TT>::difference_type n=0; ignore_unused_variable_warning(n);
372 template <
typename Cs>
379 template <
typename ColorSpace1,
typename ColorSpace2>
380 struct color_spaces_are_compatible :
public is_same<ColorSpace1,ColorSpace2> {};
391 template <
typename Cs1,
typename Cs2>
394 BOOST_STATIC_ASSERT((color_spaces_are_compatible<Cs1,Cs2>::value));
407 template <
typename CM>
446 template <
typename T>
449 gil_function_requires< boost::EqualityComparableConcept<T> >();
466 template <
typename T>
467 struct ChannelIsMutableConcept {
485 template <
typename T>
488 gil_function_requires<ChannelConcept<T> >();
489 gil_function_requires<detail::ChannelIsMutableConcept<T> >();
500 template <
typename T>
503 gil_function_requires<ChannelConcept<T> >();
504 gil_function_requires<Regular<T> >();
520 template <
typename T1,
typename T2>
522 :
public is_same<typename channel_traits<T1>::value_type, typename channel_traits<T2>::value_type> {};
533 template <
typename T1,
typename T2>
551 template <
typename SrcChannel,
typename DstChannel>
554 gil_function_requires<ChannelConcept<SrcChannel> >();
555 gil_function_requires<MutableChannelConcept<DstChannel> >();
556 dst=channel_convert<DstChannel,SrcChannel>(src); ignore_unused_variable_warning(dst);
614 template <
typename ColorBase>
617 gil_function_requires< CopyConstructible<ColorBase> >();
618 gil_function_requires< EqualityComparable<ColorBase> >();
620 typedef typename ColorBase::layout_t::color_space_t color_space_t;
621 gil_function_requires<ColorSpaceConcept<color_space_t> >();
623 typedef typename ColorBase::layout_t::channel_mapping_t channel_mapping_t;
628 typedef typename kth_element_type<ColorBase,num_elements-1>::type TN;
629 typedef typename kth_element_const_reference_type<ColorBase,num_elements-1>::type CR;
631 CR cr=gil::at_c<num_elements-1>(cb); ignore_unused_variable_warning(cr);
634 semantic_at_c<0>(cb);
657 template <
typename ColorBase>
660 gil_function_requires< ColorBaseConcept<ColorBase> >();
661 gil_function_requires< Assignable<ColorBase> >();
662 gil_function_requires< Swappable<ColorBase> >();
664 typedef typename kth_element_reference_type<ColorBase, 0>::type CR;
666 CR r=gil::at_c<0>(cb);
681 template <
typename ColorBase>
684 gil_function_requires< MutableColorBaseConcept<ColorBase> >();
685 gil_function_requires< Regular<ColorBase> >();
701 template <
typename ColorBase>
704 gil_function_requires< ColorBaseConcept<ColorBase> >();
708 typedef typename kth_element_type<ColorBase,0>::type T0;
709 typedef typename kth_element_type<ColorBase,num_elements-1>::type TN;
711 BOOST_STATIC_ASSERT((is_same<T0,TN>::value));
712 typedef typename kth_element_const_reference_type<ColorBase,0>::type CRef0;
713 CRef0 e0=dynamic_at_c(cb,0);
729 template <
typename ColorBase>
732 gil_function_requires< ColorBaseConcept<ColorBase> >();
733 gil_function_requires< HomogeneousColorBaseConcept<ColorBase> >();
734 typedef typename kth_element_reference_type<ColorBase, 0>::type R0;
735 R0 x=dynamic_at_c(cb,0);
736 dynamic_at_c(cb,0) = dynamic_at_c(cb,0);
751 template <
typename ColorBase>
754 gil_function_requires< MutableHomogeneousColorBaseConcept<ColorBase> >();
755 gil_function_requires< Regular<ColorBase> >();
773 template <
typename ColorBase1,
typename ColorBase2>
776 BOOST_STATIC_ASSERT((is_same<
typename ColorBase1::layout_t::color_space_t,
777 typename ColorBase2::layout_t::color_space_t>::value));
828 template <
typename P>
831 typedef typename color_space_type<P>::type color_space_t;
832 gil_function_requires<ColorSpaceConcept<color_space_t> >();
833 typedef typename channel_mapping_type<P>::type channel_mapping_t;
834 gil_function_requires<ChannelMappingConcept<channel_mapping_t> >();
836 static const bool planar = is_planar<P>::type::value; ignore_unused_variable_warning(planar);
841 ignore_unused_variable_warning(nc);
856 template <
typename P>
859 gil_function_requires<PixelBasedConcept<P> >();
860 typedef typename channel_type<P>::type channel_t;
861 gil_function_requires<ChannelConcept<channel_t> >();
890 template <
typename P>
893 gil_function_requires<ColorBaseConcept<P> >();
894 gil_function_requires<PixelBasedConcept<P> >();
896 BOOST_STATIC_ASSERT((is_pixel<P>::value));
897 static const bool is_mutable = P::is_mutable; ignore_unused_variable_warning(is_mutable);
899 typedef typename P::value_type value_type;
902 typedef typename P::reference reference;
903 gil_function_requires<PixelConcept<typename remove_const_and_reference<reference>::type> >();
905 typedef typename P::const_reference const_reference;
906 gil_function_requires<PixelConcept<typename remove_const_and_reference<const_reference>::type> >();
920 template <
typename P>
923 gil_function_requires<PixelConcept<P> >();
924 BOOST_STATIC_ASSERT(P::is_mutable);
936 template <
typename P>
939 gil_function_requires<PixelConcept<P> >();
940 gil_function_requires<HomogeneousColorBaseConcept<P> >();
941 gil_function_requires<HomogeneousPixelBasedConcept<P> >();
956 template <
typename P>
959 gil_function_requires<HomogeneousPixelConcept<P> >();
960 gil_function_requires<MutableHomogeneousColorBaseConcept<P> >();
977 template <
typename P>
980 gil_function_requires<PixelConcept<P> >();
981 gil_function_requires<Regular<P> >();
994 template <
typename P>
997 gil_function_requires<HomogeneousPixelConcept<P> >();
998 gil_function_requires<Regular<P> >();
999 BOOST_STATIC_ASSERT((is_same<P, typename P::value_type>::value));
1004 template <
typename P1,
typename P2,
int K>
1005 struct channels_are_pairwise_compatible :
public
1006 mpl::and_<channels_are_pairwise_compatible<P1,P2,K-1>,
1007 channels_are_compatible<typename kth_semantic_element_reference_type<P1,K>::type,
1008 typename kth_semantic_element_reference_type<P2,K>::type> > {};
1010 template <
typename P1,
typename P2>
1011 struct channels_are_pairwise_compatible<P1,P2,-1> :
public mpl::true_ {};
1018 template <
typename P1,
typename P2>
1020 :
public mpl::and_<typename color_spaces_are_compatible<typename color_space_type<P1>::type,
1021 typename color_space_type<P2>::type>::type,
1022 detail::channels_are_pairwise_compatible<P1,P2,num_channels<P1>::value-1> > {};
1035 template <
typename P1,
typename P2>
1037 void constraints() {
1054 template <
typename SrcP,
typename DstP>
1056 void constraints() {
1057 gil_function_requires<PixelConcept<SrcP> >();
1058 gil_function_requires<MutablePixelConcept<DstP> >();
1091 template <
typename D>
1093 void constraints() {
1094 gil_function_requires< boost::UnaryFunctionConcept<D,
1095 typename remove_const_and_reference<typename D::result_type>::type,
1096 typename D::argument_type> >();
1097 gil_function_requires< boost::DefaultConstructibleConcept<D> >();
1098 gil_function_requires< boost::CopyConstructibleConcept<D> >();
1099 gil_function_requires< boost::AssignableConcept<D> >();
1101 gil_function_requires<PixelConcept<typename remove_const_and_reference<typename D::result_type>::type> >();
1103 typedef typename D::const_t const_t;
1104 gil_function_requires<PixelDereferenceAdaptorConcept<const_t> >();
1105 typedef typename D::value_type value_type;
1106 gil_function_requires<PixelValueConcept<value_type> >();
1107 typedef typename D::reference reference;
1108 typedef typename D::const_reference const_reference;
1110 const bool is_mutable=D::is_mutable; ignore_unused_variable_warning(is_mutable);
1115 template <
typename P>
1116 struct PixelDereferenceAdaptorArchetype {
1117 typedef P argument_type;
1118 typedef P result_type;
1119 typedef PixelDereferenceAdaptorArchetype const_t;
1120 typedef typename remove_reference<P>::type value_type;
1121 typedef typename add_reference<P>::type reference;
1122 typedef reference const_reference;
1123 static const bool is_mutable=
false;
1124 P operator()(P)
const {
throw; }
1143 template <
typename T>
1145 void constraints() {
1146 typedef typename dynamic_x_step_type<T>::type type;
1160 template <
typename T>
1162 void constraints() {
1163 typedef typename dynamic_y_step_type<T>::type type;
1178 template <
typename T>
1180 void constraints() {
1181 typedef typename transposed_type<T>::type type;
1207 template <
typename Iterator>
1209 void constraints() {
1210 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<Iterator> >();
1211 gil_function_requires<PixelBasedConcept<Iterator> >();
1213 typedef typename std::iterator_traits<Iterator>::value_type value_type;
1214 gil_function_requires<PixelValueConcept<value_type> >();
1219 const_t const_it(it); ignore_unused_variable_warning(const_it);
1223 void check_base(mpl::false_) {}
1224 void check_base(mpl::true_) {
1226 gil_function_requires<PixelIteratorConcept<base_t> >();
1233 template <
typename Iterator>
1234 struct PixelIteratorIsMutableConcept {
1235 void constraints() {
1236 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept<Iterator> >();
1237 typedef typename remove_reference<typename std::iterator_traits<Iterator>::reference>::type ref;
1239 gil_function_requires<detail::ChannelIsMutableConcept<channel_t> >();
1252 template <
typename Iterator>
1254 void constraints() {
1255 gil_function_requires<PixelIteratorConcept<Iterator> >();
1256 gil_function_requires<detail::PixelIteratorIsMutableConcept<Iterator> >();
1262 template <
typename Iterator>
1263 struct RandomAccessIteratorIsMemoryBasedConcept {
1264 void constraints() {
1265 std::ptrdiff_t bs=memunit_step(it); ignore_unused_variable_warning(bs);
1266 it=memunit_advanced(it,3);
1267 std::ptrdiff_t bd=memunit_distance(it,it); ignore_unused_variable_warning(bd);
1268 memunit_advance(it,3);
1293 template <
typename Iterator>
1295 void constraints() {
1296 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<Iterator> >();
1297 gil_function_requires<detail::RandomAccessIteratorIsMemoryBasedConcept<Iterator> >();
1312 template <
typename Iterator>
1314 void constraints() {
1315 gil_function_requires<boost_concepts::ForwardTraversalConcept<Iterator> >();
1330 template <
typename Iterator>
1332 void constraints() {
1333 gil_function_requires<StepIteratorConcept<Iterator> >();
1334 gil_function_requires<detail::ForwardIteratorIsMutableConcept<Iterator> >();
1369 template <
typename Iterator>
1371 void constraints() {
1372 gil_function_requires<boost_concepts::ForwardTraversalConcept<Iterator> >();
1375 gil_function_requires<boost_concepts::ForwardTraversalConcept<base_t> >();
1380 base_t base=it.base(); ignore_unused_variable_warning(base);
1392 template <
typename Iterator>
1394 void constraints() {
1395 gil_function_requires<IteratorAdaptorConcept<Iterator> >();
1396 gil_function_requires<detail::ForwardIteratorIsMutableConcept<Iterator> >();
1466 template <
typename Loc>
1468 void constraints() {
1469 gil_function_requires< Regular<Loc> >();
1471 typedef typename Loc::value_type value_type;
1472 typedef typename Loc::reference reference;
1473 typedef typename Loc::difference_type difference_type;
1474 typedef typename Loc::cached_location_t cached_location_t;
1475 typedef typename Loc::const_t const_t;
1476 typedef typename Loc::point_t point_t;
1477 static const std::size_t N=Loc::num_dimensions; ignore_unused_variable_warning(N);
1479 typedef typename Loc::template axis<0>::iterator first_it_type;
1480 typedef typename Loc::template axis<N-1>::iterator last_it_type;
1481 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<first_it_type> >();
1482 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<last_it_type> >();
1485 gil_function_requires<PointNDConcept<point_t> >();
1486 BOOST_STATIC_ASSERT(point_t::num_dimensions==N);
1487 BOOST_STATIC_ASSERT((is_same<
typename std::iterator_traits<first_it_type>::difference_type,
typename point_t::template axis<0>::coord_t>::value));
1488 BOOST_STATIC_ASSERT((is_same<
typename std::iterator_traits<last_it_type>::difference_type,
typename point_t::template axis<N-1>::coord_t>::value));
1495 reference r1=loc[d]; ignore_unused_variable_warning(r1);
1496 reference r2=*loc; ignore_unused_variable_warning(r2);
1497 cached_location_t cl=loc.cache_location(d); ignore_unused_variable_warning(cl);
1498 reference r3=loc[d]; ignore_unused_variable_warning(r3);
1500 first_it_type fi=loc.template axis_iterator<0>();
1501 fi=loc.template axis_iterator<0>(d);
1502 last_it_type li=loc.template axis_iterator<N-1>();
1503 li=loc.template axis_iterator<N-1>(d);
1505 typedef PixelDereferenceAdaptorArchetype<typename Loc::value_type> deref_t;
1506 typedef typename Loc::template add_deref<deref_t>::type dtype;
1552 template <
typename Loc>
1554 void constraints() {
1555 gil_function_requires<RandomAccessNDLocatorConcept<Loc> >();
1556 BOOST_STATIC_ASSERT(Loc::num_dimensions==2);
1558 typedef typename dynamic_x_step_type<Loc>::type dynamic_x_step_t;
1559 typedef typename dynamic_y_step_type<Loc>::type dynamic_y_step_t;
1560 typedef typename transposed_type<Loc>::type transposed_t;
1562 typedef typename Loc::cached_location_t cached_location_t;
1563 gil_function_requires<Point2DConcept<typename Loc::point_t> >();
1565 typedef typename Loc::x_iterator x_iterator;
1566 typedef typename Loc::y_iterator y_iterator;
1567 typedef typename Loc::x_coord_t x_coord_t;
1568 typedef typename Loc::y_coord_t y_coord_t;
1570 x_coord_t xd=0; ignore_unused_variable_warning(xd);
1571 y_coord_t yd=0; ignore_unused_variable_warning(yd);
1573 typename Loc::difference_type d;
1574 typename Loc::reference r=loc(xd,yd); ignore_unused_variable_warning(r);
1576 dynamic_x_step_t loc2(dynamic_x_step_t(), yd);
1577 dynamic_x_step_t loc3(dynamic_x_step_t(), xd, yd);
1579 typedef typename dynamic_y_step_type<typename dynamic_x_step_type<transposed_t>::type>::type dynamic_xy_step_transposed_t;
1580 dynamic_xy_step_transposed_t loc4(loc, xd,yd,
true);
1582 bool is_contiguous=loc.is_1d_traversable(xd); ignore_unused_variable_warning(is_contiguous);
1583 loc.y_distance_to(loc, xd);
1586 loc=loc.xy_at(xd,yd);
1588 x_iterator xit=loc.x_at(d);
1589 xit=loc.x_at(xd,yd);
1592 y_iterator yit=loc.y_at(d);
1593 yit=loc.y_at(xd,yd);
1596 cached_location_t cl=loc.cache_location(xd,yd); ignore_unused_variable_warning(cl);
1615 template <
typename Loc>
1617 void constraints() {
1618 gil_function_requires< RandomAccess2DLocatorConcept<Loc> >();
1619 gil_function_requires< PixelIteratorConcept<typename Loc::x_iterator> >();
1620 gil_function_requires< PixelIteratorConcept<typename Loc::y_iterator> >();
1621 typedef typename Loc::coord_t coord_t;
1622 BOOST_STATIC_ASSERT((is_same<typename Loc::x_coord_t, typename Loc::y_coord_t>::value));
1628 template <
typename Loc>
1629 struct RandomAccessNDLocatorIsMutableConcept {
1630 void constraints() {
1631 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept<typename Loc::template axis<0>::iterator> >();
1632 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept<
typename Loc::template axis<Loc::num_dimensions-1>::iterator> >();
1634 typename Loc::difference_type d; initialize_it(d);
1635 typename Loc::value_type v;initialize_it(v);
1636 typename Loc::cached_location_t cl=loc.cache_location(d);
1644 template <
typename Loc>
1645 struct RandomAccess2DLocatorIsMutableConcept {
1646 void constraints() {
1647 gil_function_requires<detail::RandomAccessNDLocatorIsMutableConcept<Loc> >();
1648 typename Loc::x_coord_t xd=0; ignore_unused_variable_warning(xd);
1649 typename Loc::y_coord_t yd=0; ignore_unused_variable_warning(yd);
1650 typename Loc::value_type v; initialize_it(v);
1666 template <
typename Loc>
1668 void constraints() {
1669 gil_function_requires<RandomAccessNDLocatorConcept<Loc> >();
1670 gil_function_requires<detail::RandomAccessNDLocatorIsMutableConcept<Loc> >();
1681 template <
typename Loc>
1683 void constraints() {
1684 gil_function_requires< RandomAccess2DLocatorConcept<Loc> >();
1685 gil_function_requires<detail::RandomAccess2DLocatorIsMutableConcept<Loc> >();
1696 template <
typename Loc>
1698 void constraints() {
1699 gil_function_requires<PixelLocatorConcept<Loc> >();
1700 gil_function_requires<detail::RandomAccess2DLocatorIsMutableConcept<Loc> >();
1773 template <
typename View>
1775 void constraints() {
1776 gil_function_requires< Regular<View> >();
1778 typedef typename View::value_type value_type;
1779 typedef typename View::reference reference;
1780 typedef typename View::difference_type difference_type;
1781 typedef typename View::const_t const_t;
1782 typedef typename View::point_t point_t;
1783 typedef typename View::locator locator;
1784 typedef typename View::iterator iterator;
1785 typedef typename View::reverse_iterator reverse_iterator;
1786 typedef typename View::size_type size_type;
1787 static const std::size_t N=View::num_dimensions;
1789 gil_function_requires<RandomAccessNDLocatorConcept<locator> >();
1790 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<iterator> >();
1791 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<reverse_iterator> >();
1793 typedef typename View::template axis<0>::iterator first_it_type;
1794 typedef typename View::template axis<N-1>::iterator last_it_type;
1795 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<first_it_type> >();
1796 gil_function_requires<boost_concepts::RandomAccessTraversalConcept<last_it_type> >();
1802 gil_function_requires<PointNDConcept<point_t> >();
1803 BOOST_STATIC_ASSERT(point_t::num_dimensions==N);
1804 BOOST_STATIC_ASSERT((is_same<
typename std::iterator_traits<first_it_type>::difference_type,
typename point_t::template axis<0>::coord_t>::value));
1805 BOOST_STATIC_ASSERT((is_same<
typename std::iterator_traits<last_it_type>::difference_type,
typename point_t::template axis<N-1>::coord_t>::value));
1810 reverse_iterator rit;
1811 difference_type d; detail::initialize_it(d); ignore_unused_variable_warning(d);
1815 p=view.dimensions();
1817 size_type sz=view.size(); ignore_unused_variable_warning(sz);
1818 bool is_contiguous=view.is_1d_traversable(); ignore_unused_variable_warning(is_contiguous);
1825 reference r1=view[d]; ignore_unused_variable_warning(r1);
1826 reference r2=view(p); ignore_unused_variable_warning(r2);
1829 first_it_type fi=view.template axis_iterator<0>(p); ignore_unused_variable_warning(fi);
1830 last_it_type li=view.template axis_iterator<N-1>(p); ignore_unused_variable_warning(li);
1832 typedef PixelDereferenceAdaptorArchetype<typename View::value_type> deref_t;
1833 typedef typename View::template add_deref<deref_t>::type dtype;
1877 template <
typename View>
1879 void constraints() {
1880 gil_function_requires<RandomAccessNDImageViewConcept<View> >();
1881 BOOST_STATIC_ASSERT(View::num_dimensions==2);
1884 gil_function_requires<RandomAccess2DLocatorConcept<typename View::locator> >();
1886 typedef typename dynamic_x_step_type<View>::type dynamic_x_step_t;
1887 typedef typename dynamic_y_step_type<View>::type dynamic_y_step_t;
1888 typedef typename transposed_type<View>::type transposed_t;
1890 typedef typename View::x_iterator x_iterator;
1891 typedef typename View::y_iterator y_iterator;
1892 typedef typename View::x_coord_t x_coord_t;
1893 typedef typename View::y_coord_t y_coord_t;
1894 typedef typename View::xy_locator xy_locator;
1896 x_coord_t xd=0; ignore_unused_variable_warning(xd);
1897 y_coord_t yd=0; ignore_unused_variable_warning(yd);
1900 typename View::point_t d;
1902 View(xd,yd,xy_locator());
1904 xy_locator lc=view.xy_at(xd,yd);
1907 typename View::reference r=view(xd,yd); ignore_unused_variable_warning(r);
1912 xit=view.x_at(xd,yd);
1913 xit=view.row_begin(xd);
1914 xit=view.row_end(xd);
1917 yit=view.y_at(xd,yd);
1918 yit=view.col_begin(xd);
1919 yit=view.col_end(xd);
1941 template <
typename View>
1943 void constraints() {
1944 gil_function_requires<RandomAccess2DImageViewConcept<View> >();
1947 gil_function_requires<PixelLocatorConcept<typename View::xy_locator> >();
1949 BOOST_STATIC_ASSERT((is_same<typename View::x_coord_t, typename View::y_coord_t>::value));
1951 typedef typename View::coord_t coord_t;
1952 std::size_t num_chan = view.num_channels(); ignore_unused_variable_warning(num_chan);
1959 template <
typename View>
1960 struct RandomAccessNDImageViewIsMutableConcept {
1961 void constraints() {
1962 gil_function_requires<detail::RandomAccessNDLocatorIsMutableConcept<typename View::locator> >();
1964 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept<typename View::iterator> >();
1965 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept<typename View::reverse_iterator> >();
1966 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept<typename View::template axis<0>::iterator> >();
1967 gil_function_requires<detail::RandomAccessIteratorIsMutableConcept<
typename View::template axis<View::num_dimensions-1>::iterator> >();
1969 typename View::difference_type diff; initialize_it(diff); ignore_unused_variable_warning(diff);
1970 typename View::point_t pt;
1971 typename View::value_type v; initialize_it(v);
1979 template <
typename View>
1980 struct RandomAccess2DImageViewIsMutableConcept {
1981 void constraints() {
1982 gil_function_requires<detail::RandomAccessNDImageViewIsMutableConcept<View> >();
1983 typename View::x_coord_t xd=0; ignore_unused_variable_warning(xd);
1984 typename View::y_coord_t yd=0; ignore_unused_variable_warning(yd);
1985 typename View::value_type v; initialize_it(v);
1991 template <
typename View>
1992 struct PixelImageViewIsMutableConcept {
1993 void constraints() {
1994 gil_function_requires<detail::RandomAccess2DImageViewIsMutableConcept<View> >();
2008 template <
typename View>
2010 void constraints() {
2011 gil_function_requires<RandomAccessNDImageViewConcept<View> >();
2012 gil_function_requires<detail::RandomAccessNDImageViewIsMutableConcept<View> >();
2023 template <
typename View>
2025 void constraints() {
2026 gil_function_requires<RandomAccess2DImageViewConcept<View> >();
2027 gil_function_requires<detail::RandomAccess2DImageViewIsMutableConcept<View> >();
2038 template <
typename View>
2040 void constraints() {
2041 gil_function_requires<ImageViewConcept<View> >();
2042 gil_function_requires<detail::PixelImageViewIsMutableConcept<View> >();
2049 template <
typename V1,
typename V2>
2061 template <
typename V1,
typename V2>
2063 void constraints() {
2099 template <
typename Img>
2101 void constraints() {
2102 gil_function_requires<Regular<Img> >();
2104 typedef typename Img::view_t view_t;
2105 gil_function_requires<MutableRandomAccessNDImageViewConcept<view_t> >();
2107 typedef typename Img::const_view_t const_view_t;
2108 typedef typename Img::value_type pixel_t;
2110 typedef typename Img::point_t point_t;
2111 gil_function_requires<PointNDConcept<point_t> >();
2113 const_view_t cv =
const_view(img); ignore_unused_variable_warning(cv);
2114 view_t v =
view(img); ignore_unused_variable_warning(v);
2117 point_t pt=img.dimensions();
2120 Img im3(pt,fill_value,1);
2123 img.recreate(pt,fill_value,1);
2148 template <
typename Img>
2150 void constraints() {
2151 gil_function_requires<RandomAccessNDImageConcept<Img> >();
2152 typedef typename Img::x_coord_t x_coord_t;
2153 typedef typename Img::y_coord_t y_coord_t;
2154 typedef typename Img::value_type value_t;
2156 gil_function_requires<MutableRandomAccess2DImageViewConcept<typename Img::view_t> >();
2158 x_coord_t w=img.width();
2159 y_coord_t h=img.height();
2163 Img im3(w,h,fill_value,1);
2165 img.recreate(w,h,1);
2166 img.recreate(w,h,fill_value,1);
2181 template <
typename Img>
2183 void constraints() {
2184 gil_function_requires<RandomAccess2DImageConcept<Img> >();
2185 gil_function_requires<MutableImageViewConcept<typename Img::view_t> >();
2186 typedef typename Img::coord_t coord_t;
2189 BOOST_STATIC_ASSERT((is_same<coord_t, typename Img::x_coord_t>::value));
2190 BOOST_STATIC_ASSERT((is_same<coord_t, typename Img::y_coord_t>::value));
2195 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
2196 #pragma warning(pop)
2199 #if defined(__GNUC__) && (__GNUC__ >= 4)
2200 #pragma GCC diagnostic pop
Represents a unary function object that can be invoked upon dereferencing a pixel iterator...
Definition: gil_concept.hpp:1092
Concept for iterators, locators and views that can define a type just like the given iterator/locator...
Definition: gil_concept.hpp:1144
metafunction predicate determining whether the given iterator is a plain one or an adaptor over anoth...
Definition: gil_concept.hpp:70
Homogeneous color base that also has a default constructor. Refines Regular.
Definition: gil_concept.hpp:752
Definition: gil_concept.hpp:179
Homogeneous pixel concept that allows for changing its channels.
Definition: gil_concept.hpp:957
2-dimensional view over mutable values
Definition: gil_concept.hpp:2024
Homogeneous color base that allows for modifying its elements.
Definition: gil_concept.hpp:730
Pixel iterator that allows for changing its pixel.
Definition: gil_concept.hpp:1253
Definition: gil_concept.hpp:193
N-dimensional locator over mutable pixels.
Definition: gil_concept.hpp:1667
Definition: gil_concept.hpp:148
Concept of a random-access iterator that can be advanced in memory units (bytes or bits) ...
Definition: gil_concept.hpp:1294
disable_if< is_const< ColorBase >, typename kth_semantic_element_reference_type< ColorBase, K >::type >::type semantic_at_c(ColorBase &p)
A mutable accessor to the K-th semantic element of a color base.
Definition: color_base_algorithm.hpp:122
2-dimensional locator over mutable pixels
Definition: gil_concept.hpp:1682
returns the base iterator for a given iterator adaptor. Provide an specialization when introducing ne...
Definition: gil_concept.hpp:72
Two color bases are compatible if they have the same color space and their elements are compatible...
Definition: gil_concept.hpp:774
Iterator adaptor is a forward iterator adapting another forward iterator.
Definition: gil_concept.hpp:1370
Concept for pixel compatibility Pixels are compatible if their channels and color space types are com...
Definition: gil_concept.hpp:1036
N-dimensional view over mutable values.
Definition: gil_concept.hpp:2009
Pixel concept that is a Regular type.
Definition: gil_concept.hpp:978
channel_traits< DstChannel >::value_type channel_convert(const SrcChannel &src)
Converting from one channel type to another.
Definition: channel_algorithm.hpp:420
N-dimensional container of values.
Definition: gil_concept.hpp:2100
Step iterator that allows for modifying its current value.
Definition: gil_concept.hpp:1331
Specifies the element type of a homogeneous color base.
Definition: color_base_algorithm.hpp:216
Concept for locators and views that can define a type just like the given locator or view...
Definition: gil_concept.hpp:1161
Definition: gil_concept.hpp:208
A channel is convertible to another one if the channel_convert algorithm is defined for the two chann...
Definition: gil_concept.hpp:552
2-dimensional image whose value type models PixelValueConcept
Definition: gil_concept.hpp:2182
Heterogeneous pixel reference corresponding to non-byte-aligned bit range. Models ColorBaseConcept...
Definition: bit_aligned_pixel_reference.hpp:125
A color base is a container of color elements (such as channels, channel references or channel pointe...
Definition: gil_concept.hpp:615
A channel is the building block of a color. Color is defined as a mixture of primary colors and a cha...
Definition: gil_concept.hpp:447
Concept for homogeneous pixel-based GIL constructs.
Definition: gil_concept.hpp:857
Color base which allows for modifying its elements.
Definition: gil_concept.hpp:658
2-dimensional locator over immutable values
Definition: gil_concept.hpp:1553
Specifies the return type of the mutable semantic_at_c<K>(color_base);.
Definition: color_base_algorithm.hpp:104
Concept for all pixel-based GIL constructs, such as pixels, iterators, locators, views and images who...
Definition: gil_concept.hpp:829
Definition: gil_concept.hpp:133
Returns whether two views are compatible.
Definition: gil_concept.hpp:2050
A channel that supports default construction.
Definition: gil_concept.hpp:501
Concept for locators and views that can define a type just like the given locator or view...
Definition: gil_concept.hpp:1179
Predicate metafunction returning whether two channels are compatibleChannels are considered compatibl...
Definition: gil_concept.hpp:521
GIL's 2-dimensional locator over immutable GIL pixels.
Definition: gil_concept.hpp:1616
Channel mapping concept.
Definition: gil_concept.hpp:408
Homogeneous pixel concept that is a Regular type.
Definition: gil_concept.hpp:995
Homogeneous pixel concept.
Definition: gil_concept.hpp:937
Pixel concept that allows for changing its channels.
Definition: gil_concept.hpp:921
Color space type concept.
Definition: gil_concept.hpp:373
Definition: gil_concept.hpp:164
Pixel convertible concept.
Definition: gil_concept.hpp:1055
GIL's 2-dimensional view over mutable GIL pixels.
Definition: gil_concept.hpp:2039
Traits for channels. Contains the following members:
Definition: channel.hpp:114
Channels are compatible if their associated value types (ignoring constness and references) are the s...
Definition: gil_concept.hpp:534
2-dimensional container of values
Definition: gil_concept.hpp:2149
void color_convert(const SrcP &src, DstP &dst)
helper function for converting one pixel to another using GIL default color-converters where ScrP mod...
Definition: color_convert.hpp:311
N-dimensional point concept.
Definition: gil_concept.hpp:273
Color base that also has a default-constructor. Refines Regular.
Definition: gil_concept.hpp:682
2-dimensional point concept
Definition: gil_concept.hpp:310
Changes the base iterator of an iterator adaptor. Provide an specialization when introducing new iter...
Definition: gil_concept.hpp:71
Returns whether two pixels are compatible.
Definition: gil_concept.hpp:1019
Iterator adaptor that is mutable.
Definition: gil_concept.hpp:1393
GIL's 2-dimensional view over immutable GIL pixels.
Definition: gil_concept.hpp:1942
const image< Pixel, IsPlanar, Alloc >::view_t & view(image< Pixel, IsPlanar, Alloc > &img)
Returns the non-constant-pixel view of an image.
Definition: image.hpp:480
Two color spaces are compatible if they are the same.
Definition: gil_concept.hpp:392
Metafunction predicate returning whether the given iterator allows for changing its values...
Definition: gil_concept.hpp:69
2-dimensional view over immutable values
Definition: gil_concept.hpp:1878
Heterogeneous pixel value whose channel references can be constructed from the pixel bitfield and the...
Definition: gil_concept.hpp:83
Returns an MPL integral type specifying the number of elements in a color base.
Definition: color_base_algorithm.hpp:61
2D point both axes of which have the same dimension typeModels: Point2DConcept
Definition: gil_concept.hpp:52
An STL random access traversal iterator over a model of PixelConcept.
Definition: gil_concept.hpp:1208
const image< Pixel, IsPlanar, Alloc >::const_view_t const_view(const image< Pixel, IsPlanar, Alloc > &img)
Returns the constant-pixel view of an image.
Definition: image.hpp:484
Views are compatible if they have the same color spaces and compatible channel values. Constness and layout are not important for compatibility.
Definition: gil_concept.hpp:2062
Returns the type of an iterator just like the input iterator, except operating over immutable values...
Definition: gil_concept.hpp:68
Step iterator concept.
Definition: gil_concept.hpp:1313
N-dimensional view over immutable values.
Definition: gil_concept.hpp:1774
Returns the number of channels of a pixel-based GIL construct.
Definition: gil_concept.hpp:66
A channel that allows for modifying its value.
Definition: gil_concept.hpp:486
Specifies the return type of the constant semantic_at_c<K>(color_base);.
Definition: color_base_algorithm.hpp:112
Color base whose elements all have the same type.
Definition: gil_concept.hpp:702
N-dimensional locator over immutable values.
Definition: gil_concept.hpp:1467
Definition: gil_concept.hpp:225
Pixel concept - A color base whose elements are channels.
Definition: gil_concept.hpp:891
GIL's 2-dimensional locator over mutable GIL pixels.
Definition: gil_concept.hpp:1697