cmyka.hpp 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // Copyright 2012 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_TOOLBOX_COLOR_SPACES_CMYKA_HPP
  9. #define BOOST_GIL_EXTENSION_TOOLBOX_COLOR_SPACES_CMYKA_HPP
  10. #include <boost/gil/cmyk.hpp>
  11. #include <boost/gil/color_convert.hpp>
  12. #include <boost/gil/rgba.hpp>
  13. #include <boost/gil/typedefs.hpp>
  14. #include <boost/gil/detail/mp11.hpp>
  15. namespace boost{ namespace gil {
  16. /// \ingroup ColorSpaceModel
  17. using cmyka_t = mp11::mp_list<cyan_t, magenta_t, yellow_t, black_t, alpha_t>;
  18. /// \ingroup LayoutModel
  19. using cmyka_layout_t = layout<cmyka_t>;
  20. GIL_DEFINE_ALL_TYPEDEFS(8, uint8_t, cmyka)
  21. GIL_DEFINE_ALL_TYPEDEFS(8s, int8_t, cmyka)
  22. GIL_DEFINE_ALL_TYPEDEFS(16, uint16_t, cmyka)
  23. GIL_DEFINE_ALL_TYPEDEFS(16s, int16_t, cmyka)
  24. GIL_DEFINE_ALL_TYPEDEFS(32, uint32_t, cmyka)
  25. GIL_DEFINE_ALL_TYPEDEFS(32s, int32_t, cmyka)
  26. GIL_DEFINE_ALL_TYPEDEFS(32f, float32_t, cmyka)
  27. ///// \ingroup ColorConvert
  28. ///// \brief Converting CMYKA to any pixel type. Note: Supports homogeneous pixels only.
  29. //template <typename C2>
  30. //struct default_color_converter_impl<cmyka_t,C2> {
  31. // template <typename P1, typename P2>
  32. // void operator()(const P1& src, P2& dst) const {
  33. // using T1 = typename channel_type<P1>::type;
  34. // default_color_converter_impl<cmyk_t,C2>()(
  35. // pixel<T1,cmyk_layout_t>(channel_multiply(get_color(src,cyan_t()), get_color(src,alpha_t())),
  36. // channel_multiply(get_color(src,magenta_t()),get_color(src,alpha_t())),
  37. // channel_multiply(get_color(src,yellow_t()), get_color(src,alpha_t())),
  38. // channel_multiply(get_color(src,black_t()), get_color(src,alpha_t())))
  39. // ,dst);
  40. // }
  41. //};
  42. template <>
  43. struct default_color_converter_impl<cmyka_t,rgba_t> {
  44. template <typename P1, typename P2>
  45. void operator()(const P1& src, P2& dst) const {
  46. using T1 = typename channel_type<P1>::type;
  47. default_color_converter_impl<cmyk_t,rgba_t>()(
  48. pixel<T1,cmyk_layout_t>(get_color(src,cyan_t()),
  49. get_color(src,magenta_t()),
  50. get_color(src,yellow_t()),
  51. get_color(src,black_t()))
  52. ,dst);
  53. }
  54. };
  55. /// \ingroup ColorConvert
  56. /// \brief Unfortunately CMYKA to CMYKA must be explicitly provided - otherwise we get ambiguous specialization error.
  57. template <>
  58. struct default_color_converter_impl<cmyka_t,cmyka_t> {
  59. template <typename P1, typename P2>
  60. void operator()(const P1& src, P2& dst) const {
  61. static_for_each(src,dst,default_channel_converter());
  62. }
  63. };
  64. } // namespace gil
  65. } // namespace boost
  66. #endif