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 
11 namespace boost { namespace gil { namespace detail {
12 
13 template< typename View >
14 bool is_allowed( const image_read_info< pnm_tag >& info
15                , mpl::true_   // 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 
22     pnm_image_type::type bin_type = is_read_supported< typename get_pixel_type< View >::type
23                                                      , pnm_tag
24                                                      >::_bin_type;
25     if( info._type == pnm_image_type::mono_asc_t::value )
26     {
27         // ascii mono images are read gray8_image_t
28         return (  asc_type == pnm_image_type::gray_asc_t::value );
29     }
30 
31 
32     return (  asc_type == info._type
33            || bin_type == info._type
34            );
35 }
36 
37 template< typename View >
38 bool is_allowed( const image_read_info< pnm_tag >& /* info */
39                , mpl::false_  // is read_and_convert
40                )
41 {
42     return true;
43 }
44 
45 } // namespace detail
46 } // namespace gil
47 } // namespace boost
48 
49 #endif
50