1 // 2 // Copyright 2010 Kenneth Riddile 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_TARGA_DETAIL_SUPPORTED_TYPES_HPP 9 #define BOOST_GIL_EXTENSION_IO_TARGA_DETAIL_SUPPORTED_TYPES_HPP 10 11 #include <boost/gil/channel.hpp> 12 #include <boost/gil/color_base.hpp> 13 #include <boost/gil/io/base.hpp> 14 15 #include <boost/mpl/not.hpp> 16 #include <boost/type_traits/is_same.hpp> 17 18 namespace boost { namespace gil { namespace detail { 19 20 // Read support 21 22 template< typename Channel 23 , typename ColorSpace 24 > 25 struct targa_read_support : read_support_false 26 { 27 static const targa_depth::type bpp = 0; 28 }; 29 30 template<> 31 struct targa_read_support<uint8_t 32 , rgb_t 33 > : read_support_true 34 { 35 static const targa_depth::type bpp = 24; 36 }; 37 38 39 template<> 40 struct targa_read_support<uint8_t 41 , rgba_t 42 > : read_support_true 43 { 44 static const targa_depth::type bpp = 32; 45 }; 46 47 48 // Write support 49 50 template< typename Channel 51 , typename ColorSpace 52 > 53 struct targa_write_support : write_support_false 54 {}; 55 56 template<> 57 struct targa_write_support<uint8_t 58 , rgb_t 59 > : write_support_true {}; 60 61 template<> 62 struct targa_write_support<uint8_t 63 , rgba_t 64 > : write_support_true {}; 65 66 } // namespace detail 67 68 69 template< typename Pixel > 70 struct is_read_supported< Pixel 71 , targa_tag 72 > 73 : mpl::bool_< detail::targa_read_support< typename channel_type< Pixel >::type 74 , typename color_space_type< Pixel >::type 75 >::is_supported 76 > 77 { 78 typedef detail::targa_read_support< typename channel_type< Pixel >::type 79 , typename color_space_type< Pixel >::type 80 > parent_t; 81 82 static const typename targa_depth::type bpp = parent_t::bpp; 83 }; 84 85 template< typename Pixel > 86 struct is_write_supported< Pixel 87 , targa_tag 88 > 89 : mpl::bool_< detail::targa_write_support< typename channel_type< Pixel >::type 90 , typename color_space_type< Pixel >::type 91 >::is_supported 92 > {}; 93 94 } // namespace gil 95 } // namespace boost 96 97 98 #endif 99