is_allowed.hpp 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  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_PNM_DETAIL_IS_ALLOWED_HPP
  9. #define BOOST_GIL_EXTENSION_IO_PNM_DETAIL_IS_ALLOWED_HPP
  10. #include <boost/gil/extension/io/pnm/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< pnm_tag >& info
  15. , std::true_type // is read_and_no_convert
  16. )
  17. {
  18. pnm_image_type::type asc_type = is_read_supported< typename get_pixel_type< View >::type
  19. , pnm_tag
  20. >::_asc_type;
  21. pnm_image_type::type bin_type = is_read_supported< typename get_pixel_type< View >::type
  22. , pnm_tag
  23. >::_bin_type;
  24. if( info._type == pnm_image_type::mono_asc_t::value )
  25. {
  26. // ascii mono images are read gray8_image_t
  27. return ( asc_type == pnm_image_type::gray_asc_t::value );
  28. }
  29. return ( asc_type == info._type
  30. || bin_type == info._type
  31. );
  32. }
  33. template< typename View >
  34. bool is_allowed( const image_read_info< pnm_tag >& /* info */
  35. , std::false_type // is read_and_convert
  36. )
  37. {
  38. return true;
  39. }
  40. } // namespace detail
  41. } // namespace gil
  42. } // namespace boost
  43. #endif