File indexing completed on 2025-01-18 09:36:55
0001
0002
0003
0004
0005
0006
0007
0008 #ifndef BOOST_GIL_CONCEPTS_PIXEL_HPP
0009 #define BOOST_GIL_CONCEPTS_PIXEL_HPP
0010
0011 #include <boost/gil/concepts/basic.hpp>
0012 #include <boost/gil/concepts/channel.hpp>
0013 #include <boost/gil/concepts/color.hpp>
0014 #include <boost/gil/concepts/color_base.hpp>
0015 #include <boost/gil/concepts/concept_check.hpp>
0016 #include <boost/gil/concepts/fwd.hpp>
0017 #include <boost/gil/concepts/pixel_based.hpp>
0018 #include <boost/gil/concepts/detail/type_traits.hpp>
0019 #include <boost/gil/detail/mp11.hpp>
0020
0021 #include <cstddef>
0022 #include <type_traits>
0023
0024 #if defined(BOOST_CLANG)
0025 #pragma clang diagnostic push
0026 #pragma clang diagnostic ignored "-Wunknown-pragmas"
0027 #pragma clang diagnostic ignored "-Wunused-local-typedefs"
0028 #endif
0029
0030 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
0031 #pragma GCC diagnostic push
0032 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
0033 #endif
0034
0035 namespace boost { namespace gil {
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062 template <typename P>
0063 struct PixelConcept
0064 {
0065 void constraints()
0066 {
0067 gil_function_requires<ColorBaseConcept<P>>();
0068 gil_function_requires<PixelBasedConcept<P>>();
0069
0070 static_assert(is_pixel<P>::value, "");
0071 static const bool is_mutable = P::is_mutable;
0072 ignore_unused_variable_warning(is_mutable);
0073
0074 using value_type = typename P::value_type;
0075
0076
0077
0078 using reference = typename P::reference;
0079 gil_function_requires<PixelConcept
0080 <
0081 typename detail::remove_const_and_reference<reference>::type
0082 >>();
0083
0084 using const_reference = typename P::const_reference;
0085 gil_function_requires<PixelConcept
0086 <
0087 typename detail::remove_const_and_reference<const_reference>::type
0088 >>();
0089 }
0090 };
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100 template <typename P>
0101 struct MutablePixelConcept
0102 {
0103 void constraints()
0104 {
0105 gil_function_requires<PixelConcept<P>>();
0106 static_assert(P::is_mutable, "");
0107 }
0108 };
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119
0120
0121
0122 template <typename P>
0123 struct HomogeneousPixelConcept
0124 {
0125 void constraints()
0126 {
0127 gil_function_requires<PixelConcept<P>>();
0128 gil_function_requires<HomogeneousColorBaseConcept<P>>();
0129 gil_function_requires<HomogeneousPixelBasedConcept<P>>();
0130 p[0];
0131 }
0132 P p;
0133 };
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144
0145
0146
0147 template <typename P>
0148 struct MutableHomogeneousPixelConcept
0149 {
0150 void constraints()
0151 {
0152 gil_function_requires<HomogeneousPixelConcept<P>>();
0153 gil_function_requires<MutableHomogeneousColorBaseConcept<P>>();
0154 p[0] = v;
0155 v = p[0];
0156 }
0157 typename P::template element_type<P>::type v;
0158 P p;
0159 };
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169 template <typename P>
0170 struct PixelValueConcept
0171 {
0172 void constraints()
0173 {
0174 gil_function_requires<PixelConcept<P>>();
0175 gil_function_requires<Regular<P>>();
0176 }
0177 };
0178
0179
0180
0181
0182
0183
0184
0185
0186
0187 template <typename P>
0188 struct HomogeneousPixelValueConcept
0189 {
0190 void constraints()
0191 {
0192 gil_function_requires<HomogeneousPixelConcept<P>>();
0193 gil_function_requires<Regular<P>>();
0194 static_assert(std::is_same<P, typename P::value_type>::value, "");
0195 }
0196 };
0197
0198 namespace detail {
0199
0200 template <typename P1, typename P2, int K>
0201 struct channels_are_pairwise_compatible
0202 : mp11::mp_and
0203 <
0204 channels_are_pairwise_compatible<P1, P2, K - 1>,
0205 channels_are_compatible
0206 <
0207 typename kth_semantic_element_reference_type<P1, K>::type,
0208 typename kth_semantic_element_reference_type<P2, K>::type
0209 >
0210 >
0211 {
0212 };
0213
0214 template <typename P1, typename P2>
0215 struct channels_are_pairwise_compatible<P1, P2, -1> : std::true_type {};
0216
0217 }
0218
0219
0220
0221
0222
0223
0224
0225 template <typename P1, typename P2>
0226 struct pixels_are_compatible
0227 : mp11::mp_and
0228 <
0229 typename color_spaces_are_compatible
0230 <
0231 typename color_space_type<P1>::type,
0232 typename color_space_type<P2>::type
0233 >::type,
0234 detail::channels_are_pairwise_compatible
0235 <
0236 P1, P2, num_channels<P1>::value - 1
0237 >
0238 >
0239 {
0240 };
0241
0242
0243
0244
0245
0246
0247
0248
0249
0250
0251
0252
0253
0254
0255 template <typename P1, typename P2>
0256 struct PixelsCompatibleConcept
0257 {
0258 void constraints()
0259 {
0260 static_assert(pixels_are_compatible<P1, P2>::value, "");
0261 }
0262 };
0263
0264
0265
0266
0267
0268
0269
0270
0271
0272
0273
0274
0275
0276 template <typename SrcP, typename DstP>
0277 struct PixelConvertibleConcept
0278 {
0279 void constraints()
0280 {
0281 gil_function_requires<PixelConcept<SrcP>>();
0282 gil_function_requires<MutablePixelConcept<DstP>>();
0283 color_convert(src, dst);
0284 }
0285 SrcP src;
0286 DstP dst;
0287 };
0288
0289 }}
0290
0291 #if defined(BOOST_CLANG)
0292 #pragma clang diagnostic pop
0293 #endif
0294
0295 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
0296 #pragma GCC diagnostic pop
0297 #endif
0298
0299 #endif