device_n.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // Copyright 2005-2007 Adobe Systems Incorporated
  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_DEVICE_N_HPP
  9. #define BOOST_GIL_DEVICE_N_HPP
  10. #include <boost/gil/metafunctions.hpp>
  11. #include <boost/gil/utilities.hpp>
  12. #include <boost/config.hpp>
  13. #include <boost/mpl/range_c.hpp>
  14. #include <boost/mpl/vector_c.hpp>
  15. #include <boost/type_traits.hpp>
  16. #include <cstddef>
  17. namespace boost { namespace gil {
  18. /// \brief unnamed color
  19. /// \ingroup ColorNameModel
  20. template <int N> struct devicen_color_t {};
  21. template <int N> struct devicen_t;
  22. /// \brief unnamed color space of one channel
  23. /// \ingroup ColorSpaceModel
  24. template <> struct devicen_t<1> : public mpl::vector1<devicen_color_t<0> > {};
  25. /// \brief unnamed color space of two channels
  26. /// \ingroup ColorSpaceModel
  27. template <> struct devicen_t<2> : public mpl::vector2<devicen_color_t<0>, devicen_color_t<1> > {};
  28. /// \brief unnamed color space of three channels
  29. /// \ingroup ColorSpaceModel
  30. template <> struct devicen_t<3> : public mpl::vector3<devicen_color_t<0>, devicen_color_t<1>, devicen_color_t<2> > {};
  31. /// \brief unnamed color space of four channels
  32. /// \ingroup ColorSpaceModel
  33. template <> struct devicen_t<4> : public mpl::vector4<devicen_color_t<0>, devicen_color_t<1>, devicen_color_t<2>, devicen_color_t<3> > {};
  34. /// \brief unnamed color space of five channels
  35. /// \ingroup ColorSpaceModel
  36. template <> struct devicen_t<5> : public mpl::vector5<devicen_color_t<0>, devicen_color_t<1>, devicen_color_t<2>, devicen_color_t<3>, devicen_color_t<4> > {};
  37. /// \brief unnamed color layout of up to five channels
  38. /// \ingroup LayoutModel
  39. template <int N> struct devicen_layout_t : public layout<devicen_t<N> > {};
  40. /// \ingroup ImageViewConstructors
  41. /// \brief from 2-channel planar data
  42. template <typename IC>
  43. inline typename type_from_x_iterator<planar_pixel_iterator<IC,devicen_t<2>>>::view_t
  44. planar_devicen_view(std::size_t width, std::size_t height, IC c0, IC c1, std::ptrdiff_t rowsize_in_bytes)
  45. {
  46. using view_t = typename type_from_x_iterator<planar_pixel_iterator<IC,devicen_t<2>>>::view_t;
  47. return view_t(width, height, typename view_t::locator(typename view_t::x_iterator(c0,c1), rowsize_in_bytes));
  48. }
  49. /// \ingroup ImageViewConstructors
  50. /// \brief from 3-channel planar data
  51. template <typename IC>
  52. inline typename type_from_x_iterator<planar_pixel_iterator<IC,devicen_t<3>>>::view_t
  53. planar_devicen_view(std::size_t width, std::size_t height, IC c0, IC c1, IC c2, std::ptrdiff_t rowsize_in_bytes)
  54. {
  55. using view_t = typename type_from_x_iterator<planar_pixel_iterator<IC,devicen_t<3>>>::view_t;
  56. return view_t(width, height, typename view_t::locator(typename view_t::x_iterator(c0,c1,c2), rowsize_in_bytes));
  57. }
  58. /// \ingroup ImageViewConstructors
  59. /// \brief from 4-channel planar data
  60. template <typename IC>
  61. inline typename type_from_x_iterator<planar_pixel_iterator<IC,devicen_t<4>>>::view_t
  62. planar_devicen_view(std::size_t width, std::size_t height, IC c0, IC c1, IC c2, IC c3, std::ptrdiff_t rowsize_in_bytes)
  63. {
  64. using view_t = typename type_from_x_iterator<planar_pixel_iterator<IC,devicen_t<4>>>::view_t;
  65. return view_t(width, height, typename view_t::locator(typename view_t::x_iterator(c0,c1,c2,c3), rowsize_in_bytes));
  66. }
  67. /// \ingroup ImageViewConstructors
  68. /// \brief from 5-channel planar data
  69. template <typename IC>
  70. inline typename type_from_x_iterator<planar_pixel_iterator<IC,devicen_t<5>>>::view_t
  71. planar_devicen_view(std::size_t width, std::size_t height, IC c0, IC c1, IC c2, IC c3, IC c4, std::ptrdiff_t rowsize_in_bytes)
  72. {
  73. using view_t = typename type_from_x_iterator<planar_pixel_iterator<IC,devicen_t<5>>>::view_t;
  74. return view_t(width, height, typename view_t::locator(typename view_t::x_iterator(c0,c1,c2,c3,c4), rowsize_in_bytes));
  75. }
  76. } } // namespace boost::gil
  77. #endif