00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef GIL_DYNAMICIMAGE_IMAGE_VIEWS_HPP
00010 #define GIL_DYNAMICIMAGE_IMAGE_VIEWS_HPP
00011
00019
00021 #include "../../core/image_view_factory.hpp"
00022
00023 ADOBE_GIL_NAMESPACE_BEGIN
00024
00025 namespace detail {
00026 template <typename RESULT> struct flipped_up_down_view_fn {
00027 typedef RESULT result_type;
00028 template <typename VIEW> result_type operator()(const VIEW& src) const { return result_type(flipped_up_down_view(src)); }
00029 };
00030 template <typename RESULT> struct flipped_left_right_view_fn {
00031 typedef RESULT result_type;
00032 template <typename VIEW> result_type operator()(const VIEW& src) const { return result_type(flipped_left_right_view(src)); }
00033 };
00034 template <typename RESULT> struct rotated90cw_view_fn {
00035 typedef RESULT result_type;
00036 template <typename VIEW> result_type operator()(const VIEW& src) const { return result_type(rotated90cw_view(src)); }
00037 };
00038 template <typename RESULT> struct rotated90ccw_view_fn {
00039 typedef RESULT result_type;
00040 template <typename VIEW> result_type operator()(const VIEW& src) const { return result_type(rotated90ccw_view(src)); }
00041 };
00042 template <typename RESULT> struct tranposed_view_fn {
00043 typedef RESULT result_type;
00044 template <typename VIEW> result_type operator()(const VIEW& src) const { return result_type(tranposed_view(src)); }
00045 };
00046 template <typename RESULT> struct rotated180_view_fn {
00047 typedef RESULT result_type;
00048 template <typename VIEW> result_type operator()(const VIEW& src) const { return result_type(rotated180_view(src)); }
00049 };
00050 template <typename RESULT> struct subimage_view_fn {
00051 typedef RESULT result_type;
00052 subimage_view_fn(const point2<std::ptrdiff_t>& topleft, const point2<std::ptrdiff_t>& dimensions) : _topleft(topleft), _size2(dimensions) {}
00053 point2<std::ptrdiff_t> _topleft,_size2;
00054 template <typename VIEW> result_type operator()(const VIEW& src) const { return result_type(subimage_view(src,_topleft,_size2)); }
00055 };
00056 template <typename RESULT> struct subsampled_view_fn {
00057 typedef RESULT result_type;
00058 subsampled_view_fn(const point2<std::ptrdiff_t>& step) : _step(step) {}
00059 point2<std::ptrdiff_t> _step;
00060 template <typename VIEW> result_type operator()(const VIEW& src) const { return result_type(subsampled_view(src,_step)); }
00061 };
00062 template <typename RESULT> struct nth_channel_view_fn {
00063 typedef RESULT result_type;
00064 nth_channel_view_fn(int n) : _n(n) {}
00065 int _n;
00066 template <typename VIEW> result_type operator()(const VIEW& src) const { return result_type(nth_channel_view(src,_n)); }
00067 };
00068 template <typename DST_P, typename RESULT> struct color_converted_view_fn {
00069 typedef RESULT result_type;
00070 template <typename VIEW> result_type operator()(const VIEW& src) const { return result_type(color_converted_view<DST_P>(src)); }
00071 };
00072 };
00073
00077
00079 template <typename VTYPES> inline
00080 any_image_view<VTYPES> flipped_up_down_view(const any_image_view<VTYPES>& src) {
00081 return apply_operation(src,detail::flipped_up_down_view_fn<any_image_view<VTYPES> >());
00082 }
00083
00085 template <typename VTYPES> inline
00086 typename any_image_view<VTYPES>::dynamic_step_t flipped_left_right_view(const any_image_view<VTYPES>& src) {
00087 return apply_operation(src,detail::flipped_left_right_view_fn<typename any_image_view<VTYPES>::dynamic_step_t>());
00088 }
00089
00091 template <typename VTYPES> inline
00092 typename any_image_view<VTYPES>::dynamic_step_t tranposed_view(const any_image_view<VTYPES>& src) {
00093 return apply_operation(src,detail::tranposed_view_fn<typename any_image_view<VTYPES>::dynamic_step_t>());
00094 }
00095
00097 template <typename VTYPES> inline
00098 typename any_image_view<VTYPES>::dynamic_step_t rotated90cw_view(const any_image_view<VTYPES>& src) {
00099 return apply_operation(src,detail::rotated90cw_view_fn<typename any_image_view<VTYPES>::dynamic_step_t>());
00100 }
00101
00102 template <typename VTYPES> inline
00103 typename any_image_view<VTYPES>::dynamic_step_t rotated90ccw_view(const any_image_view<VTYPES>& src) {
00104 return apply_operation(src,detail::rotated90ccw_view_fn<typename any_image_view<VTYPES>::dynamic_step_t>());
00105 }
00106
00107 template <typename VTYPES> inline
00108 typename any_image_view<VTYPES>::dynamic_step_t rotated180_view(const any_image_view<VTYPES>& src) {
00109 return apply_operation(src,detail::rotated180_view_fn<typename any_image_view<VTYPES>::dynamic_step_t>());
00110 }
00111
00112 template <typename VTYPES> inline
00113 any_image_view<VTYPES> subimage_view(const any_image_view<VTYPES>& src, const point2<std::ptrdiff_t>& topleft, const point2<std::ptrdiff_t>& dimensions) {
00114 return apply_operation(src,detail::subimage_view_fn<any_image_view<VTYPES> >(topleft,dimensions));
00115 }
00116
00117 template <typename VTYPES> inline
00118 any_image_view<VTYPES> subimage_view(const any_image_view<VTYPES>& src, int xMin, int yMin, int width, int height) {
00119 return apply_operation(src,detail::subimage_view_fn<any_image_view<VTYPES> >(point2<std::ptrdiff_t>(xMin,yMin),point2<std::ptrdiff_t>(width,height)));
00120 }
00121
00122 template <typename VTYPES> inline
00123 typename any_image_view<VTYPES>::dynamic_step_t subsampled_view(const any_image_view<VTYPES>& src, const point2<std::ptrdiff_t>& step) {
00124 return apply_operation(src,detail::subsampled_view_fn<typename any_image_view<VTYPES>::dynamic_step_t>(step));
00125 }
00126
00127 template <typename VTYPES> inline
00128 typename any_image_view<VTYPES>::dynamic_step_t subsampled_view(const any_image_view<VTYPES>& src, int xStep, int yStep) {
00129 return apply_operation(src,detail::subsampled_view_fn<typename any_image_view<VTYPES>::dynamic_step_t>(point2<std::ptrdiff_t>(xStep,yStep)));
00130 }
00131
00132 template <typename VTYPES>
00133 struct nth_channel_view_type<any_image_view<VTYPES> > {
00134 private:
00135 struct get_nthchannel_type {
00136 template <typename V> struct apply { typedef typename nth_channel_view_type<V>::type type; };
00137 };
00138 public:
00139 typedef any_image_view<typename boost::mpl::transform<VTYPES, get_nthchannel_type>::type> type;
00140 };
00141
00142 template <typename VTYPES> inline
00143 typename nth_channel_view_type<any_image_view<VTYPES> >::type nth_channel_view(const any_image_view<VTYPES>& src, int n) {
00144 return apply_operation(src,detail::nth_channel_view_fn<typename nth_channel_view_type<any_image_view<VTYPES> >::type>(n));
00145 }
00146
00147 template <typename VTYPES, typename DST_P>
00148 struct color_convert_view_type<any_image_view<VTYPES>,DST_P> {
00149 private:
00150 struct get_ccv_type {
00151 template <typename V> struct apply { typedef typename color_convert_view_type<V, DST_P>::type type; };
00152 };
00153 public:
00154 typedef any_image_view<typename boost::mpl::transform<VTYPES, get_ccv_type>::type> type;
00155 };
00156
00157 template <typename DST_P, typename VTYPES> inline
00158 typename color_convert_view_type<any_image_view<VTYPES>, DST_P>::type any_color_converted_view(const any_image_view<VTYPES>& src) {
00159 return apply_operation(src,detail::color_converted_view_fn<DST_P,typename color_convert_view_type<any_image_view<VTYPES>, DST_P>::type >());
00160 }
00161
00163
00164 ADOBE_GIL_NAMESPACE_END
00165
00166 #endif