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