test_fixture.hpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  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. #include <boost/mp11.hpp>
  11. #include <tuple>
  12. namespace boost { namespace gil {
  13. namespace test { namespace fixture {
  14. using dynamic_image = gil::any_image
  15. <
  16. boost::mp11::mp_list
  17. <
  18. gil::gray8_image_t,
  19. gil::gray16_image_t,
  20. gil::gray32_image_t,
  21. gil::bgr8_image_t,
  22. gil::bgr16_image_t,
  23. gil::bgr32_image_t,
  24. gil::rgb8_image_t,
  25. gil::rgb16_image_t,
  26. gil::rgb32_image_t,
  27. gil::rgba8_image_t,
  28. gil::rgba16_image_t,
  29. gil::rgba32_image_t
  30. >
  31. >;
  32. template <typename Image>
  33. struct fill_any_view
  34. {
  35. using result_type = void;
  36. using pixel_t = typename Image::value_type;
  37. fill_any_view(std::initializer_list<int> dst_view_indices, pixel_t pixel_value)
  38. : dst_view_indices_(dst_view_indices), pixel_value_(pixel_value)
  39. {}
  40. template <typename View>
  41. void operator()(View& /*dst_view*/) { /* sink any other views here */ }
  42. void operator()(typename Image::view_t& dst_view)
  43. {
  44. // sink view of interest here
  45. for (auto const& i : dst_view_indices_)
  46. dst_view[i] = pixel_value_;
  47. }
  48. std::initializer_list<int> dst_view_indices_;
  49. pixel_t pixel_value_;
  50. };
  51. }}}} // namespace boost::gil::test::fixture