pnm_write_test.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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 pnm_write_test_module
  9. #include <boost/gil/extension/io/pnm.hpp>
  10. #include <boost/test/unit_test.hpp>
  11. #include "color_space_write_test.hpp"
  12. #include "mandel_view.hpp"
  13. #include "paths.hpp"
  14. using namespace std;
  15. using namespace boost::gil;
  16. using tag_t = pnm_tag;
  17. BOOST_AUTO_TEST_SUITE( gil_io_pnm_tests )
  18. #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  19. BOOST_AUTO_TEST_CASE( write_test )
  20. {
  21. mandel_view< rgb8_pixel_t >::type v = create_mandel_view( 200, 200
  22. , rgb8_pixel_t( 0, 0, 255 )
  23. , rgb8_pixel_t( 0, 255, 0 )
  24. );
  25. // test writing all supported image types
  26. {
  27. using gray1_image_t = bit_aligned_image1_type<1, gray_layout_t>::type;
  28. gray1_image_t dst( 200, 200 );
  29. copy_and_convert_pixels( v, view( dst ));
  30. write_view( pnm_out + "p4_write_test.pnm"
  31. , view( dst )
  32. , pnm_tag()
  33. );
  34. }
  35. {
  36. gray8_image_t dst( 200, 200 );
  37. copy_and_convert_pixels( v, view( dst ));
  38. write_view( pnm_out + "p5_write_test.pnm"
  39. , view( dst )
  40. , pnm_tag()
  41. );
  42. }
  43. {
  44. write_view( pnm_out + "p6_write_test.pnm"
  45. , v
  46. , pnm_tag()
  47. );
  48. }
  49. }
  50. #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  51. BOOST_AUTO_TEST_CASE( rgb_color_space_write_test )
  52. {
  53. color_space_write_test< pnm_tag >( pnm_out + "rgb_color_space_test.pnm"
  54. , pnm_out + "bgr_color_space_test.pnm"
  55. );
  56. }
  57. BOOST_AUTO_TEST_SUITE_END()