annotate DEPENDENCIES/generic/include/boost/gil/extension/dynamic_image/any_image.hpp @ 125:34e428693f5d vext

Vext -> Repoint
author Chris Cannam
date Thu, 14 Jun 2018 11:15:39 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /*
Chris@16 2 Copyright 2005-2007 Adobe Systems Incorporated
Chris@16 3
Chris@16 4 Use, modification and distribution are subject to the Boost Software License,
Chris@16 5 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 6 http://www.boost.org/LICENSE_1_0.txt).
Chris@16 7
Chris@16 8 See http://opensource.adobe.com/gil for most recent version including documentation.
Chris@16 9 */
Chris@16 10 /*************************************************************************************************/
Chris@16 11
Chris@16 12 #ifndef GIL_DYNAMICIMAGE_ANY_IMAGE_HPP
Chris@16 13 #define GIL_DYNAMICIMAGE_ANY_IMAGE_HPP
Chris@16 14
Chris@16 15 ////////////////////////////////////////////////////////////////////////////////////////
Chris@16 16 /// \file
Chris@16 17 /// \brief Support for run-time instantiated images and image views
Chris@16 18 /// \author Lubomir Bourdev and Hailin Jin \n
Chris@16 19 /// Adobe Systems Incorporated
Chris@16 20 ///
Chris@16 21 ///
Chris@16 22 ////////////////////////////////////////////////////////////////////////////////////////
Chris@16 23
Chris@16 24 #include "any_image_view.hpp"
Chris@16 25 #include "../../image.hpp"
Chris@16 26
Chris@16 27 //#ifdef _MSC_VER
Chris@16 28 //#pragma warning(push)
Chris@16 29 //#pragma warning(disable : 4244) // conversion from 'std::ptrdiff_t' to 'int', possible loss of data. even if we static-assert the two types are the same (on visual studio 8)
Chris@16 30 //#endif
Chris@16 31
Chris@16 32 namespace boost { namespace gil {
Chris@16 33
Chris@16 34 namespace detail {
Chris@16 35 template <typename T> struct get_view_t { typedef typename T::view_t type; };
Chris@16 36 template <typename Images> struct images_get_views_t : public mpl::transform<Images, get_view_t<mpl::_1> > {};
Chris@16 37
Chris@16 38 template <typename T> struct get_const_view_t { typedef typename T::const_view_t type; };
Chris@16 39 template <typename Images> struct images_get_const_views_t : public mpl::transform<Images, get_const_view_t<mpl::_1> > {};
Chris@16 40
Chris@16 41 struct recreate_image_fnobj {
Chris@16 42 typedef void result_type;
Chris@16 43 const point2<std::ptrdiff_t>& _dimensions;
Chris@16 44 unsigned _alignment;
Chris@16 45
Chris@16 46 recreate_image_fnobj(const point2<std::ptrdiff_t>& dims, unsigned alignment) : _dimensions(dims), _alignment(alignment) {}
Chris@16 47 template <typename Image> result_type operator()(Image& img) const { img.recreate(_dimensions,_alignment); }
Chris@16 48 };
Chris@16 49
Chris@16 50 template <typename AnyView> // Models AnyViewConcept
Chris@16 51 struct any_image_get_view {
Chris@16 52 typedef AnyView result_type;
Chris@16 53 template <typename Image> result_type operator()( Image& img) const { return result_type(view(img)); }
Chris@16 54 };
Chris@16 55
Chris@16 56 template <typename AnyConstView> // Models AnyConstViewConcept
Chris@16 57 struct any_image_get_const_view {
Chris@16 58 typedef AnyConstView result_type;
Chris@16 59 template <typename Image> result_type operator()(const Image& img) const { return result_type(const_view(img)); }
Chris@16 60 };
Chris@16 61 }
Chris@16 62
Chris@16 63 ////////////////////////////////////////////////////////////////////////////////////////
Chris@16 64 /// \ingroup ImageModel
Chris@16 65 /// \brief Represents a run-time specified image. Note it does NOT model ImageConcept
Chris@16 66 ///
Chris@16 67 /// Represents an image whose type (color space, layout, planar/interleaved organization, etc) can be specified at run time.
Chris@16 68 /// It is the runtime equivalent of \p image.
Chris@16 69 /// Some of the requirements of ImageConcept, such as the \p value_type typedef cannot be fulfilled, since the language does not allow runtime type specification.
Chris@16 70 /// Other requirements, such as access to the pixels, would be inefficient to provide. Thus \p any_image does not fully model ImageConcept.
Chris@16 71 /// In particular, its \p view and \p const_view methods return \p any_image_view, which does not fully model ImageViewConcept. See \p any_image_view for more.
Chris@16 72 ////////////////////////////////////////////////////////////////////////////////////////
Chris@16 73 template <typename ImageTypes>
Chris@16 74 class any_image : public variant<ImageTypes> {
Chris@16 75 typedef variant<ImageTypes> parent_t;
Chris@16 76 public:
Chris@16 77 typedef any_image_view<typename detail::images_get_const_views_t<ImageTypes>::type> const_view_t;
Chris@16 78 typedef any_image_view<typename detail::images_get_views_t<ImageTypes>::type> view_t;
Chris@16 79 typedef std::ptrdiff_t x_coord_t;
Chris@16 80 typedef std::ptrdiff_t y_coord_t;
Chris@16 81 typedef point2<std::ptrdiff_t> point_t;
Chris@16 82
Chris@16 83 any_image() : parent_t() {}
Chris@16 84 template <typename T> explicit any_image(const T& obj) : parent_t(obj) {}
Chris@16 85 template <typename T> explicit any_image(T& obj, bool do_swap) : parent_t(obj,do_swap) {}
Chris@16 86 any_image(const any_image& v) : parent_t((const parent_t&)v) {}
Chris@16 87
Chris@16 88 template <typename T> any_image& operator=(const T& obj) { parent_t::operator=(obj); return *this; }
Chris@16 89 any_image& operator=(const any_image& v) { parent_t::operator=((const parent_t&)v); return *this;}
Chris@16 90
Chris@16 91 void recreate(const point_t& dims, unsigned alignment=1) { apply_operation(*this,detail::recreate_image_fnobj(dims,alignment)); }
Chris@16 92 void recreate(x_coord_t width, y_coord_t height, unsigned alignment=1) { recreate(point2<std::ptrdiff_t>(width,height),alignment); }
Chris@16 93
Chris@16 94 std::size_t num_channels() const { return apply_operation(*this, detail::any_type_get_num_channels()); }
Chris@16 95 point_t dimensions() const { return apply_operation(*this, detail::any_type_get_dimensions()); }
Chris@16 96 x_coord_t width() const { return dimensions().x; }
Chris@16 97 y_coord_t height() const { return dimensions().y; }
Chris@16 98 };
Chris@16 99
Chris@16 100 ///@{
Chris@16 101 /// \name view, const_view
Chris@16 102 /// \brief Get an image view from a run-time instantiated image
Chris@16 103
Chris@16 104 /// \ingroup ImageModel
Chris@16 105
Chris@16 106 /// \brief Returns the non-constant-pixel view of any image. The returned view is any view.
Chris@16 107 template <typename Types> GIL_FORCEINLINE // Models ImageVectorConcept
Chris@16 108 typename any_image<Types>::view_t view(any_image<Types>& anyImage) {
Chris@16 109 return apply_operation(anyImage, detail::any_image_get_view<typename any_image<Types>::view_t>());
Chris@16 110 }
Chris@16 111
Chris@16 112 /// \brief Returns the constant-pixel view of any image. The returned view is any view.
Chris@16 113 template <typename Types> GIL_FORCEINLINE // Models ImageVectorConcept
Chris@16 114 typename any_image<Types>::const_view_t const_view(const any_image<Types>& anyImage) {
Chris@16 115 return apply_operation(anyImage, detail::any_image_get_const_view<typename any_image<Types>::const_view_t>());
Chris@16 116 }
Chris@16 117 ///@}
Chris@16 118
Chris@16 119 } } // namespace boost::gil
Chris@16 120
Chris@16 121 //#ifdef _MSC_VER
Chris@16 122 //#pragma warning(pop)
Chris@16 123 //#endif
Chris@16 124
Chris@16 125 #endif