rgb.hpp 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. /*
  2. Copyright 2005-2007 Adobe Systems Incorporated
  3. Use, modification and distribution are subject to the Boost Software License,
  4. Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. http://www.boost.org/LICENSE_1_0.txt).
  6. See http://opensource.adobe.com/gil for most recent version including documentation.
  7. */
  8. /*************************************************************************************************/
  9. #ifndef GIL_RGB_H
  10. #define GIL_RGB_H
  11. ////////////////////////////////////////////////////////////////////////////////////////
  12. /// \file
  13. /// \brief Support for RGB color space and variants
  14. /// \author Lubomir Bourdev and Hailin Jin \n
  15. /// Adobe Systems Incorporated
  16. /// \date 2005-2007 \n Last updated on October 10, 2007
  17. ////////////////////////////////////////////////////////////////////////////////////////
  18. #include <cstddef>
  19. #include <boost/mpl/range_c.hpp>
  20. #include <boost/mpl/vector_c.hpp>
  21. #include "gil_config.hpp"
  22. #include "metafunctions.hpp"
  23. #include "planar_pixel_iterator.hpp"
  24. namespace boost { namespace gil {
  25. /// \addtogroup ColorNameModel
  26. /// \{
  27. /// \brief Red
  28. struct red_t {};
  29. /// \brief Green
  30. struct green_t {};
  31. /// \brief Blue
  32. struct blue_t {};
  33. /// \}
  34. /// \ingroup ColorSpaceModel
  35. typedef mpl::vector3<red_t,green_t,blue_t> rgb_t;
  36. /// \ingroup LayoutModel
  37. typedef layout<rgb_t> rgb_layout_t;
  38. /// \ingroup LayoutModel
  39. typedef layout<rgb_t, mpl::vector3_c<int,2,1,0> > bgr_layout_t;
  40. /// \ingroup ImageViewConstructors
  41. /// \brief from raw RGB planar data
  42. template <typename IC>
  43. inline
  44. typename type_from_x_iterator<planar_pixel_iterator<IC,rgb_t> >::view_t
  45. planar_rgb_view(std::size_t width, std::size_t height,
  46. IC r, IC g, IC b,
  47. std::ptrdiff_t rowsize_in_bytes) {
  48. typedef typename type_from_x_iterator<planar_pixel_iterator<IC,rgb_t> >::view_t RView;
  49. return RView(width, height,
  50. typename RView::locator(planar_pixel_iterator<IC,rgb_t>(r,g,b),
  51. rowsize_in_bytes));
  52. }
  53. } } // namespace boost::gil
  54. #endif