rgb.hpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  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_RGB_HPP
  9. #define BOOST_GIL_RGB_HPP
  10. #include <boost/gil/metafunctions.hpp>
  11. #include <boost/gil/planar_pixel_iterator.hpp>
  12. #include <boost/gil/detail/mp11.hpp>
  13. #include <cstddef>
  14. #include <type_traits>
  15. namespace boost { namespace gil {
  16. /// \addtogroup ColorNameModel
  17. /// \{
  18. /// \brief Red
  19. struct red_t {};
  20. /// \brief Green
  21. struct green_t {};
  22. /// \brief Blue
  23. struct blue_t {};
  24. /// \}
  25. /// \ingroup ColorSpaceModel
  26. using rgb_t = mp11::mp_list<red_t, green_t, blue_t>;
  27. /// \ingroup LayoutModel
  28. using rgb_layout_t = layout<rgb_t>;
  29. /// \ingroup LayoutModel
  30. using bgr_layout_t = layout<rgb_t, mp11::mp_list_c<int, 2, 1, 0>>;
  31. /// \ingroup ImageViewConstructors
  32. /// \brief from raw RGB planar data
  33. template <typename IC>
  34. inline auto planar_rgb_view(
  35. std::size_t width, std::size_t height,
  36. IC r, IC g, IC b,
  37. std::ptrdiff_t rowsize_in_bytes)
  38. -> typename type_from_x_iterator<planar_pixel_iterator<IC, rgb_t> >::view_t
  39. {
  40. using view_t = typename type_from_x_iterator<planar_pixel_iterator<IC, rgb_t>>::view_t;
  41. return view_t(
  42. width, height,
  43. typename view_t::locator(
  44. planar_pixel_iterator<IC, rgb_t>(r, g, b),
  45. rowsize_in_bytes));
  46. }
  47. }} // namespace boost::gil
  48. #endif