jpeg_write_test.cpp 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 jpeg_write_test_module
  9. #include <boost/gil.hpp>
  10. #include <boost/gil/extension/io/jpeg.hpp>
  11. #include <boost/test/unit_test.hpp>
  12. #include "color_space_write_test.hpp"
  13. #include "mandel_view.hpp"
  14. #include "paths.hpp"
  15. using namespace std;
  16. using namespace boost::gil;
  17. using tag_t = jpeg_tag;
  18. BOOST_AUTO_TEST_SUITE( gil_io_jpeg_tests )
  19. #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  20. BOOST_AUTO_TEST_CASE( write_test )
  21. {
  22. // test writing all supported image types
  23. {
  24. write_view( jpeg_out + "gray8_test.jpg"
  25. , create_mandel_view( 200, 200
  26. , gray8_pixel_t( 0 )
  27. , gray8_pixel_t( 255 )
  28. )
  29. , tag_t()
  30. );
  31. }
  32. {
  33. write_view( jpeg_out + "rgb8_test.jpg"
  34. , create_mandel_view( 200, 200
  35. , rgb8_pixel_t( 0, 0, 255 )
  36. , rgb8_pixel_t( 0, 255, 0 )
  37. )
  38. , tag_t()
  39. );
  40. }
  41. {
  42. write_view( jpeg_out + "cmyk8_test.jpg"
  43. , create_mandel_view( 200, 200
  44. , cmyk8_pixel_t( 0, 0, 255, 127 )
  45. , cmyk8_pixel_t( 0, 255, 0, 127 )
  46. )
  47. , tag_t()
  48. );
  49. }
  50. }
  51. #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  52. #ifdef BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
  53. BOOST_AUTO_TEST_CASE( dct_method_write_test )
  54. {
  55. {
  56. using image_t = rgb8_image_t;
  57. image_t img;
  58. read_image( jpeg_filename
  59. , img
  60. , tag_t()
  61. );
  62. image_write_info< jpeg_tag > info;
  63. info._dct_method = jpeg_dct_method::fast;
  64. #ifdef BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  65. write_view( jpeg_out + "fast_dct_write_test.jpg"
  66. , view( img )
  67. , info
  68. );
  69. #endif // BOOST_GIL_IO_TEST_ALLOW_WRITING_IMAGES
  70. }
  71. }
  72. #endif // BOOST_GIL_IO_TEST_ALLOW_READING_IMAGES
  73. BOOST_AUTO_TEST_CASE( rgb_color_space_write_test )
  74. {
  75. color_space_write_test< jpeg_tag >( jpeg_out + "rgb_color_space_test.jpg"
  76. , jpeg_out + "bgr_color_space_test.jpg"
  77. );
  78. }
  79. BOOST_AUTO_TEST_SUITE_END()