raw_test.cpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128
  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. #define BOOST_TEST_MODULE raw_test
  9. #define BOOST_FILESYSTEM_VERSION 3
  10. #define BOOST_GIL_IO_ADD_FS_PATH_SUPPORT
  11. #include <boost/gil.hpp>
  12. #include <boost/gil/extension/io/raw.hpp>
  13. #include <boost/mp11.hpp>
  14. #include <boost/test/unit_test.hpp>
  15. #include <fstream>
  16. #include "mandel_view.hpp"
  17. #include "paths.hpp"
  18. #include "subimage_test.hpp"
  19. using namespace std;
  20. using namespace boost;
  21. using namespace gil;
  22. namespace fs = boost::filesystem;
  23. using tag_t = raw_tag;
  24. BOOST_AUTO_TEST_SUITE( gil_io_raw_tests )
  25. #ifdef BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
  26. BOOST_AUTO_TEST_CASE( read_image_info_using_string )
  27. {
  28. {
  29. /// raw_tag reader's can only constructed with char*, std::string, and LibRaw object
  30. using backend_t = get_reader_backend<char const*, tag_t>::type;
  31. backend_t b = make_reader_backend(raw_filename.c_str(),
  32. image_read_settings<raw_tag>());
  33. backend_t backend = read_image_info(raw_filename, tag_t());
  34. BOOST_CHECK_EQUAL( backend._info._width , 2176 );
  35. BOOST_CHECK_EQUAL( backend._info._height, 1448 );
  36. }
  37. {
  38. fs::path my_path( raw_filename );
  39. using backend_t = get_reader_backend<fs::path, tag_t>::type;
  40. backend_t backend = read_image_info(my_path, tag_t());
  41. BOOST_CHECK_EQUAL( backend._info._width , 2176 );
  42. BOOST_CHECK_EQUAL( backend._info._height, 1448 );
  43. }
  44. }
  45. BOOST_AUTO_TEST_CASE( read_image_test )
  46. {
  47. {
  48. rgb8_image_t img;
  49. read_image( raw_filename, img, tag_t() );
  50. BOOST_CHECK_EQUAL( img.width() , 2176 );
  51. BOOST_CHECK_EQUAL( img.height(), 1448 );
  52. }
  53. {
  54. fs::path my_path( raw_filename );
  55. rgb8_image_t img;
  56. read_image( my_path, img, tag_t() );
  57. BOOST_CHECK_EQUAL( img.width() , 2176 );
  58. BOOST_CHECK_EQUAL( img.height(), 1448 );
  59. }
  60. }
  61. BOOST_AUTO_TEST_CASE( read_and_convert_image_test )
  62. {
  63. rgb8_image_t img;
  64. read_and_convert_image( raw_filename, img, tag_t() );
  65. BOOST_CHECK_EQUAL( img.width() , 2176 );
  66. BOOST_CHECK_EQUAL( img.height(), 1448 );
  67. }
  68. BOOST_AUTO_TEST_CASE( read_view_test )
  69. {
  70. rgb8_image_t img( 2176, 1448 );
  71. read_view( raw_filename, view( img ), tag_t() );
  72. }
  73. BOOST_AUTO_TEST_CASE( read_and_convert_view_test )
  74. {
  75. rgb8_image_t img( 2176, 1448 );
  76. read_and_convert_view( raw_filename, view( img ), tag_t() );
  77. }
  78. // BOOST_AUTO_TEST_CASE( subimage_test )
  79. // {
  80. // run_subimage_test<rgb8_image_t, tag_t>(raw_filename, point_t(0, 0), point_t(127, 1));
  81. // run_subimage_test<rgb8_image_t, tag_t>(raw_filename, point_t(39, 7), point_t(50, 50));
  82. // }
  83. BOOST_AUTO_TEST_CASE( dynamic_image_test )
  84. {
  85. using my_img_types = mp11::mp_list
  86. <
  87. gray8_image_t,
  88. gray16_image_t,
  89. rgb8_image_t,
  90. rgba8_image_t
  91. >;
  92. any_image< my_img_types > runtime_image;
  93. read_image(raw_filename.c_str(), runtime_image, tag_t());
  94. }
  95. #endif // BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
  96. BOOST_AUTO_TEST_SUITE_END()