Boost GIL


device_n.hpp
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_DEVICE_N_HPP
9 #define BOOST_GIL_DEVICE_N_HPP
10 
11 #include <boost/gil/metafunctions.hpp>
12 #include <boost/gil/utilities.hpp>
13 #include <boost/gil/detail/mp11.hpp>
14 
15 #include <boost/config.hpp>
16 
17 #include <cstddef>
18 #include <type_traits>
19 
20 namespace boost { namespace gil {
21 
22 
23 // TODO: Document the DeviceN Color Space and Color Model
24 // with reference to the Adobe documentation
25 // https://www.adobe.com/content/dam/acom/en/devnet/postscript/pdfs/TN5604.DeviceN_Color.pdf
26 
29 template <int N>
30 struct devicen_color_t {};
31 
32 template <int N>
33 struct devicen_t;
34 
38 template <int N>
39 struct devicen_t
40 {
41 private:
42  template <typename T>
44 
45  static_assert(
46  N == 1 || (3 <= N && N <= 5),
47  "invalid number of DeviceN color components");
48 
49 public:
50  using type = mp11::mp_transform<color_t, mp11::mp_iota_c<N>>;
51 };
52 
55 template <int N>
56 struct devicen_layout_t : layout<typename devicen_t<N>::type> {};
57 
60 template <typename IC>
62 planar_devicen_view(std::size_t width, std::size_t height, IC c0, IC c1, std::ptrdiff_t rowsize_in_bytes)
63 {
64  using view_t = typename type_from_x_iterator<planar_pixel_iterator<IC,devicen_t<2>>>::view_t;
65  return view_t(width, height, typename view_t::locator(typename view_t::x_iterator(c0,c1), rowsize_in_bytes));
66 }
67 
70 template <typename IC>
71 inline
72 auto planar_devicen_view(std::size_t width, std::size_t height, IC c0, IC c1, IC c2, std::ptrdiff_t rowsize_in_bytes)
74 {
75  using view_t = typename type_from_x_iterator<planar_pixel_iterator<IC,devicen_t<3>>>::view_t;
76  return view_t(width, height, typename view_t::locator(typename view_t::x_iterator(c0,c1,c2), rowsize_in_bytes));
77 }
78 
81 template <typename IC>
82 inline
83 auto planar_devicen_view(std::size_t width, std::size_t height, IC c0, IC c1, IC c2, IC c3, std::ptrdiff_t rowsize_in_bytes)
85 {
86  using view_t = typename type_from_x_iterator<planar_pixel_iterator<IC,devicen_t<4>>>::view_t;
87  return view_t(width, height, typename view_t::locator(typename view_t::x_iterator(c0,c1,c2,c3), rowsize_in_bytes));
88 }
89 
92 template <typename IC>
93 inline
94 auto planar_devicen_view(std::size_t width, std::size_t height, IC c0, IC c1, IC c2, IC c3, IC c4, std::ptrdiff_t rowsize_in_bytes)
96 {
97  using view_t = typename type_from_x_iterator<planar_pixel_iterator<IC,devicen_t<5>>>::view_t;
98  return view_t(width, height, typename view_t::locator(typename view_t::x_iterator(c0,c1,c2,c3,c4), rowsize_in_bytes));
99 }
100 
101 }} // namespace boost::gil
102 
103 #endif
auto planar_devicen_view(std::size_t width, std::size_t height, IC c0, IC c1, IC c2, IC c3, IC c4, std::ptrdiff_t rowsize_in_bytes) -> typename type_from_x_iterator< planar_pixel_iterator< IC, devicen_t< 5 >>>::view_t
from 5-channel planar data
Definition: device_n.hpp:94
Given a pixel iterator defining access to pixels along a row, returns the types of the corresponding ...
Definition: metafunctions.hpp:301
unnamed color
Definition: device_n.hpp:30
Represents a color space and ordering of channels in memory.
Definition: utilities.hpp:266
Unnamed color space of 1, 3, 4, or 5 channels.
Definition: device_n.hpp:33
unnamed color layout of up to five channels
Definition: device_n.hpp:56