1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
/*
Copyright 2012 Christian Henning
Use, modification and distribution are subject to the Boost Software License,
Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt).
*/
/*************************************************************************************************/
#ifndef BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_CMYKA_HPP
#define BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_CMYKA_HPP
////////////////////////////////////////////////////////////////////////////////////////
/// \file cmyka.hpp
/// \brief Support for cmyka color space.
/// \author Christian Henning \n
///
/// \date 2012 \n
///
////////////////////////////////////////////////////////////////////////////////////////
#include <boost/gil/rgba.hpp>
#include <boost/gil/cmyk.hpp>
#include <boost/gil/color_convert.hpp>
#include <boost/gil/typedefs.hpp>
namespace boost{ namespace gil {
/// \ingroup ColorSpaceModel
using cmyka_t = mpl::vector5<cyan_t, magenta_t, yellow_t, black_t, alpha_t>;
/// \ingroup LayoutModel
using cmyka_layout_t = layout<cmyka_t>;
GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, cmyka)
GIL_DEFINE_ALL_TYPEDEFS(8s, int8_t, cmyka)
GIL_DEFINE_ALL_TYPEDEFS(16, uint16_t, cmyka)
GIL_DEFINE_ALL_TYPEDEFS(16s, int16_t, cmyka)
GIL_DEFINE_ALL_TYPEDEFS(32, uint32_t, cmyka)
GIL_DEFINE_ALL_TYPEDEFS(32s, int32_t, cmyka)
GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, cmyka)
///// \ingroup ColorConvert
///// \brief Converting CMYKA to any pixel type. Note: Supports homogeneous pixels only.
//template <typename C2>
//struct default_color_converter_impl<cmyka_t,C2> {
// template <typename P1, typename P2>
// void operator()(const P1& src, P2& dst) const {
// typedef typename channel_type<P1>::type T1;
// default_color_converter_impl<cmyk_t,C2>()(
// pixel<T1,cmyk_layout_t>(channel_multiply(get_color(src,cyan_t()), get_color(src,alpha_t())),
// channel_multiply(get_color(src,magenta_t()),get_color(src,alpha_t())),
// channel_multiply(get_color(src,yellow_t()), get_color(src,alpha_t())),
// channel_multiply(get_color(src,black_t()), get_color(src,alpha_t())))
// ,dst);
// }
//};
template <>
struct default_color_converter_impl<cmyka_t,rgba_t> {
template <typename P1, typename P2>
void operator()(const P1& src, P2& dst) const {
typedef typename channel_type<P1>::type T1;
default_color_converter_impl<cmyk_t,rgba_t>()(
pixel<T1,cmyk_layout_t>(get_color(src,cyan_t()),
get_color(src,magenta_t()),
get_color(src,yellow_t()),
get_color(src,black_t()))
,dst);
}
};
/// \ingroup ColorConvert
/// \brief Unfortunately CMYKA to CMYKA must be explicitly provided - otherwise we get ambiguous specialization error.
template <>
struct default_color_converter_impl<cmyka_t,cmyka_t> {
template <typename P1, typename P2>
void operator()(const P1& src, P2& dst) const {
static_for_each(src,dst,default_channel_converter());
}
};
} // namespace gil
} // namespace boost
#endif // BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_CMYKA_HPP
|