]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/gil/test/core/color_base/static_transform_gray_to_rgb_fail.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / gil / test / core / color_base / static_transform_gray_to_rgb_fail.cpp
1 //
2 // Copyright 2019 Mateusz Loskot <mateusz at loskot dot net>
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 #include <boost/gil/color_base_algorithm.hpp>
9 #include <boost/gil/pixel.hpp>
10 #include <boost/gil/typedefs.hpp>
11
12 #include <cassert>
13 #include <cstdint>
14
15 namespace gil = boost::gil;
16
17 int main()
18 {
19 // K-element index must be less than size of channel_mapping_t sequence
20 // of the *destination* color base.
21
22 // RGB (wider space) transformation to Gray (narrower space) takes only R channel value
23 {
24 gil::rgb8_pixel_t src{ 32, 64, 128 };
25 gil::gray8_pixel_t dst{ 0 };
26 gil::static_transform(src, dst, [](std::uint8_t src_channel) {
27 return src_channel; // copy
28 });
29 assert(gil::at_c<0>(dst) == std::uint16_t{32});
30 }
31
32 // Gray (narrower space) to RGB (wider space) transformation FAILS to compile
33 {
34 gil::gray8_pixel_t src{32};
35 gil::rgb8_pixel_t dst{0, 0, 0};
36 gil::static_transform(src, dst, [](std::uint8_t src_channel) {
37 return src_channel; // copy
38 });
39 }
40 }