rgba.hpp 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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_RGBA_HPP
  9. #define BOOST_GIL_RGBA_HPP
  10. #include <boost/gil/planar_pixel_iterator.hpp>
  11. #include <boost/gil/rgb.hpp>
  12. #include <boost/gil/detail/mp11.hpp>
  13. #include <cstddef>
  14. #include <type_traits>
  15. namespace boost { namespace gil {
  16. /// \ingroup ColorNameModel
  17. /// \brief Alpha
  18. struct alpha_t {};
  19. /// \ingroup ColorSpaceModel
  20. using rgba_t =mp11::mp_list<red_t, green_t, blue_t, alpha_t>;
  21. /// \ingroup LayoutModel
  22. using rgba_layout_t = layout<rgba_t>;
  23. /// \ingroup LayoutModel
  24. using bgra_layout_t = layout<rgba_t, mp11::mp_list_c<int, 2, 1, 0, 3>>;
  25. /// \ingroup LayoutModel
  26. using argb_layout_t = layout<rgba_t, mp11::mp_list_c<int, 1, 2, 3, 0>>;
  27. /// \ingroup LayoutModel
  28. using abgr_layout_t = layout<rgba_t, mp11::mp_list_c<int, 3, 2, 1, 0>>;
  29. /// \ingroup ImageViewConstructors
  30. /// \brief from raw RGBA planar data
  31. template <typename ChannelPtr>
  32. inline
  33. auto planar_rgba_view(std::size_t width, std::size_t height,
  34. ChannelPtr r, ChannelPtr g, ChannelPtr b, ChannelPtr a,
  35. std::ptrdiff_t rowsize_in_bytes)
  36. -> typename type_from_x_iterator<planar_pixel_iterator<ChannelPtr, rgba_t> >::view_t
  37. {
  38. using pixel_iterator_t = planar_pixel_iterator<ChannelPtr, rgba_t>;
  39. using view_t = typename type_from_x_iterator<pixel_iterator_t>::view_t;
  40. using locator_t = typename view_t::locator;
  41. locator_t loc(pixel_iterator_t(r, g, b, a), rowsize_in_bytes);
  42. return view_t(width, height, loc);
  43. }
  44. }} // namespace boost::gil
  45. #endif