]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/gil/test/extension/io/jpeg/jpeg_old_test.cpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / libs / gil / test / extension / io / jpeg / jpeg_old_test.cpp
1 //
2 // Copyright 2013 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 #include <boost/gil.hpp>
9 #include <boost/gil/extension/io/jpeg/old.hpp>
10
11 #include <boost/mp11.hpp>
12 #include <boost/core/lightweight_test.hpp>
13
14 #include "mandel_view.hpp"
15 #include "paths.hpp"
16
17 namespace gil = boost::gil;
18 namespace mp11 = boost::mp11;
19
20 #ifdef BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
21
22 void test_old_read_dimensions()
23 {
24 gil::point_t dim = gil::jpeg_read_dimensions(jpeg_filename);
25 BOOST_TEST_EQ(dim.x, 1000);
26 BOOST_TEST_EQ(dim.y, 600);
27 }
28
29 void test_old_read_image()
30 {
31 gil::rgb8_image_t img;
32 gil::jpeg_read_image(jpeg_filename, img);
33
34 BOOST_TEST_EQ(img.width(), 1000);
35 BOOST_TEST_EQ(img.height(), 600);
36 }
37
38 void test_old_read_and_convert_image()
39 {
40 gil::rgb8_image_t img;
41 gil::jpeg_read_and_convert_image(jpeg_filename, img);
42
43 BOOST_TEST_EQ(img.width(), 1000);
44 BOOST_TEST_EQ(img.height(), 600);
45 }
46
47 void test_old_read_view()
48 {
49 gil::rgb8_image_t img(1000, 600);
50 gil::jpeg_read_view(jpeg_filename, gil::view(img));
51 }
52
53 void test_old_read_and_convert_view()
54 {
55 gil::rgb8_image_t img(1000, 600);
56 gil::jpeg_read_and_convert_view(jpeg_filename, gil::view(img));
57 }
58
59 void test_old_write_view()
60 {
61 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
62 auto b = gil::rgb8_pixel_t(0, 0, 255);
63 auto g = gil::rgb8_pixel_t(0, 255, 0);
64 gil::jpeg_write_view(jpeg_out + "old_write_test.jpg", create_mandel_view(320, 240, b, g));
65 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
66 }
67
68 void test_old_dynamic_image()
69 {
70 using my_img_types = mp11::mp_list
71 <
72 gil::gray8_image_t,
73 gil::gray16_image_t,
74 gil::rgb8_image_t,
75 gil::rgba8_image_t
76 >;
77
78 gil::any_image<my_img_types> image;
79 gil::jpeg_read_image(jpeg_filename.c_str(), image);
80
81 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
82 gil::jpeg_write_view(jpeg_out + "old_dynamic_image_test.jpg", gil::view(image));
83 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
84 }
85
86 int main()
87 {
88 test_old_read_dimensions();
89 test_old_read_image();
90 test_old_read_and_convert_image();
91 test_old_read_view();
92 test_old_read_and_convert_view();
93 test_old_write_view();
94 test_old_dynamic_image();
95
96 return boost::report_errors();
97 }
98
99 #else
100 int main() {}
101 #endif // BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES