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>
13 #include <boost/gil/image.hpp>
15 #include <boost/config.hpp>
17 #if BOOST_WORKAROUND(BOOST_MSVC, >= 1400)
19 #pragma warning(disable:4512) //assignment operator could not be generated
22 namespace boost {
namespace gil {
25 template <
typename T>
struct get_view_t {
typedef typename T::view_t type; };
26 template <
typename Images>
struct images_get_views_t :
public mpl::transform<Images, get_view_t<mpl::_1> > {};
28 template <
typename T>
struct get_const_view_t {
typedef typename T::const_view_t type; };
29 template <
typename Images>
struct images_get_const_views_t :
public mpl::transform<Images, get_const_view_t<mpl::_1> > {};
31 struct recreate_image_fnobj {
32 typedef void result_type;
33 const point2<std::ptrdiff_t>& _dimensions;
36 recreate_image_fnobj(
const point2<std::ptrdiff_t>& dims,
unsigned alignment) : _dimensions(dims), _alignment(alignment) {}
37 template <
typename Image> result_type operator()(Image& img)
const { img.recreate(_dimensions,_alignment); }
40 template <
typename AnyView>
41 struct any_image_get_view {
42 typedef AnyView result_type;
43 template <
typename Image> result_type operator()( Image& img)
const {
return result_type(
view(img)); }
46 template <
typename AnyConstView>
47 struct any_image_get_const_view {
48 typedef AnyConstView result_type;
49 template <
typename Image> result_type operator()(
const Image& img)
const {
return result_type(
const_view(img)); }
63 template <
typename ImageTypes>
69 typedef std::ptrdiff_t x_coord_t;
70 typedef std::ptrdiff_t y_coord_t;
75 template <
typename T>
explicit any_image(T& obj,
bool do_swap) :
parent_t(obj,do_swap) {}
79 template <
typename T>
any_image& operator=(
const T& obj) { parent_t::operator=(obj);
return *
this; }
83 void recreate(
const point_t& dims,
unsigned alignment=1) {
apply_operation(*
this,detail::recreate_image_fnobj(dims,alignment)); }
84 void recreate(x_coord_t width, y_coord_t height,
unsigned alignment=1) { recreate(
point2<std::ptrdiff_t>(width,height),alignment); }
88 x_coord_t width()
const {
return dimensions().x; }
89 y_coord_t height()
const {
return dimensions().y; }
99 template <
typename Types> BOOST_FORCEINLINE
105 template <
typename Types> BOOST_FORCEINLINE
113 #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:106
Represents a run-time specified image. Note it does NOT model ImageConcept.
Definition: any_image.hpp:64
BOOST_FORCEINLINE UnaryOp::result_type 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 concrete instance of a run-time specified type from a set of typesA concept is typically...
Definition: variant.hpp:80
Represents a run-time specified image view. Models HasDynamicXStepTypeConcept, HasDynamicYStepTypeCon...
Definition: any_image_view.hpp:51
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:100
Returns the number of channels of a pixel-based GIL construct.
Definition: concepts.hpp:56