]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/gil/test/extension/io/tiff/tiff_tiled_read_macros.hpp
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / boost / libs / gil / test / extension / io / tiff / tiff_tiled_read_macros.hpp
CommitLineData
f67539c2
TL
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_TEST_EXTENSION_IO_TIFF_TIFF_TILED_READ_MACROS_HPP
9#define BOOST_GIL_TEST_EXTENSION_IO_TIFF_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 <boost/core/lightweight_test.hpp>
21
22#include <string>
23
24#include "paths.hpp"
25
26// TODO: Rename macros to use BOOST_GIL_ prefix. See https://github.com/boostorg/gil/issues/410 ~mloskot
27// TODO: Make sure generated test cases are executed. See tiff_subimage_test.cpp. ~mloskot
28
29#define BOOST_GIL_TEST_NAME_TILE_STRIP_COMPARISON_BIT_ALIGNED_RGB(n, data) \
30 BOOST_PP_CAT( \
31 BOOST_PP_CAT( \
32 BOOST_PP_CAT( \
33 BOOST_PP_CAT( \
34 BOOST_PP_CAT(read_tile_and_compare_with_, BOOST_PP_TUPLE_ELEM(2, 0, data)), \
35 BOOST_PP_TUPLE_ELEM(2, 1, data)), \
36 _strip_), \
37 n), \
38 bit_bit_aligned)
39
40#define BOOST_GIL_TEST_GENERATE_TILE_STRIP_COMPARISON_BIT_ALIGNED_RGB(z, n, data) \
41 void BOOST_GIL_TEST_NAME_TILE_STRIP_COMPARISON_BIT_ALIGNED_RGB(n, data)() \
42 { \
43 namespace gil = boost::gil; \
44 std::string filename_strip( \
45 tiff_in_GM + "tiger-" + BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(2, 0, data)) + \
46 "-strip-" + BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(2, 1, data)) + "-"); \
47 std::string filename_tile( \
48 tiff_in_GM + "tiger-" + BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(2, 0, data)) + \
49 "-tile-" + BOOST_PP_STRINGIZE(BOOST_PP_TUPLE_ELEM(2, 1, data)) + "-"); \
50 std::string padding(""); \
51 if (BOOST_PP_LESS(n, 10) == 1) \
52 padding = "0"; \
53 filename_strip = filename_strip + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
54 filename_tile = filename_tile + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
55 gil::bit_aligned_image3_type<n, n, n, gil::rgb_layout_t>::type img_strip, img_tile; \
56 gil::read_image(filename_strip, img_strip, gil::tiff_tag()); \
57 gil::read_image(filename_tile, img_tile, gil::tiff_tag()); \
58 BOOST_TEST_EQ( \
59 gil::equal_pixels(gil::const_view(img_strip), gil::const_view(img_tile)), true); \
60 }
61
62// Special case for minisblack images
63#define BOOST_GIL_TEST_NAME_TILE_TILE_STRIP_COMPARISON_BIT_ALIGNED_MINISBLACK(n, data) \
64 BOOST_PP_CAT( \
65 BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(read_tile_and_compare_with_, data), _strip_), n), \
66 bit_bit_aligned)
67
68#define BOOST_GIL_TEST_GENERATE_TILE_STRIP_COMPARISON_BIT_ALIGNED_MINISBLACK(z, n, data) \
69 void BOOST_GIL_TEST_NAME_TILE_TILE_STRIP_COMPARISON_BIT_ALIGNED_MINISBLACK(n, data)() \
70 { \
71 namespace gil = boost::gil; \
72 std::string filename_strip(tiff_in_GM + "tiger-" + BOOST_PP_STRINGIZE(data) + "-strip-"); \
73 std::string filename_tile(tiff_in_GM + "tiger-" + BOOST_PP_STRINGIZE(data) + "-tile-"); \
74 std::string padding(""); \
75 if (BOOST_PP_LESS(n, 10) == 1) \
76 padding = "0"; \
77 filename_strip = filename_strip + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
78 filename_tile = filename_tile + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
79 gil::bit_aligned_image1_type<n, gil::gray_layout_t>::type img_strip, img_tile; \
80 gil::read_image(filename_strip, img_strip, gil::tiff_tag()); \
81 gil::read_image(filename_tile, img_tile, gil::tiff_tag()); \
82 BOOST_TEST_EQ( \
83 gil::equal_pixels(gil::const_view(img_strip), gil::const_view(img_tile)), true); \
84 }
85
86// Special case for palette images
87#define BOOST_GIL_TEST_NAME_TILE_STRIP_COMPARISON_PALETTE(n, data) \
88 BOOST_PP_CAT( \
89 BOOST_PP_CAT(BOOST_PP_CAT(BOOST_PP_CAT(read_tile_and_compare_with_, data), _strip_), n), \
90 bit)
91
92#define BOOST_GIL_TEST_GENERATE_TILE_STRIP_COMPARISON_PALETTE(z, n, data) \
93 void BOOST_GIL_TEST_NAME_TILE_STRIP_COMPARISON_PALETTE(n, data)() \
94 { \
95 namespace gil = boost::gil; \
96 std::string filename_strip(tiff_in_GM + "tiger-" + BOOST_PP_STRINGIZE(data) + "-strip-"); \
97 std::string filename_tile(tiff_in_GM + "tiger-" + BOOST_PP_STRINGIZE(data) + "-tile-"); \
98 std::string padding(""); \
99 if (BOOST_PP_LESS(n, 10) == 1) \
100 padding = "0"; \
101 filename_strip = filename_strip + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
102 filename_tile = filename_tile + padding + BOOST_PP_STRINGIZE(n) + ".tif"; \
103 gil::rgb16_image_t img_strip, img_tile; \
104 gil::read_image(filename_strip, img_strip, gil::tiff_tag()); \
105 gil::read_image(filename_tile, img_tile, gil::tiff_tag()); \
106 BOOST_TEST_EQ( \
107 gil::equal_pixels(gil::const_view(img_strip), gil::const_view(img_tile)), true); \
108 }
109
110#define BOOST_GIL_TEST_CALL_TILE_STRIP_COMPARISON_PALETTE(z, n, data) \
111 BOOST_GIL_TEST_NAME_TILE_STRIP_COMPARISON_PALETTE(n, data);
112
113
114#endif // BOOST_GIL_TEST_EXTENSION_IO_TIFF_TIFF_TILED_READ_MACROS_HPP