]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/boost/gil/extension/toolbox/color_spaces/gray_alpha.hpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / boost / gil / extension / toolbox / color_spaces / gray_alpha.hpp
CommitLineData
92f5a8d4
TL
1//
2// Copyright 2012 Andreas Pokorny
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_GRAY_ALPHA_HPP
9#define BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_GRAY_ALPHA_HPP
10
11#include <boost/gil/color_convert.hpp>
12#include <boost/gil/gray.hpp>
13#include <boost/gil/typedefs.hpp>
14
15#include <boost/gil/detail/mp11.hpp>
16
17namespace boost{ namespace gil {
18
19using gray_alpha_t = mp11::mp_list<gray_color_t,alpha_t>;
20
21using gray_alpha_layout_t = layout<gray_alpha_t>;
22using alpha_gray_layout_t = layout<gray_alpha_layout_t, mp11::mp_list_c<int,1,0>>;
23
f67539c2
TL
24BOOST_GIL_DEFINE_BASE_TYPEDEFS(8, uint8_t, alpha_gray)
25BOOST_GIL_DEFINE_BASE_TYPEDEFS(8s, int8_t, alpha_gray)
26BOOST_GIL_DEFINE_BASE_TYPEDEFS(16, uint16_t, alpha_gray)
27BOOST_GIL_DEFINE_BASE_TYPEDEFS(16s, int16_t, alpha_gray)
28BOOST_GIL_DEFINE_BASE_TYPEDEFS(32, uint32_t, alpha_gray)
29BOOST_GIL_DEFINE_BASE_TYPEDEFS(32s, int32_t, alpha_gray)
30BOOST_GIL_DEFINE_BASE_TYPEDEFS(32f, float32_t, alpha_gray)
31
32BOOST_GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, gray_alpha)
33BOOST_GIL_DEFINE_ALL_TYPEDEFS(8s, int8_t, gray_alpha)
34BOOST_GIL_DEFINE_ALL_TYPEDEFS(16, uint16_t, gray_alpha)
35BOOST_GIL_DEFINE_ALL_TYPEDEFS(16s, int16_t, gray_alpha)
36BOOST_GIL_DEFINE_ALL_TYPEDEFS(32, uint32_t, gray_alpha)
37BOOST_GIL_DEFINE_ALL_TYPEDEFS(32s, int32_t, gray_alpha)
38BOOST_GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, gray_alpha)
92f5a8d4
TL
39
40/// \ingroup ColorConvert
41/// \brief Gray Alpha to RGBA
42template <>
43struct default_color_converter_impl<gray_alpha_t,rgba_t> {
44 template <typename P1, typename P2>
45 void operator()(const P1& src, P2& dst) const {
46 get_color(dst,red_t()) =
47 channel_convert<typename color_element_type<P2, red_t>::type>(get_color(src,gray_color_t()));
48 get_color(dst,green_t())=
49 channel_convert<typename color_element_type<P2, green_t>::type>(get_color(src,gray_color_t()));
50 get_color(dst,blue_t()) =
51 channel_convert<typename color_element_type<P2, blue_t>::type>(get_color(src,gray_color_t()));
52 get_color(dst,alpha_t()) =
53 channel_convert<typename color_element_type<P2, alpha_t>::type>(get_color(src,alpha_t()));
54 }
55};
56
57/// \brief Gray Alpha to RGB
58template <>
59struct default_color_converter_impl<gray_alpha_t,rgb_t> {
60 template <typename P1, typename P2>
61 void operator()(const P1& src, P2& dst) const {
62 get_color(dst,red_t()) =
63 channel_convert<typename color_element_type<P2, red_t>::type>(
64 channel_multiply(get_color(src,gray_color_t()),get_color(src,alpha_t()) )
65 );
66 get_color(dst,green_t()) =
67 channel_convert<typename color_element_type<P2, green_t>::type>(
68 channel_multiply(get_color(src,gray_color_t()),get_color(src,alpha_t()) )
69 );
70 get_color(dst,blue_t()) =
71 channel_convert<typename color_element_type<P2, blue_t>::type>(
72 channel_multiply(get_color(src,gray_color_t()),get_color(src,alpha_t()) )
73 );
74 }
75};
76
77/// \brief Gray Alpha to Gray
78template <>
79struct default_color_converter_impl<gray_alpha_t,gray_t> {
80 template <typename P1, typename P2>
81 void operator()(const P1& src, P2& dst) const {
82 get_color(dst,gray_color_t()) =
83 channel_convert<typename color_element_type<P2, gray_color_t>::type>(
84 channel_multiply(get_color(src,gray_color_t()),get_color(src,alpha_t()) )
85 );
86 }
87};
88
89} // namespace gil
90} // namespace boost
91
92#endif