pixel_bit_size.hpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  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_PIXEL_BIT_SIZE_HPP
  9. #define BOOST_GIL_EXTENSION_TOOLBOX_METAFUNCTIONS_PIXEL_BIT_SIZE_HPP
  10. #include <boost/gil/bit_aligned_pixel_reference.hpp>
  11. #include <boost/gil/packed_pixel.hpp>
  12. namespace boost{ namespace gil {
  13. /// pixel_bit_size metafunctions
  14. /// \brief Accumulates the all channel size.
  15. ///
  16. /// \code
  17. /// using image_t = bit_aligned_image5_type<16, 16, 16, 8, 8, devicen_layout_t<5>>::type;
  18. /// const int size = pixel_bit_size<image_t::view_t::reference>::value;
  19. /// \endcode
  20. template< typename PixelRef>
  21. struct pixel_bit_size : std::integral_constant<int, 0> {};
  22. template <typename B, typename C, typename L, bool M>
  23. struct pixel_bit_size<bit_aligned_pixel_reference<B, C, L, M>>
  24. : mp11::mp_fold
  25. <
  26. C,
  27. std::integral_constant<int, 0>,
  28. mp11::mp_plus
  29. >
  30. {};
  31. template <typename B, typename C, typename L, bool M>
  32. struct pixel_bit_size<bit_aligned_pixel_reference<B, C, L, M> const>
  33. : mp11::mp_fold
  34. <
  35. C,
  36. std::integral_constant<int, 0>,
  37. mp11::mp_plus
  38. >
  39. {};
  40. template <typename B, typename C, typename L>
  41. struct pixel_bit_size<packed_pixel<B, C, L>>
  42. : mp11::mp_fold
  43. <
  44. C,
  45. std::integral_constant<int, 0>,
  46. mp11::mp_plus
  47. >
  48. {};
  49. template <typename B, typename C, typename L>
  50. struct pixel_bit_size<const packed_pixel<B,C,L> >
  51. : mp11::mp_fold
  52. <
  53. C,
  54. std::integral_constant<int, 0>,
  55. mp11::mp_plus
  56. >
  57. {};
  58. }} // namespace boost::gil
  59. #endif