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_TIFF_TILED_WRITE_MACROS_HPP
9 #define BOOST_GIL_TIFF_TILED_WRITE_MACROS_HPP
11 #include <boost/gil.hpp>
12 #include <boost/gil/extension/io/tiff.hpp>
14 #include <boost/mpl/vector.hpp>
15 #include <boost/preprocessor/cat.hpp>
16 #include <boost/preprocessor/stringize.hpp>
17 #include <boost/preprocessor/tuple/elem.hpp>
18 #include <boost/preprocessor/comparison/less.hpp>
19 #include <boost/preprocessor/repetition/repeat_from_to.hpp>
23 using tag_t = boost::gil::tiff_tag;
25 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
27 #define GENERATE_WRITE_TILE_BIT_ALIGNED_RGB(z, n, data)\
28 BOOST_AUTO_TEST_CASE( BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(write_rgb_tile_and_compare_with_,data),_strip_),n), bit_bit_aligned) )\
30 using namespace std; \
31 using namespace boost; \
32 using namespace gil; \
33 string filename( string( "tiger-" ) + BOOST_PP_STRINGIZE(data) + "-strip-contig-" ); \
34 string path( tiff_in_GM ); \
36 if(BOOST_PP_LESS(n, 10)==1) \
38 filename += padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
40 bit_aligned_image3_type< n, n, n, rgb_layout_t >::type img_strip, img_saved; \
41 read_image( path, img_strip, tag_t() ); \
42 image_write_info<tag_t> info; \
43 info._is_tiled = true; \
44 info._tile_width = info._tile_length = 16; \
45 write_view( tiff_out + filename, view(img_strip), info ); \
46 read_image( tiff_out + filename, img_saved, tag_t() ); \
47 BOOST_CHECK_EQUAL( equal_pixels( const_view(img_strip), const_view(img_saved) ), true); \
50 // Special case for minisblack images
51 #define GENERATE_WRITE_TILE_BIT_ALIGNED_MINISBLACK(z, n, data)\
52 BOOST_AUTO_TEST_CASE( BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(write_minisblack_tile_and_compare_with_,data),_strip_),n), bit_bit_aligned) )\
54 using namespace std; \
55 using namespace boost; \
56 using namespace gil; \
57 string filename( string( "tiger-" ) + BOOST_PP_STRINGIZE(data) + "-strip-" ); \
58 string path( tiff_in_GM ); \
60 if(BOOST_PP_LESS(n, 10)==1) \
62 filename = filename + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
64 bit_aligned_image1_type< n, gray_layout_t >::type img_strip, img_saved; \
65 read_image( path, img_strip, tag_t() ); \
66 image_write_info<tag_t> info; \
67 info._is_tiled = true; \
68 info._tile_width = info._tile_length = 16; \
69 write_view( tiff_out + filename, view(img_strip), info ); \
70 read_image( tiff_out + filename, img_saved, tag_t() ); \
71 BOOST_CHECK_EQUAL( equal_pixels( const_view(img_strip), const_view(img_saved) ), true); \
74 // Special case for palette images
75 #define GENERATE_WRITE_TILE_BIT_ALIGNED_PALETTE(z, n, data)\
76 BOOST_AUTO_TEST_CASE( BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(write_palette_tile_and_compare_with_,data),_strip_),n), bit) )\
78 using namespace std; \
79 using namespace boost; \
80 using namespace gil; \
81 string filename( string( "tiger-" ) + BOOST_PP_STRINGIZE(data) + "-strip-" ); \
82 string path( tiff_in_GM ); \
84 if(BOOST_PP_LESS(n, 10)==1) \
86 filename = filename + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
88 rgb16_image_t img_strip, img_saved; \
89 read_image( path, img_strip, tag_t() ); \
90 image_write_info<tag_t> info; \
91 info._is_tiled = true; \
92 info._tile_width = info._tile_length = 16; \
93 write_view( tiff_out + filename, view(img_strip), info ); \
94 read_image( tiff_out + filename, img_saved, tag_t() ); \
95 BOOST_CHECK_EQUAL( equal_pixels( const_view(img_strip), const_view(img_saved) ), true); \
100 #define GENERATE_WRITE_TILE_BIT_ALIGNED_RGB(z, n, data)\
101 BOOST_AUTO_TEST_CASE( BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(write_rgb_tile_and_compare_with_,data),_strip_),n), bit_bit_aligned) )\
103 using namespace std; \
104 using namespace boost; \
105 using namespace gil; \
106 string filename( string( "tiger-" ) + BOOST_PP_STRINGIZE(data) + "-strip-contig-" ); \
107 string path( tiff_in_GM ); \
108 string padding(""); \
109 if(BOOST_PP_LESS(n, 10)==1) \
111 filename += padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
113 bit_aligned_image3_type< n, n, n, rgb_layout_t >::type img_strip, img_saved; \
114 read_image( path, img_strip, tag_t() ); \
115 image_write_info<tag_t> info; \
116 info._is_tiled = true; \
117 info._tile_width = info._tile_length = 16; \
120 // Special case for minisblack images
121 #define GENERATE_WRITE_TILE_BIT_ALIGNED_MINISBLACK(z, n, data)\
122 BOOST_AUTO_TEST_CASE( BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(write_minisblack_tile_and_compare_with_,data),_strip_),n), bit_bit_aligned) )\
124 using namespace std; \
125 using namespace boost; \
126 using namespace gil; \
127 string filename( string( "tiger-" ) + BOOST_PP_STRINGIZE(data) + "-strip-" ); \
128 string path( tiff_in_GM ); \
129 string padding(""); \
130 if(BOOST_PP_LESS(n, 10)==1) \
132 filename = filename + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
134 bit_aligned_image1_type< n, gray_layout_t >::type img_strip, img_saved; \
135 read_image( path, img_strip, tag_t() ); \
136 image_write_info<tag_t> info; \
137 info._is_tiled = true; \
138 info._tile_width = info._tile_length = 16; \
141 // Special case for palette images
142 #define GENERATE_WRITE_TILE_BIT_ALIGNED_PALETTE(z, n, data)\
143 BOOST_AUTO_TEST_CASE( BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(write_palette_tile_and_compare_with_,data),_strip_),n), bit) )\
145 using namespace std; \
146 using namespace boost; \
147 using namespace gil; \
148 string filename( string( "tiger-" ) + BOOST_PP_STRINGIZE(data) + "-strip-" ); \
149 string path( tiff_in_GM ); \
150 string padding(""); \
151 if(BOOST_PP_LESS(n, 10)==1) \
153 filename = filename + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
155 rgb16_image_t img_strip, img_saved; \
156 read_image( path, img_strip, tag_t() ); \
157 image_write_info<tag_t> info; \
158 info._is_tiled = true; \
159 info._tile_width = info._tile_length = 16; \
162 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
164 #endif // BOOST_GIL_TIFF_TILED_READ_MACROS_HPP