rgb.hpp 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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
  35. auto planar_rgb_view(
  36. std::size_t width, std::size_t height,
  37. IC r, IC g, IC b,
  38. std::ptrdiff_t rowsize_in_bytes)
  39. -> typename type_from_x_iterator<planar_pixel_iterator<IC, rgb_t> >::view_t
  40. {
  41. using view_t = typename type_from_x_iterator<planar_pixel_iterator<IC, rgb_t>>::view_t;
  42. return view_t(
  43. width, height,
  44. typename view_t::locator(
  45. planar_pixel_iterator<IC, rgb_t>(r, g, b),
  46. rowsize_in_bytes));
  47. }
  48. }} // namespace boost::gil
  49. #endif