9 #ifndef BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_ANY_IMAGE_HPP    10 #define BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_ANY_IMAGE_HPP    12 #include <boost/gil/extension/dynamic_image/any_image_view.hpp>    13 #include <boost/gil/extension/dynamic_image/apply_operation.hpp>    15 #include <boost/gil/image.hpp>    16 #include <boost/gil/detail/mp11.hpp>    18 #include <boost/config.hpp>    19 #include <boost/variant2/variant.hpp>    21 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)    23 #pragma warning(disable:4512) //assignment operator could not be generated    26 namespace boost { 
namespace gil {
    31 using get_view_t = 
typename T::view_t;
    33 template <
typename Images>
    34 using images_get_views_t = mp11::mp_transform<get_view_t, Images>;
    37 using get_const_view_t = 
typename T::const_view_t;
    39 template <
typename Images>
    40 using images_get_const_views_t = mp11::mp_transform<get_const_view_t, Images>;
    42 struct recreate_image_fnobj
    44     using result_type = void;
    45     point<std::ptrdiff_t> 
const& _dimensions;
    48     recreate_image_fnobj(point<std::ptrdiff_t> 
const& dims, 
unsigned alignment)
    49         : _dimensions(dims), _alignment(alignment)
    52     template <
typename Image>
    53     result_type operator()(Image& img)
 const { img.recreate(_dimensions,_alignment); }
    56 template <
typename AnyView>  
    57 struct any_image_get_view
    59     using result_type = AnyView;
    60     template <
typename Image>
    61     result_type operator()(Image& img)
 const    63         return result_type(
view(img));
    67 template <
typename AnyConstView>  
    68 struct any_image_get_const_view
    70     using result_type = AnyConstView;
    71     template <
typename Image>
    72     result_type operator()(Image 
const& img)
 const { 
return result_type{
const_view(img)}; }
    88 template <
typename ...Images>
    89 class any_image : 
public variant2::variant<Images...>
    91     using parent_t = variant2::variant<Images...>;
    93     using view_t = mp11::mp_rename<detail::images_get_views_t<any_image>, 
any_image_view>;
    94     using const_view_t = mp11::mp_rename<detail::images_get_const_views_t<any_image>, 
any_image_view>;
    95     using x_coord_t = std::ptrdiff_t;
    96     using y_coord_t = std::ptrdiff_t;
   102     template <
typename Image>
   103     explicit any_image(Image 
const& img) : parent_t(img) {}
   105     template <
typename Image>
   106     any_image(Image&& img) : parent_t(std::move(img)) {}
   108     template <
typename Image>
   109     explicit any_image(Image& img, 
bool do_swap) : parent_t(img, do_swap) {}
   111     template <
typename ...OtherImages>
   113         : parent_t((variant2::variant<OtherImages...> 
const&)img)
   118         parent_t::operator=((parent_t 
const&)img);
   122     template <
typename Image>
   125         parent_t::operator=(img);
   129     template <
typename ...OtherImages>
   132             parent_t::operator=((
typename variant2::variant<OtherImages...> 
const&)img);
   136     void recreate(
const point_t& dims, 
unsigned alignment=1)
   141     void recreate(x_coord_t width, y_coord_t height, 
unsigned alignment=1)
   143         recreate({ width, height }, alignment);
   156     x_coord_t width()
  const { 
return dimensions().x; }
   157     y_coord_t height()
 const { 
return dimensions().y; }
   168 template <
typename ...Images>
   172     using view_t = 
typename any_image<Images...>::view_t;
   178 template <
typename ...Images>
   182     using view_t = 
typename any_image<Images...>::const_view_t;
   183     return apply_operation(img, detail::any_image_get_const_view<view_t>());
   189 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) BOOST_FORCEINLINE auto apply_operation(Variant1 &&arg1, Visitor &&op)
Applies the visitor op to the variants.
Definition: apply_operation.hpp:19
Represents a run-time specified image. Note it does NOT model ImageConcept.
Definition: any_image.hpp:89
BOOST_FORCEINLINE auto view(any_image< Images... > &img) -> typename any_image< Images... >::view_t
Returns the non-constant-pixel view of any image. The returned view is any view.
Definition: any_image.hpp:170
Represents a run-time specified image view. Models HasDynamicXStepTypeConcept, HasDynamicYStepTypeCon...
Definition: any_image_view.hpp:74
Returns the number of channels of a pixel-based GIL construct.
Definition: locator.hpp:38
BOOST_FORCEINLINE auto const_view(any_image< Images... > const &img) -> typename any_image< Images... >::const_view_t
Returns the constant-pixel view of any image. The returned view is any view.
Definition: any_image.hpp:180