Imported Upstream version 1.72.0
[platform/upstream/boost.git] / boost / gil / extension / toolbox / color_spaces / cmyka.hpp
1 //
2 // Copyright 2012 Christian Henning
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_EXTENSION_TOOLBOX_COLOR_SPACES_CMYKA_HPP
9 #define BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_CMYKA_HPP
10
11 #include <boost/gil/cmyk.hpp>
12 #include <boost/gil/color_convert.hpp>
13 #include <boost/gil/rgba.hpp>
14 #include <boost/gil/typedefs.hpp>
15 #include <boost/gil/detail/mp11.hpp>
16
17 namespace boost{ namespace gil {
18
19 /// \ingroup ColorSpaceModel
20 using cmyka_t = mp11::mp_list<cyan_t, magenta_t, yellow_t, black_t, alpha_t>;
21
22 /// \ingroup LayoutModel
23 using cmyka_layout_t = layout<cmyka_t>;
24
25 GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, cmyka)
26 GIL_DEFINE_ALL_TYPEDEFS(8s, int8_t, cmyka)
27 GIL_DEFINE_ALL_TYPEDEFS(16, uint16_t, cmyka)
28 GIL_DEFINE_ALL_TYPEDEFS(16s, int16_t, cmyka)
29 GIL_DEFINE_ALL_TYPEDEFS(32, uint32_t, cmyka)
30 GIL_DEFINE_ALL_TYPEDEFS(32s, int32_t, cmyka)
31 GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, cmyka)
32
33 ///// \ingroup ColorConvert
34 ///// \brief Converting CMYKA to any pixel type. Note: Supports homogeneous pixels only.
35 //template <typename C2>
36 //struct default_color_converter_impl<cmyka_t,C2> {
37 //    template <typename P1, typename P2>
38 //    void operator()(const P1& src, P2& dst) const {
39 //        using T1 = typename channel_type<P1>::type;
40 //        default_color_converter_impl<cmyk_t,C2>()(
41 //            pixel<T1,cmyk_layout_t>(channel_multiply(get_color(src,cyan_t()),  get_color(src,alpha_t())),
42 //                                    channel_multiply(get_color(src,magenta_t()),get_color(src,alpha_t())),
43 //                                    channel_multiply(get_color(src,yellow_t()), get_color(src,alpha_t())),
44 //                                    channel_multiply(get_color(src,black_t()), get_color(src,alpha_t())))
45 //            ,dst);
46 //    }
47 //};
48 template <>
49 struct default_color_converter_impl<cmyka_t,rgba_t> {
50     template <typename P1, typename P2>
51     void operator()(const P1& src, P2& dst) const {
52         using T1 = typename channel_type<P1>::type;
53         default_color_converter_impl<cmyk_t,rgba_t>()(
54             pixel<T1,cmyk_layout_t>(get_color(src,cyan_t()),
55                                     get_color(src,magenta_t()),
56                                     get_color(src,yellow_t()),
57                                     get_color(src,black_t()))
58             ,dst);
59     }
60 };
61
62 /// \ingroup ColorConvert
63 /// \brief Unfortunately CMYKA to CMYKA must be explicitly provided - otherwise we get ambiguous specialization error.
64 template <>
65 struct default_color_converter_impl<cmyka_t,cmyka_t> {
66     template <typename P1, typename P2>
67     void operator()(const P1& src, P2& dst) const {
68         static_for_each(src,dst,default_channel_converter());
69     }
70 };
71
72 } // namespace gil
73 } // namespace boost
74
75 #endif