all_formats_test.cpp 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 all_formats_test
  9. #include <boost/gil/extension/io/png.hpp>
  10. #include <boost/gil/extension/io/bmp.hpp>
  11. #include <boost/gil/extension/io/jpeg.hpp>
  12. #include <boost/gil/extension/io/pnm.hpp>
  13. #include <boost/gil/extension/io/targa.hpp>
  14. #include <boost/gil/extension/io/tiff.hpp>
  15. #include <boost/test/unit_test.hpp>
  16. #include "paths.hpp"
  17. // Test will include all format's headers and load and write some images.
  18. // This test is more of a compilation test.
  19. using namespace std;
  20. using namespace boost::gil;
  21. namespace fs = boost::filesystem;
  22. BOOST_AUTO_TEST_SUITE( gil_io_tests )
  23. BOOST_AUTO_TEST_CASE( non_bit_aligned_image_test )
  24. {
  25. #ifdef BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
  26. {
  27. rgb8_image_t img;
  28. read_image( bmp_filename, img, bmp_tag() );
  29. #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  30. fs::create_directories(fs::path(bmp_out));
  31. write_view( bmp_out + "all_formats_test.bmp", view( img ), bmp_tag() );
  32. #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  33. }
  34. {
  35. rgb8_image_t img;
  36. read_image( jpeg_filename, img, jpeg_tag() );
  37. #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  38. fs::create_directories(fs::path(jpeg_out));
  39. write_view( jpeg_out + "all_formats_test.jpg", view( img ), jpeg_tag() );
  40. #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  41. }
  42. {
  43. rgba8_image_t img;
  44. read_image( png_filename, img, png_tag() );
  45. #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  46. fs::create_directories(fs::path(png_out));
  47. write_view( png_out + "all_formats_test.png", view( img ), png_tag() );
  48. #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  49. }
  50. {
  51. rgb8_image_t img;
  52. read_image( pnm_filename, img, pnm_tag() );
  53. #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  54. fs::create_directories(fs::path(pnm_out));
  55. write_view( pnm_out + "all_formats_test.pnm", view( img ), pnm_tag() );
  56. #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  57. }
  58. {
  59. rgb8_image_t img;
  60. read_image( targa_filename, img, targa_tag() );
  61. #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  62. fs::create_directories(fs::path(targa_out));
  63. write_view( targa_out + "all_formats_test.tga", view( img ), targa_tag() );
  64. #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  65. }
  66. {
  67. rgba8_image_t img;
  68. read_image( tiff_filename, img, tiff_tag() );
  69. #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  70. fs::create_directories(fs::path(tiff_out));
  71. write_view( tiff_out + "all_formats_test.tif", view( img ), tiff_tag() );
  72. #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  73. }
  74. #endif // BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
  75. }
  76. BOOST_AUTO_TEST_SUITE_END()