supported_types.hpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105
  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. #include <boost/gil/extension/io/targa/tags.hpp>
  11. #include <boost/gil/channel.hpp>
  12. #include <boost/gil/color_base.hpp>
  13. #include <boost/gil/io/base.hpp>
  14. #include <type_traits>
  15. namespace boost { namespace gil { namespace detail {
  16. // Read support
  17. template< typename Channel
  18. , typename ColorSpace
  19. >
  20. struct targa_read_support : read_support_false
  21. {
  22. static const targa_depth::type bpp = 0;
  23. };
  24. template<>
  25. struct targa_read_support<uint8_t
  26. , rgb_t
  27. > : read_support_true
  28. {
  29. static const targa_depth::type bpp = 24;
  30. };
  31. template<>
  32. struct targa_read_support<uint8_t
  33. , rgba_t
  34. > : read_support_true
  35. {
  36. static const targa_depth::type bpp = 32;
  37. };
  38. // Write support
  39. template< typename Channel
  40. , typename ColorSpace
  41. >
  42. struct targa_write_support : write_support_false
  43. {};
  44. template<>
  45. struct targa_write_support<uint8_t
  46. , rgb_t
  47. > : write_support_true {};
  48. template<>
  49. struct targa_write_support<uint8_t
  50. , rgba_t
  51. > : write_support_true {};
  52. } // namespace detail
  53. template<typename Pixel>
  54. struct is_read_supported<Pixel, targa_tag>
  55. : std::integral_constant
  56. <
  57. bool,
  58. detail::targa_read_support
  59. <
  60. typename channel_type<Pixel>::type,
  61. typename color_space_type<Pixel>::type
  62. >::is_supported
  63. >
  64. {
  65. using parent_t = detail::targa_read_support
  66. <
  67. typename channel_type<Pixel>::type,
  68. typename color_space_type<Pixel>::type
  69. >;
  70. static const typename targa_depth::type bpp = parent_t::bpp;
  71. };
  72. template<typename Pixel>
  73. struct is_write_supported<Pixel, targa_tag>
  74. : std::integral_constant
  75. <
  76. bool,
  77. detail::targa_write_support
  78. <
  79. typename channel_type<Pixel>::type,
  80. typename color_space_type<Pixel>::type
  81. >::is_supported
  82. >
  83. {};
  84. }} // namespace boost::gil
  85. #endif