Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:36:55

0001 //
0002 // Copyright 2005-2007 Adobe Systems Incorporated
0003 //
0004 // Distributed under the Boost Software License, Version 1.0
0005 // See accompanying file LICENSE_1_0.txt or copy at
0006 // http://www.boost.org/LICENSE_1_0.txt
0007 //
0008 #ifndef BOOST_GIL_CONCEPTS_IMAGE_HPP
0009 #define BOOST_GIL_CONCEPTS_IMAGE_HPP
0010 
0011 #include <boost/gil/concepts/basic.hpp>
0012 #include <boost/gil/concepts/concept_check.hpp>
0013 #include <boost/gil/concepts/fwd.hpp>
0014 #include <boost/gil/concepts/image_view.hpp>
0015 #include <boost/gil/concepts/point.hpp>
0016 #include <boost/gil/detail/mp11.hpp>
0017 
0018 #include <type_traits>
0019 
0020 #if defined(BOOST_CLANG)
0021 #pragma clang diagnostic push
0022 #pragma clang diagnostic ignored "-Wunknown-pragmas"
0023 #pragma clang diagnostic ignored "-Wunused-local-typedefs"
0024 #endif
0025 
0026 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
0027 #pragma GCC diagnostic push
0028 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
0029 #endif
0030 
0031 namespace boost { namespace gil {
0032 
0033 /// \ingroup ImageConcept
0034 /// \brief N-dimensional container of values
0035 ///
0036 /// \code
0037 /// concept RandomAccessNDImageConcept<typename Image> : Regular<Image>
0038 /// {
0039 ///     typename view_t; where MutableRandomAccessNDImageViewConcept<view_t>;
0040 ///     typename const_view_t = view_t::const_t;
0041 ///     typename point_t      = view_t::point_t;
0042 ///     typename value_type   = view_t::value_type;
0043 ///     typename allocator_type;
0044 ///
0045 ///     Image::Image(point_t dims, std::size_t alignment=1);
0046 ///     Image::Image(point_t dims, value_type fill_value, std::size_t alignment);
0047 ///
0048 ///     void Image::recreate(point_t new_dims, std::size_t alignment=1);
0049 ///     void Image::recreate(point_t new_dims, value_type fill_value, std::size_t alignment);
0050 ///
0051 ///     point_t const&        Image::dimensions() const;
0052 ///     const const_view_t&   const_view(const Image&);
0053 ///     const view_t&         view(Image&);
0054 /// };
0055 /// \endcode
0056 template <typename Image>
0057 struct RandomAccessNDImageConcept
0058 {
0059     void constraints()
0060     {
0061         gil_function_requires<Regular<Image>>();
0062 
0063         using view_t = typename Image::view_t;
0064         gil_function_requires<MutableRandomAccessNDImageViewConcept<view_t>>();
0065 
0066         using const_view_t = typename Image::const_view_t;
0067         using pixel_t = typename Image::value_type;
0068         using point_t = typename Image::point_t;
0069         gil_function_requires<PointNDConcept<point_t>>();
0070 
0071         const_view_t cv = const_view(image);
0072         ignore_unused_variable_warning(cv);
0073         view_t v = view(image);
0074         ignore_unused_variable_warning(v);
0075 
0076         pixel_t fill_value;
0077         point_t pt = image.dimensions();
0078         Image image1(pt);
0079         Image image2(pt, 1);
0080         Image image3(pt, fill_value, 1);
0081         image.recreate(pt);
0082         image.recreate(pt, 1);
0083         image.recreate(pt, fill_value, 1);
0084     }
0085     Image image;
0086 };
0087 
0088 
0089 /// \ingroup ImageConcept
0090 /// \brief 2-dimensional container of values
0091 ///
0092 /// \code
0093 /// concept RandomAccess2DImageConcept<RandomAccessNDImageConcept Image>
0094 /// {
0095 ///     typename x_coord_t = const_view_t::x_coord_t;
0096 ///     typename y_coord_t = const_view_t::y_coord_t;
0097 ///
0098 ///     Image::Image(x_coord_t width, y_coord_t height, std::size_t alignment=1);
0099 ///     Image::Image(x_coord_t width, y_coord_t height, value_type fill_value, std::size_t alignment);
0100 ///
0101 ///     x_coord_t Image::width() const;
0102 ///     y_coord_t Image::height() const;
0103 ///
0104 ///     void Image::recreate(x_coord_t width, y_coord_t height, std::size_t alignment=1);
0105 ///     void Image::recreate(x_coord_t width, y_coord_t height, value_type fill_value, std::size_t alignment);
0106 /// };
0107 /// \endcode
0108 template <typename Image>
0109 struct RandomAccess2DImageConcept
0110 {
0111     void constraints()
0112     {
0113         gil_function_requires<RandomAccessNDImageConcept<Image>>();
0114         using x_coord_t = typename Image::x_coord_t;
0115         using y_coord_t = typename Image::y_coord_t;
0116         using value_t = typename Image::value_type;
0117 
0118         gil_function_requires<MutableRandomAccess2DImageViewConcept<typename Image::view_t>>();
0119 
0120         x_coord_t w=image.width();
0121         y_coord_t h=image.height();
0122         value_t fill_value;
0123         Image im1(w,h);
0124         Image im2(w,h,1);
0125         Image im3(w,h,fill_value,1);
0126         image.recreate(w,h);
0127         image.recreate(w,h,1);
0128         image.recreate(w,h,fill_value,1);
0129     }
0130     Image image;
0131 };
0132 
0133 /// \ingroup ImageConcept
0134 /// \brief 2-dimensional image whose value type models PixelValueConcept
0135 ///
0136 /// \code
0137 /// concept ImageConcept<RandomAccess2DImageConcept Image>
0138 /// {
0139 ///     where MutableImageViewConcept<view_t>;
0140 ///     typename coord_t  = view_t::coord_t;
0141 /// };
0142 /// \endcode
0143 template <typename Image>
0144 struct ImageConcept
0145 {
0146     void constraints()
0147     {
0148         gil_function_requires<RandomAccess2DImageConcept<Image>>();
0149         gil_function_requires<MutableImageViewConcept<typename Image::view_t>>();
0150         using coord_t = typename Image::coord_t;
0151         static_assert(num_channels<Image>::value == mp11::mp_size<typename color_space_type<Image>::type>::value, "");
0152 
0153         static_assert(std::is_same<coord_t, typename Image::x_coord_t>::value, "");
0154         static_assert(std::is_same<coord_t, typename Image::y_coord_t>::value, "");
0155     }
0156     Image image;
0157 };
0158 
0159 }} // namespace boost::gil
0160 
0161 #if defined(BOOST_CLANG)
0162 #pragma clang diagnostic pop
0163 #endif
0164 
0165 #if defined(BOOST_GCC) && (BOOST_GCC >= 40900)
0166 #pragma GCC diagnostic pop
0167 #endif
0168 
0169 #endif