gray_to_rgba.hpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. //
  2. // Copyright 2012 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_TOOLBOX_COLOR_CONVERTERS_GRAY_TO_RGBA_HPP
  9. #define BOOST_GIL_EXTENSION_TOOLBOX_COLOR_CONVERTERS_GRAY_TO_RGBA_HPP
  10. #include <boost/gil/color_convert.hpp>
  11. namespace boost{ namespace gil {
  12. /// This one is missing in gil ( color_convert.hpp ).
  13. template <>
  14. struct default_color_converter_impl<gray_t,rgba_t>
  15. {
  16. template <typename P1, typename P2>
  17. void operator()(const P1& src, P2& dst) const
  18. {
  19. get_color(dst,red_t()) =
  20. channel_convert<typename color_element_type<P2, red_t >::type>(get_color(src,gray_color_t()));
  21. get_color(dst,green_t())=
  22. channel_convert<typename color_element_type<P2, green_t>::type>(get_color(src,gray_color_t()));
  23. get_color(dst,blue_t()) =
  24. channel_convert<typename color_element_type<P2, blue_t >::type>(get_color(src,gray_color_t()));
  25. using channel_t = typename channel_type<P2>::type;
  26. get_color(dst,alpha_t()) = channel_traits< channel_t >::max_value();
  27. }
  28. };
  29. }} // namespace boost::gil
  30. #endif