tiff_tiled_read_macros.hpp 4.7 KB

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