• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 //
2 // Copyright 2019 Mateusz Loskot <mateusz at loskot dot net>
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 #include <boost/gil.hpp>
9 #include <boost/gil/extension/dynamic_image/any_image.hpp>
10 
11 #include <tuple>
12 
13 namespace boost { namespace gil {
14 
15 namespace test { namespace fixture {
16 
17 using dynamic_image = gil::any_image
18 <
19     gil::gray8_image_t,
20     gil::gray16_image_t,
21     gil::gray32_image_t,
22     gil::bgr8_image_t,
23     gil::bgr16_image_t,
24     gil::bgr32_image_t,
25     gil::rgb8_image_t,
26     gil::rgb16_image_t,
27     gil::rgb32_image_t,
28     gil::rgba8_image_t,
29     gil::rgba16_image_t,
30     gil::rgba32_image_t
31 >;
32 
33 template <typename Image>
34 struct fill_any_view
35 {
36     using result_type = void;
37     using pixel_t = typename Image::value_type;
38 
fill_any_viewboost::gil::test::fixture::fill_any_view39     fill_any_view(std::initializer_list<int> dst_view_indices, pixel_t pixel_value)
40         : dst_view_indices_(dst_view_indices), pixel_value_(pixel_value)
41     {}
42 
43     template <typename View>
operator ()boost::gil::test::fixture::fill_any_view44     void operator()(View& /*dst_view*/) { /* sink any other views here */ }
45 
operator ()boost::gil::test::fixture::fill_any_view46     void operator()(typename Image::view_t& dst_view)
47     {
48         // sink view of interest here
49         for (auto const& i : dst_view_indices_)
50             dst_view[i] = pixel_value_;
51     }
52 
53     std::initializer_list<int> dst_view_indices_;
54     pixel_t pixel_value_;
55 };
56 
57 }}}} // namespace boost::gil::test::fixture
58