8 #ifndef BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_ANY_IMAGE_HPP 9 #define BOOST_GIL_EXTENSION_DYNAMIC_IMAGE_ANY_IMAGE_HPP 11 #include <boost/gil/extension/dynamic_image/any_image_view.hpp> 12 #include <boost/gil/extension/dynamic_image/apply_operation.hpp> 14 #include <boost/gil/image.hpp> 16 #include <boost/config.hpp> 18 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) 20 #pragma warning(disable:4512) //assignment operator could not be generated 23 namespace boost {
namespace gil {
26 template <
typename T>
struct get_view_t {
using type =
typename T::view_t; };
27 template <
typename Images>
struct images_get_views_t :
public mpl::transform<Images, get_view_t<mpl::_1> > {};
29 template <
typename T>
struct get_const_view_t {
using type =
typename T::const_view_t; };
30 template <
typename Images>
struct images_get_const_views_t :
public mpl::transform<Images, get_const_view_t<mpl::_1> > {};
32 struct recreate_image_fnobj
34 using result_type = void;
35 point<std::ptrdiff_t>
const& _dimensions;
38 recreate_image_fnobj(point<std::ptrdiff_t>
const& dims,
unsigned alignment) : _dimensions(dims), _alignment(alignment) {}
39 template <
typename Image>
40 result_type operator()(Image& img)
const { img.recreate(_dimensions,_alignment); }
43 template <
typename AnyView>
44 struct any_image_get_view {
45 using result_type = AnyView;
46 template <
typename Image> result_type operator()( Image& img)
const {
return result_type(
view(img)); }
49 template <
typename AnyConstView>
50 struct any_image_get_const_view {
51 using result_type = AnyConstView;
52 template <
typename Image> result_type operator()(
const Image& img)
const {
return result_type(
const_view(img)); }
66 template <
typename ImageTypes>
67 class any_image :
public make_variant_over<ImageTypes>::type {
68 using parent_t =
typename make_variant_over<ImageTypes>::type;
72 using x_coord_t = std::ptrdiff_t;
73 using y_coord_t = std::ptrdiff_t;
77 template <
typename T>
explicit any_image(
const T& obj) : parent_t(obj) {}
78 template <
typename T>
explicit any_image(T& obj,
bool do_swap) : parent_t(obj,do_swap) {}
80 template <
typename Types>
any_image(
const any_image<Types>& v) : parent_t((
const typename make_variant_over<Types>::type&)v) {}
82 template <
typename T>
any_image& operator=(
const T& obj) { parent_t::operator=(obj);
return *
this; }
83 any_image& operator=(
const any_image& v) { parent_t::operator=((
const parent_t&)v);
return *
this;}
84 template <
typename Types>
any_image& operator=(
const any_image<Types>& v) { parent_t::operator=((
const typename make_variant_over<Types>::type&)v);
return *
this;}
86 void recreate(
const point_t& dims,
unsigned alignment=1)
91 void recreate(x_coord_t width, y_coord_t height,
unsigned alignment=1)
93 recreate({width, height}, alignment);
98 x_coord_t width()
const {
return dimensions().x; }
99 y_coord_t height()
const {
return dimensions().y; }
109 template <
typename Types> BOOST_FORCEINLINE
115 template <
typename Types> BOOST_FORCEINLINE
123 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400) BOOST_FORCEINLINE any_image< Types >::const_view_t const_view(const any_image< Types > &anyImage)
Returns the constant-pixel view of any image. The returned view is any view.
Definition: any_image.hpp:116
Definition: algorithm.hpp:30
Represents a run-time specified image. Note it does NOT model ImageConcept.
Definition: any_image.hpp:67
BOOST_FORCEINLINE auto apply_operation(variant< Types > &arg, UnaryOp op)
Invokes a generic mutable operation (represented as a unary function object) on a variant...
Definition: apply_operation.hpp:31
Represents a run-time specified image view. Models HasDynamicXStepTypeConcept, HasDynamicYStepTypeCon...
Definition: any_image_view.hpp:61
BOOST_FORCEINLINE any_image< Types >::view_t view(any_image< Types > &anyImage)
Returns the non-constant-pixel view of any image. The returned view is any view.
Definition: any_image.hpp:110
Returns the number of channels of a pixel-based GIL construct.
Definition: locator.hpp:38