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