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  (1 <= 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>
61 inline
62 auto planar_devicen_view(std::size_t width, std::size_t height, IC c0, IC c1, std::ptrdiff_t rowsize_in_bytes)
64 {
65  using view_t = typename type_from_x_iterator<planar_pixel_iterator<IC,devicen_t<2>>>::view_t;
66  return view_t(width, height, typename view_t::locator(typename view_t::x_iterator(c0,c1), rowsize_in_bytes));
67 }
68 
71 template <typename IC>
72 inline
73 auto planar_devicen_view(std::size_t width, std::size_t height, IC c0, IC c1, IC c2, std::ptrdiff_t rowsize_in_bytes)
75 {
76  using view_t = typename type_from_x_iterator<planar_pixel_iterator<IC,devicen_t<3>>>::view_t;
77  return view_t(width, height, typename view_t::locator(typename view_t::x_iterator(c0,c1,c2), rowsize_in_bytes));
78 }
79 
82 template <typename IC>
83 inline
84 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)
86 {
87  using view_t = typename type_from_x_iterator<planar_pixel_iterator<IC,devicen_t<4>>>::view_t;
88  return view_t(width, height, typename view_t::locator(typename view_t::x_iterator(c0,c1,c2,c3), rowsize_in_bytes));
89 }
90 
93 template <typename IC>
94 inline
95 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)
97 {
98  using view_t = typename type_from_x_iterator<planar_pixel_iterator<IC,devicen_t<5>>>::view_t;
99  return view_t(width, height, typename view_t::locator(typename view_t::x_iterator(c0,c1,c2,c3,c4), rowsize_in_bytes));
100 }
101 
102 }} // namespace boost::gil
103 
104 #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:95
defined(BOOST_NO_CXX17_HDR_MEMORY_RESOURCE)
Definition: algorithm.hpp:36
unnamed color
Definition: device_n.hpp:30
unnamed color layout of up to five channels
Definition: device_n.hpp:56
Unnamed color space of 1, 2, 3, 4, or 5 channels.
Definition: device_n.hpp:40
Represents a color space and ordering of channels in memory.
Definition: utilities.hpp:268
Given a pixel iterator defining access to pixels along a row, returns the types of the corresponding ...
Definition: metafunctions.hpp:303