get_pixel_type.hpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. //
  2. // Copyright 2012 Christian Henning, Andreas Pokorny, Lubomir Bourdev
  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_EXTENSION_TOOLBOX_METAFUNCTIONS_GET_PIXEL_TYPE_HPP
  9. #define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_GET_PIXEL_TYPE_HPP
  10. #include <boost/gil/extension/toolbox/dynamic_images.hpp>
  11. #include <boost/gil/extension/toolbox/metafunctions/is_bit_aligned.hpp>
  12. #include <boost/gil/detail/mp11.hpp>
  13. namespace boost{ namespace gil {
  14. /// get_pixel_type metafunction
  15. /// \brief Depending on Image this function generates either
  16. /// the pixel type or the reference type in case
  17. /// the image is bit_aligned.
  18. template<typename View>
  19. struct get_pixel_type
  20. {
  21. using type = mp11::mp_if
  22. <
  23. is_bit_aligned<typename View::value_type>,
  24. typename View::reference,
  25. typename View::value_type
  26. >;
  27. };
  28. template<typename Views>
  29. struct get_pixel_type<any_image_view<Views>>
  30. {
  31. using type = any_image_pixel_t;
  32. };
  33. }} // namespace boost::gil
  34. #endif