Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / gil / test / extension / io / tiff_tiled_read_macros.hpp
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 #ifndef BOOST_GIL_TIFF_TILED_READ_MACROS_HPP
9 #define BOOST_GIL_TIFF_TILED_READ_MACROS_HPP
10
11 #include <boost/gil.hpp>
12 #include <boost/gil/extension/io/tiff/read.hpp>
13
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>
19
20 #include "paths.hpp"
21
22 using tag_t = boost::gil::tiff_tag;
23
24 // TODO: Rename the macros to BOOST_GIL_*
25
26 #define GENERATE_TILE_STRIP_COMPARISON_BIT_ALIGNED_RGB(z, n, data)\
27     BOOST_AUTO_TEST_CASE( BOOST_PP_CAT( \
28                                 BOOST_PP_CAT( \
29                                     BOOST_PP_CAT( \
30                                         BOOST_PP_CAT( \
31                                             BOOST_PP_CAT( read_tile_and_compare_with_ \
32                                                         , BOOST_PP_TUPLE_ELEM(2,0,data) \
33                                                         ) \
34                                                 , BOOST_PP_TUPLE_ELEM(2,1,data) \
35                                                 ) \
36                                             ,_strip_ \
37                                             ) \
38                                         ,n \
39                                         ) \
40                                       , bit_bit_aligned \
41                                       ) \
42                         )\
43     { \
44       using namespace std; \
45       using namespace boost; \
46       using namespace gil; \
47       string filename_strip( tiff_in_GM + "tiger-" + BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(2,0,data)) + "-strip-" + BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(2,1,data)) + "-" ); \
48       string filename_tile ( tiff_in_GM + "tiger-" + BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(2,0,data)) + "-tile-"  + BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(2,1,data)) + "-" ); \
49       string padding(""); \
50       if(BOOST_PP_LESS(n, 10)==1) \
51         padding = "0"; \
52       filename_strip = filename_strip + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
53       filename_tile  = filename_tile  + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
54       bit_aligned_image3_type< n, n, n, rgb_layout_t >::type img_strip, img_tile; \
55       read_image( filename_strip, img_strip, tag_t() ); \
56       read_image( filename_tile,  img_tile,  tag_t() ); \
57       BOOST_CHECK_EQUAL( equal_pixels( const_view(img_strip), const_view(img_tile) ), true); \
58     } \
59
60 // Special case for minisblack images
61 #define GENERATE_TILE_STRIP_COMPARISON_BIT_ALIGNED_MINISBLACK(z, n, data)\
62     BOOST_AUTO_TEST_CASE( BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(read_tile_and_compare_with_,data),_strip_),n), bit_bit_aligned) )\
63     { \
64       using namespace std; \
65       using namespace boost; \
66       using namespace gil; \
67       string filename_strip( tiff_in_GM + "tiger-" + BOOST_PP_STRINGIZE(data) + "-strip-" ); \
68       string filename_tile ( tiff_in_GM + "tiger-" + BOOST_PP_STRINGIZE(data) + "-tile-"  ); \
69       string padding(""); \
70       if(BOOST_PP_LESS(n, 10)==1) \
71         padding = "0"; \
72       filename_strip = filename_strip + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
73       filename_tile  = filename_tile  + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
74       bit_aligned_image1_type< n, gray_layout_t >::type img_strip, img_tile; \
75       read_image( filename_strip, img_strip, tag_t() ); \
76       read_image( filename_tile,  img_tile,  tag_t() ); \
77       BOOST_CHECK_EQUAL( equal_pixels( const_view(img_strip), const_view(img_tile) ), true); \
78     } \
79
80 // Special case for palette images
81 #define GENERATE_TILE_STRIP_COMPARISON_PALETTE(z, n, data)\
82     BOOST_AUTO_TEST_CASE( BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(read_tile_and_compare_with_,data),_strip_),n), bit) )\
83     { \
84       using namespace std; \
85       using namespace boost; \
86       using namespace gil; \
87       string filename_strip( tiff_in_GM + "tiger-" + BOOST_PP_STRINGIZE(data) + "-strip-" ); \
88       string filename_tile ( tiff_in_GM + "tiger-" + BOOST_PP_STRINGIZE(data) + "-tile-"  ); \
89       string padding(""); \
90       if(BOOST_PP_LESS(n, 10)==1) \
91         padding = "0"; \
92       filename_strip = filename_strip + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
93       filename_tile  = filename_tile  + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
94       rgb16_image_t img_strip, img_tile; \
95       read_image( filename_strip, img_strip, tag_t() ); \
96       read_image( filename_tile,  img_tile,  tag_t() ); \
97       BOOST_CHECK_EQUAL( equal_pixels( const_view(img_strip), const_view(img_tile) ), true); \
98     } \
99
100
101
102 #endif // BOOST_GIL_TIFF_TILED_READ_MACROS_HPP