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/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>
22 using tag_t = boost::gil::tiff_tag;
24 // TODO: Rename the macros to BOOST_GIL_*
26 #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
28 #define GENERATE_WRITE_TILE_BIT_ALIGNED_RGB(z, n, data)\
29 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) )\
31 using namespace std; \
32 using namespace boost; \
33 using namespace gil; \
34 string filename( string( "tiger-" ) + BOOST_PP_STRINGIZE(data) + "-strip-contig-" ); \
35 string path( tiff_in_GM ); \
37 if(BOOST_PP_LESS(n, 10)==1) \
39 filename += padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
41 bit_aligned_image3_type< n, n, n, rgb_layout_t >::type img_strip, img_saved; \
42 read_image( path, img_strip, tag_t() ); \
43 image_write_info<tag_t> info; \
44 info._is_tiled = true; \
45 info._tile_width = info._tile_length = 16; \
46 write_view( tiff_out + filename, view(img_strip), info ); \
47 read_image( tiff_out + filename, img_saved, tag_t() ); \
48 BOOST_CHECK_EQUAL( equal_pixels( const_view(img_strip), const_view(img_saved) ), true); \
51 // Special case for minisblack images
52 #define GENERATE_WRITE_TILE_BIT_ALIGNED_MINISBLACK(z, n, data)\
53 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) )\
55 using namespace std; \
56 using namespace boost; \
57 using namespace gil; \
58 string filename( string( "tiger-" ) + BOOST_PP_STRINGIZE(data) + "-strip-" ); \
59 string path( tiff_in_GM ); \
61 if(BOOST_PP_LESS(n, 10)==1) \
63 filename = filename + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
65 bit_aligned_image1_type< n, gray_layout_t >::type img_strip, img_saved; \
66 read_image( path, img_strip, tag_t() ); \
67 image_write_info<tag_t> info; \
68 info._is_tiled = true; \
69 info._tile_width = info._tile_length = 16; \
70 write_view( tiff_out + filename, view(img_strip), info ); \
71 read_image( tiff_out + filename, img_saved, tag_t() ); \
72 BOOST_CHECK_EQUAL( equal_pixels( const_view(img_strip), const_view(img_saved) ), true); \
75 // Special case for palette images
76 #define GENERATE_WRITE_TILE_BIT_ALIGNED_PALETTE(z, n, data)\
77 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) )\
79 using namespace std; \
80 using namespace boost; \
81 using namespace gil; \
82 string filename( string( "tiger-" ) + BOOST_PP_STRINGIZE(data) + "-strip-" ); \
83 string path( tiff_in_GM ); \
85 if(BOOST_PP_LESS(n, 10)==1) \
87 filename = filename + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
89 rgb16_image_t img_strip, img_saved; \
90 read_image( path, img_strip, tag_t() ); \
91 image_write_info<tag_t> info; \
92 info._is_tiled = true; \
93 info._tile_width = info._tile_length = 16; \
94 write_view( tiff_out + filename, view(img_strip), info ); \
95 read_image( tiff_out + filename, img_saved, tag_t() ); \
96 BOOST_CHECK_EQUAL( equal_pixels( const_view(img_strip), const_view(img_saved) ), true); \
101 #define GENERATE_WRITE_TILE_BIT_ALIGNED_RGB(z, n, data)\
102 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) )\
104 using namespace std; \
105 using namespace boost; \
106 using namespace gil; \
107 string filename( string( "tiger-" ) + BOOST_PP_STRINGIZE(data) + "-strip-contig-" ); \
108 string path( tiff_in_GM ); \
109 string padding(""); \
110 if(BOOST_PP_LESS(n, 10)==1) \
112 filename += padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
114 bit_aligned_image3_type< n, n, n, rgb_layout_t >::type img_strip, img_saved; \
115 read_image( path, img_strip, tag_t() ); \
116 image_write_info<tag_t> info; \
117 info._is_tiled = true; \
118 info._tile_width = info._tile_length = 16; \
121 // Special case for minisblack images
122 #define GENERATE_WRITE_TILE_BIT_ALIGNED_MINISBLACK(z, n, data)\
123 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) )\
125 using namespace std; \
126 using namespace boost; \
127 using namespace gil; \
128 string filename( string( "tiger-" ) + BOOST_PP_STRINGIZE(data) + "-strip-" ); \
129 string path( tiff_in_GM ); \
130 string padding(""); \
131 if(BOOST_PP_LESS(n, 10)==1) \
133 filename = filename + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
135 bit_aligned_image1_type< n, gray_layout_t >::type img_strip, img_saved; \
136 read_image( path, img_strip, tag_t() ); \
137 image_write_info<tag_t> info; \
138 info._is_tiled = true; \
139 info._tile_width = info._tile_length = 16; \
142 // Special case for palette images
143 #define GENERATE_WRITE_TILE_BIT_ALIGNED_PALETTE(z, n, data)\
144 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) )\
146 using namespace std; \
147 using namespace boost; \
148 using namespace gil; \
149 string filename( string( "tiger-" ) + BOOST_PP_STRINGIZE(data) + "-strip-" ); \
150 string path( tiff_in_GM ); \
151 string padding(""); \
152 if(BOOST_PP_LESS(n, 10)==1) \
154 filename = filename + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
156 rgb16_image_t img_strip, img_saved; \
157 read_image( path, img_strip, tag_t() ); \
158 image_write_info<tag_t> info; \
159 info._is_tiled = true; \
160 info._tile_width = info._tile_length = 16; \
163 #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
165 #endif // BOOST_GIL_TIFF_TILED_READ_MACROS_HPP