Boost GIL


concepts/image.hpp
1 //
2 // Copyright 2005-2007 Adobe Systems Incorporated
3 //
4 // Distributed under the Boost Software License, Version 1.0
5 // See accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt
7 //
8 #ifndef BOOST_GIL_CONCEPTS_IMAGE_HPP
9 #define BOOST_GIL_CONCEPTS_IMAGE_HPP
10 
11 #include <boost/gil/concepts/basic.hpp>
12 #include <boost/gil/concepts/concept_check.hpp>
13 #include <boost/gil/concepts/fwd.hpp>
14 #include <boost/gil/concepts/image_view.hpp>
15 #include <boost/gil/concepts/point.hpp>
16 
17 #include <boost/mpl/size.hpp>
18 
19 #if defined(BOOST_CLANG)
20 #pragma clang diagnostic push
21 #pragma clang diagnostic ignored "-Wunused-local-typedefs"
22 #endif
23 
24 #if defined(BOOST_GCC) && (BOOST_GCC >= 40600)
25 #pragma GCC diagnostic push
26 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
27 #endif
28 
29 namespace boost { namespace gil {
30 
54 template <typename Image>
56 {
57  void constraints()
58  {
59  gil_function_requires<Regular<Image>>();
60 
61  using view_t = typename Image::view_t;
62  gil_function_requires<MutableRandomAccessNDImageViewConcept<view_t>>();
63 
64  using const_view_t = typename Image::const_view_t;
65  using pixel_t = typename Image::value_type;
66  using point_t = typename Image::point_t;
67  gil_function_requires<PointNDConcept<point_t>>();
68 
69  const_view_t cv = const_view(image);
70  ignore_unused_variable_warning(cv);
71  view_t v = view(image);
72  ignore_unused_variable_warning(v);
73 
74  pixel_t fill_value;
75  point_t pt = image.dimensions();
76  Image image1(pt);
77  Image image2(pt, 1);
78  Image image3(pt, fill_value, 1);
79  image.recreate(pt);
80  image.recreate(pt, 1);
81  image.recreate(pt, fill_value, 1);
82  }
83  Image image;
84 };
85 
86 
106 template <typename Image>
108 {
109  void constraints()
110  {
111  gil_function_requires<RandomAccessNDImageConcept<Image>>();
112  using x_coord_t = typename Image::x_coord_t;
113  using y_coord_t = typename Image::y_coord_t;
114  using value_t = typename Image::value_type;
115 
116  gil_function_requires<MutableRandomAccess2DImageViewConcept<typename Image::view_t>>();
117 
118  x_coord_t w=image.width();
119  y_coord_t h=image.height();
120  value_t fill_value;
121  Image im1(w,h);
122  Image im2(w,h,1);
123  Image im3(w,h,fill_value,1);
124  image.recreate(w,h);
125  image.recreate(w,h,1);
126  image.recreate(w,h,fill_value,1);
127  }
128  Image image;
129 };
130 
141 template <typename Image>
143 {
144  void constraints()
145  {
146  gil_function_requires<RandomAccess2DImageConcept<Image>>();
147  gil_function_requires<MutableImageViewConcept<typename Image::view_t>>();
148  using coord_t = typename Image::coord_t;
149  static_assert(num_channels<Image>::value == mpl::size<typename color_space_type<Image>::type>::value, "");
150 
151  static_assert(is_same<coord_t, typename Image::x_coord_t>::value, "");
152  static_assert(is_same<coord_t, typename Image::y_coord_t>::value, "");
153  }
154  Image image;
155 };
156 
157 }} // namespace boost::gil
158 
159 #if defined(BOOST_CLANG)
160 #pragma clang diagnostic pop
161 #endif
162 
163 #if defined(BOOST_GCC) && (BOOST_GCC >= 40600)
164 #pragma GCC diagnostic pop
165 #endif
166 
167 #endif
Definition: algorithm.hpp:30
N-dimensional container of values.
Definition: concepts/image.hpp:55
2-dimensional image whose value type models PixelValueConcept
Definition: concepts/image.hpp:142
container interface over image view. Models ImageConcept, PixelBasedConcept
Definition: image.hpp:39
2-dimensional container of values
Definition: concepts/image.hpp:107
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:460
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:464
Returns the number of channels of a pixel-based GIL construct.
Definition: locator.hpp:38