// // Copyright 2005-2007 Adobe Systems Incorporated // // Distributed under the Boost Software License, Version 1.0 // See accompanying file LICENSE_1_0.txt or copy at // http://www.boost.org/LICENSE_1_0.txt // #ifndef BOOST_GIL_CONCEPTS_PIXEL_HPP #define BOOST_GIL_CONCEPTS_PIXEL_HPP #include #include #include #include #include #include #include #include #include #include #include #if defined(BOOST_CLANG) #pragma clang diagnostic push #pragma clang diagnostic ignored "-Wunknown-pragmas" #pragma clang diagnostic ignored "-Wunused-local-typedefs" #endif #if defined(BOOST_GCC) && (BOOST_GCC >= 40900) #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wunused-local-typedefs" #endif namespace boost { namespace gil { /// \brief Pixel concept - A color base whose elements are channels /// \ingroup PixelConcept /// \code /// concept PixelConcept : ColorBaseConcept

, PixelBasedConcept

/// { /// where is_pixel

::value == true; /// // where for each K [0..size

::value - 1]: /// // ChannelConcept>; /// /// typename P::value_type; /// where PixelValueConcept; /// typename P::reference; /// where PixelConcept; /// typename P::const_reference; /// where PixelConcept; /// static const bool P::is_mutable; /// /// template where { PixelConcept } /// P::P(P2); /// template where { PixelConcept } /// bool operator==(const P&, const P2&); /// template where { PixelConcept } /// bool operator!=(const P&, const P2&); /// }; /// \endcode template struct PixelConcept { void constraints() { gil_function_requires>(); gil_function_requires>(); static_assert(is_pixel

::value, ""); static const bool is_mutable = P::is_mutable; ignore_unused_variable_warning(is_mutable); using value_type = typename P::value_type; // TODO: Is the cyclic dependency intentional? --mloskot // gil_function_requires>(); using reference = typename P::reference; gil_function_requires::type >>(); using const_reference = typename P::const_reference; gil_function_requires::type >>(); } }; /// \brief Pixel concept that allows for changing its channels /// \ingroup PixelConcept /// \code /// concept MutablePixelConcept : MutableColorBaseConcept

/// { /// where is_mutable==true; /// }; /// \endcode template struct MutablePixelConcept { void constraints() { gil_function_requires>(); static_assert(P::is_mutable, ""); } }; /// \brief Homogeneous pixel concept /// \ingroup PixelConcept /// \code /// concept HomogeneousPixelConcept /// : HomogeneousColorBaseConcept

, HomogeneousPixelBasedConcept

/// { /// P::template element_const_reference_type

::type operator[](P p, std::size_t i) const /// { /// return dynamic_at_c(p,i); /// } /// }; /// \endcode template struct HomogeneousPixelConcept { void constraints() { gil_function_requires>(); gil_function_requires>(); gil_function_requires>(); p[0]; } P p; }; /// \brief Homogeneous pixel concept that allows for changing its channels /// \ingroup PixelConcept /// \code /// concept MutableHomogeneousPixelConcept /// : MutableHomogeneousColorBaseConcept

/// { /// P::template element_reference_type

::type operator[](P p, std::size_t i) /// { /// return dynamic_at_c(p, i); /// } /// }; /// \endcode template struct MutableHomogeneousPixelConcept { void constraints() { gil_function_requires>(); gil_function_requires>(); p[0] = v; v = p[0]; } typename P::template element_type

::type v; P p; }; /// \brief Pixel concept that is a Regular type /// \ingroup PixelConcept /// \code /// concept PixelValueConcept : Regular

/// { /// where SameType; /// }; /// \endcode template struct PixelValueConcept { void constraints() { gil_function_requires>(); gil_function_requires>(); } }; /// \brief Homogeneous pixel concept that is a Regular type /// \ingroup PixelConcept /// \code /// concept HomogeneousPixelValueConcept : Regular

/// { /// where SameType; /// }; /// \endcode template struct HomogeneousPixelValueConcept { void constraints() { gil_function_requires>(); gil_function_requires>(); static_assert(std::is_same::value, ""); } }; namespace detail { template struct channels_are_pairwise_compatible : mp11::mp_and < channels_are_pairwise_compatible, channels_are_compatible < typename kth_semantic_element_reference_type::type, typename kth_semantic_element_reference_type::type > > { }; template struct channels_are_pairwise_compatible : std::true_type {}; } // namespace detail /// \ingroup PixelAlgorithm /// \brief Returns whether two pixels are compatible /// Pixels are compatible if their channels and color space types are compatible. /// Compatible pixels can be assigned and copy constructed from one another. /// \tparam P1 Models PixelConcept /// \tparam P2 Models PixelConcept template struct pixels_are_compatible : mp11::mp_and < typename color_spaces_are_compatible < typename color_space_type::type, typename color_space_type::type >::type, detail::channels_are_pairwise_compatible < P1, P2, num_channels::value - 1 > > { }; /// \ingroup PixelConcept /// \brief Concept for pixel compatibility /// Pixels are compatible if their channels and color space types are compatible. /// Compatible pixels can be assigned and copy constructed from one another. /// \tparam P1 Models PixelConcept /// \tparam P2 Models PixelConcept /// \code /// concept PixelsCompatibleConcept /// : ColorBasesCompatibleConcept { /// // where for each K [0..size::value): /// // ChannelsCompatibleConcept::type, kth_semantic_element_type::type>; /// }; /// \endcode template struct PixelsCompatibleConcept { void constraints() { static_assert(pixels_are_compatible::value, ""); } }; /// \ingroup PixelConcept /// \brief Pixel convertible concept /// Convertibility is non-symmetric and implies that one pixel /// can be converted to another, approximating the color. /// Conversion is explicit and sometimes lossy. /// \code /// template /// concept PixelConvertibleConcept /// { /// void color_convert(const SrcPixel&, DstPixel&); /// }; /// \endcode template struct PixelConvertibleConcept { void constraints() { gil_function_requires>(); gil_function_requires>(); color_convert(src, dst); } SrcP src; DstP dst; }; }} // namespace boost::gil #if defined(BOOST_CLANG) #pragma clang diagnostic pop #endif #if defined(BOOST_GCC) && (BOOST_GCC >= 40900) #pragma GCC diagnostic pop #endif #endif