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.hpp>
10
11 #include <boost/core/lightweight_test.hpp>
12
13 #include "color_space_write_test.hpp"
14 #include "mandel_view.hpp"
15 #include "paths.hpp"
16
17 namespace gil = boost::gil;
18
19 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
test_write_gray8()20 void test_write_gray8()
21 {
22 gil::write_view(jpeg_out + "gray8_test.jpg", create_mandel_view(200, 200,
23 gil::gray8_pixel_t(0), gil::gray8_pixel_t(255)), gil::jpeg_tag());
24 }
25
test_write_rgb8()26 void test_write_rgb8()
27 {
28 gil::write_view(jpeg_out + "rgb8_test.jpg", create_mandel_view(200, 200,
29 gil::rgb8_pixel_t(0, 0, 255), gil::rgb8_pixel_t(0, 255, 0)), gil::jpeg_tag());
30 }
31
test_write_cmyk8()32 void test_write_cmyk8()
33 {
34 gil::write_view(jpeg_out + "cmyk8_test.jpg", create_mandel_view(200, 200,
35 gil::cmyk8_pixel_t(0, 0, 255, 127), gil::cmyk8_pixel_t(0, 255, 0, 127)), gil::jpeg_tag());
36 }
37 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
38
39 #ifdef BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
40
test_dct_method_write_test()41 void test_dct_method_write_test()
42 {
43 using image_t = gil::rgb8_image_t;
44 image_t img;
45
46 gil::read_image(jpeg_filename, img, gil::jpeg_tag());
47 gil::image_write_info<gil::jpeg_tag> info;
48 info._dct_method = gil::jpeg_dct_method::fast;
49
50 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
51 gil::write_view(jpeg_out + "fast_dct_write_test.jpg", gil::view(img), info);
52 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
53 }
54
55 #endif // BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
56
test_rgb_color_space_write_test()57 void test_rgb_color_space_write_test()
58 {
59 color_space_write_test<gil::jpeg_tag>(
60 jpeg_out + "rgb_color_space_test.jpg",
61 jpeg_out + "bgr_color_space_test.jpg");
62 }
63
main()64 int main()
65 {
66 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
67 test_write_gray8();
68 test_write_rgb8();
69 test_write_cmyk8();
70 #endif
71
72 #ifdef BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
73 test_dct_method_write_test();
74 #endif
75
76 test_rgb_color_space_write_test();
77
78 return boost::report_errors();
79 }
80
81
82