is_allowed.hpp 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. //
  2. // Copyright 2009 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_EXTENSION_IO_JPEG_DETAIL_IS_ALLOWED_HPP
  9. #define BOOST_GIL_EXTENSION_IO_JPEG_DETAIL_IS_ALLOWED_HPP
  10. #include <boost/gil/extension/io/jpeg/tags.hpp>
  11. #include <type_traits>
  12. namespace boost { namespace gil { namespace detail {
  13. template< typename View >
  14. bool is_allowed( const image_read_info< jpeg_tag >& info
  15. , std::true_type // is read_and_no_convert
  16. )
  17. {
  18. if( info._color_space == JCS_YCbCr )
  19. {
  20. // We read JCS_YCbCr files as rgb.
  21. return ( is_read_supported< typename View::value_type
  22. , jpeg_tag
  23. >::_color_space == JCS_RGB );
  24. }
  25. return ( is_read_supported< typename View::value_type
  26. , jpeg_tag
  27. >::_color_space == info._color_space );
  28. }
  29. template< typename View >
  30. bool is_allowed( const image_read_info< jpeg_tag >& /* info */
  31. , std::false_type // is read_and_convert
  32. )
  33. {
  34. return true;
  35. }
  36. } // namespace detail
  37. } // namespace gil
  38. } // namespace boost
  39. #endif