supported_types.hpp 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. //
  2. // Copyright 2007-2008 Christian Henning, Andreas Pokorny, Lubomir Bourdev
  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_SUPPORTED_TYPES_HPP
  9. #define BOOST_GIL_EXTENSION_IO_JPEG_DETAIL_SUPPORTED_TYPES_HPP
  10. #include <boost/gil/extension/io/jpeg/tags.hpp>
  11. #include <boost/gil/channel.hpp>
  12. #include <boost/gil/color_base.hpp>
  13. #include <type_traits>
  14. namespace boost { namespace gil { namespace detail {
  15. // Read support
  16. template< jpeg_color_space::type ColorSpace >
  17. struct jpeg_rw_support_base
  18. {
  19. static const jpeg_color_space::type _color_space = ColorSpace;
  20. };
  21. template< typename Channel
  22. , typename ColorSpace
  23. >
  24. struct jpeg_read_support : read_support_false
  25. , jpeg_rw_support_base< JCS_UNKNOWN > {};
  26. template<>
  27. struct jpeg_read_support<uint8_t
  28. , rgb_t
  29. > : read_support_true
  30. , jpeg_rw_support_base< JCS_RGB > {};
  31. template<>
  32. struct jpeg_read_support<uint8_t
  33. , cmyk_t
  34. > : read_support_true
  35. , jpeg_rw_support_base< JCS_CMYK > {};
  36. template<>
  37. struct jpeg_read_support<uint8_t
  38. , gray_t
  39. > : read_support_true
  40. , jpeg_rw_support_base< JCS_GRAYSCALE > {};
  41. // Write support
  42. template< typename Channel
  43. , typename ColorSpace
  44. >
  45. struct jpeg_write_support : write_support_false
  46. , jpeg_rw_support_base< JCS_UNKNOWN > {};
  47. template<>
  48. struct jpeg_write_support<uint8_t
  49. , gray_t
  50. > : write_support_true
  51. , jpeg_rw_support_base< JCS_GRAYSCALE > {};
  52. template<>
  53. struct jpeg_write_support<uint8_t
  54. , rgb_t
  55. > : write_support_true
  56. , jpeg_rw_support_base< JCS_RGB > {};
  57. template<>
  58. struct jpeg_write_support<uint8_t
  59. , cmyk_t
  60. > : write_support_true
  61. , jpeg_rw_support_base< JCS_CMYK > {};
  62. } // namespace detail
  63. template<typename Pixel>
  64. struct is_read_supported<Pixel, jpeg_tag>
  65. : std::integral_constant
  66. <
  67. bool,
  68. detail::jpeg_read_support
  69. <
  70. typename channel_type<Pixel>::type,
  71. typename color_space_type<Pixel>::type
  72. >::is_supported
  73. >
  74. {
  75. using parent_t = detail::jpeg_read_support
  76. <
  77. typename channel_type<Pixel>::type,
  78. typename color_space_type<Pixel>::type
  79. >;
  80. static const typename jpeg_color_space::type _color_space = parent_t::_color_space;
  81. };
  82. template<typename Pixel>
  83. struct is_write_supported<Pixel, jpeg_tag>
  84. : std::integral_constant
  85. <
  86. bool,
  87. detail::jpeg_write_support
  88. <
  89. typename channel_type<Pixel>::type,
  90. typename color_space_type<Pixel>::type
  91. >::is_supported
  92. >
  93. {};
  94. } // namespace gil
  95. } // namespace boost
  96. #endif