2 // Copyright 2013 Christian Henning
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
8 #ifndef BOOST_GIL_TEST_EXTENSION_IO_TIFF_TIFF_TILED_WRITE_MACROS_HPP
9 #define BOOST_GIL_TEST_EXTENSION_IO_TIFF_TIFF_TILED_WRITE_MACROS_HPP
11 #include <boost/gil.hpp>
12 #include <boost/gil/extension/io/tiff.hpp>
14 #include <boost/preprocessor/cat.hpp>
15 #include <boost/preprocessor/stringize.hpp>
16 #include <boost/preprocessor/tuple/elem.hpp>
17 #include <boost/preprocessor/comparison/less.hpp>
18 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
24 // TODO: Rename macros to use BOOST_GIL_ prefix. See https://github.com/boostorg/gil/issues/410 ~mloskot
25 // TODO: Make sure generated test cases are executed. See tiff_subimage_test.cpp. ~mloskot
27 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
29 #define GENERATE_WRITE_TILE_BIT_ALIGNED_RGB(z, n, data) \
32 BOOST_PP_CAT(BOOST_PP_CAT(write_rgb_tile_and_compare_with_, data), _strip_), n), \
35 namespace gil = boost::gil; \
36 std::string filename(std::string("tiger-") + BOOST_PP_STRINGIZE(data) + "-strip-contig-"); \
37 std::string path(tiff_in_GM); \
38 std::string padding(""); \
39 if (BOOST_PP_LESS(n, 10) == 1) \
41 filename += padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
43 gil::bit_aligned_image3_type<n, n, n, gil::rgb_layout_t>::type img_strip, img_saved; \
44 gil::read_image(path, img_strip, gil::tiff_tag()); \
45 gil::image_write_info<gil::tiff_tag> info; \
46 info._is_tiled = true; \
47 info._tile_width = info._tile_length = 16; \
48 gil::write_view(tiff_out + filename, gil::view(img_strip), info); \
49 gil::read_image(tiff_out + filename, img_saved, gil::tiff_tag()); \
51 gil::equal_pixels(gil::const_view(img_strip), gil::const_view(img_saved)), true); \
54 // Special case for minisblack images
55 #define GENERATE_WRITE_TILE_BIT_ALIGNED_MINISBLACK(z, n, data) \
58 BOOST_PP_CAT(BOOST_PP_CAT(write_minisblack_tile_and_compare_with_, data), _strip_), \
62 namespace gil = boost::gil; \
63 std::string filename(std::string("tiger-") + BOOST_PP_STRINGIZE(data) + "-strip-"); \
64 std::string path(tiff_in_GM); \
65 std::string padding(""); \
66 if (BOOST_PP_LESS(n, 10) == 1) \
68 filename = filename + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
70 gil::bit_aligned_image1_type<n, gil::gray_layout_t>::type img_strip, img_saved; \
71 gil::read_image(path, img_strip, gil::tiff_tag()); \
72 gil::image_write_info<gil::tiff_tag> info; \
73 info._is_tiled = true; \
74 info._tile_width = info._tile_length = 16; \
75 gil::write_view(tiff_out + filename, gil::view(img_strip), info); \
76 gil::read_image(tiff_out + filename, img_saved, gil::tiff_tag()); \
78 gil::equal_pixels(gil::const_view(img_strip), gil::const_view(img_saved)), true); \
81 // Special case for palette images
82 #define GENERATE_WRITE_TILE_BIT_ALIGNED_PALETTE(z, n, data) \
85 BOOST_PP_CAT(BOOST_PP_CAT(write_palette_tile_and_compare_with_, data), _strip_), n), \
88 namespace gil = boost::gil; \
89 std::string filename(std::string("tiger-") + BOOST_PP_STRINGIZE(data) + "-strip-"); \
90 std::string path(tiff_in_GM); \
91 std::string padding(""); \
92 if (BOOST_PP_LESS(n, 10) == 1) \
94 filename = filename + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
96 gil::rgb16_image_t img_strip, img_saved; \
97 gil::read_image(path, img_strip, gil::tiff_tag()); \
98 gil::image_write_info<gil::tiff_tag> info; \
99 info._is_tiled = true; \
100 info._tile_width = info._tile_length = 16; \
101 gil::write_view(tiff_out + filename, gil::view(img_strip), info); \
102 gil::read_image(tiff_out + filename, img_saved, gil::tiff_tag()); \
104 gil::equal_pixels(gil::const_view(img_strip), gil::const_view(img_saved)), true); \
109 #define GENERATE_WRITE_TILE_BIT_ALIGNED_RGB(z, n, data) \
112 BOOST_PP_CAT(BOOST_PP_CAT(write_rgb_tile_and_compare_with_, data), _strip_), n), \
115 namespace gil = boost::gil; \
116 std::string filename(std::string("tiger-") + BOOST_PP_STRINGIZE(data) + "-strip-contig-"); \
117 std::string path(tiff_in_GM); \
118 std::string padding(""); \
119 if (BOOST_PP_LESS(n, 10) == 1) \
121 filename += padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
123 gil::bit_aligned_image3_type<n, n, n, gil::rgb_layout_t>::type img_strip, img_saved; \
124 gil::read_image(path, img_strip, gil::tiff_tag()); \
125 gil::image_write_info<gil::tiff_tag> info; \
126 info._is_tiled = true; \
127 info._tile_width = info._tile_length = 16; \
130 // Special case for minisblack images
131 #define GENERATE_WRITE_TILE_BIT_ALIGNED_MINISBLACK(z, n, data) \
134 BOOST_PP_CAT(BOOST_PP_CAT(write_minisblack_tile_and_compare_with_, data), _strip_), \
138 namespace gil = boost::gil; \
139 std::string filename(std::string("tiger-") + BOOST_PP_STRINGIZE(data) + "-strip-"); \
140 std::string path(tiff_in_GM); \
141 std::string padding(""); \
142 if (BOOST_PP_LESS(n, 10) == 1) \
144 filename = filename + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
146 gil::bit_aligned_image1_type<n, gil::gray_layout_t>::type img_strip, img_saved; \
147 gil::read_image(path, img_strip, gil::tiff_tag()); \
148 gil::image_write_info<gil::tiff_tag> info; \
149 info._is_tiled = true; \
150 info._tile_width = info._tile_length = 16; \
153 // Special case for palette images
154 #define GENERATE_WRITE_TILE_BIT_ALIGNED_PALETTE(z, n, data) \
157 BOOST_PP_CAT(BOOST_PP_CAT(write_palette_tile_and_compare_with_, data), _strip_), n), \
160 namespace gil = boost::gil; \
161 std::string filename(std::string("tiger-") + BOOST_PP_STRINGIZE(data) + "-strip-"); \
162 std::string path(tiff_in_GM); \
163 std::string padding(""); \
164 if (BOOST_PP_LESS(n, 10) == 1) \
166 filename = filename + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
168 gil::rgb16_image_t img_strip, img_saved; \
169 gil::read_image(path, img_strip, gil::tiff_tag()); \
170 gil::image_write_info<gil::tiff_tag> info; \
171 info._is_tiled = true; \
172 info._tile_width = info._tile_length = 16; \
175 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
177 #endif // BOOST_GIL_TEST_EXTENSION_IO_TIFF_TIFF_TILED_WRITE_MACROS_HPP