extension/dynamic_image/image_view_factory.hpp

Go to the documentation of this file.
00001 /*
00002     Copyright 2005-2007 Adobe Systems Incorporated
00003    
00004     Use, modification and distribution are subject to the Boost Software License,
00005     Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
00006     http://www.boost.org/LICENSE_1_0.txt).
00007 
00008     See http://opensource.adobe.com/gil for most recent version including documentation.
00009 */
00010 
00011 /*************************************************************************************************/
00012 
00013 #ifndef GIL_DYNAMICIMAGE_IMAGE_VIEWS_HPP
00014 #define GIL_DYNAMICIMAGE_IMAGE_VIEWS_HPP
00015 
00023 
00025 #include "any_image_view.hpp"
00026 #include "../../image_view_factory.hpp"
00027 
00028 namespace boost { namespace gil {
00029 
00030 namespace detail {
00031 template <typename Result> struct flipped_up_down_view_fn {
00032     typedef Result result_type;
00033     template <typename View> result_type operator()(const View& src) const { return result_type(flipped_up_down_view(src)); }
00034 };
00035 template <typename Result> struct flipped_left_right_view_fn {
00036     typedef Result result_type;
00037     template <typename View> result_type operator()(const View& src) const { return result_type(flipped_left_right_view(src)); }
00038 };
00039 template <typename Result> struct rotated90cw_view_fn {
00040     typedef Result result_type;
00041     template <typename View> result_type operator()(const View& src) const { return result_type(rotated90cw_view(src)); }
00042 };
00043 template <typename Result> struct rotated90ccw_view_fn {
00044     typedef Result result_type;
00045     template <typename View> result_type operator()(const View& src) const { return result_type(rotated90ccw_view(src)); }
00046 };
00047 template <typename Result> struct tranposed_view_fn {
00048     typedef Result result_type;
00049     template <typename View> result_type operator()(const View& src) const { return result_type(tranposed_view(src)); }
00050 };
00051 template <typename Result> struct rotated180_view_fn {
00052     typedef Result result_type;
00053     template <typename View> result_type operator()(const View& src) const { return result_type(rotated180_view(src)); }
00054 };
00055 template <typename Result> struct subimage_view_fn {
00056     typedef Result result_type;
00057     subimage_view_fn(const point2<std::ptrdiff_t>& topleft, const point2<std::ptrdiff_t>& dimensions) : _topleft(topleft), _size2(dimensions) {}
00058     point2<std::ptrdiff_t> _topleft,_size2;
00059     template <typename View> result_type operator()(const View& src) const { return result_type(subimage_view(src,_topleft,_size2)); }
00060 };
00061 template <typename Result> struct subsampled_view_fn {
00062     typedef Result result_type;
00063     subsampled_view_fn(const point2<std::ptrdiff_t>& step) : _step(step) {}
00064     point2<std::ptrdiff_t> _step;
00065     template <typename View> result_type operator()(const View& src) const { return result_type(subsampled_view(src,_step)); }
00066 };
00067 template <typename Result> struct nth_channel_view_fn {
00068     typedef Result result_type;
00069     nth_channel_view_fn(int n) : _n(n) {}
00070     int _n;
00071     template <typename View> result_type operator()(const View& src) const { return result_type(nth_channel_view(src,_n)); }
00072 };
00073 template <typename DstP, typename Result> struct color_converted_view_fn {
00074     typedef Result result_type;
00075     template <typename View> result_type operator()(const View& src) const { return result_type(color_converted_view<DstP>(src)); }
00076 };
00077 } // namespace detail
00078 
00079 
00081 template <typename ViewTypes> inline // Models MPL Random Access Container of models of ImageViewConcept
00082 typename dynamic_y_step_type<any_image_view<ViewTypes> >::type flipped_up_down_view(const any_image_view<ViewTypes>& src) { 
00083     return apply_operation(src,detail::flipped_up_down_view_fn<typename dynamic_y_step_type<any_image_view<ViewTypes> >::type>()); 
00084 }
00085 
00087 template <typename ViewTypes> inline // Models MPL Random Access Container of models of ImageViewConcept
00088 typename dynamic_x_step_type<any_image_view<ViewTypes> >::type flipped_left_right_view(const any_image_view<ViewTypes>& src) { 
00089     return apply_operation(src,detail::flipped_left_right_view_fn<typename dynamic_x_step_type<any_image_view<ViewTypes> >::type>()); 
00090 }
00091 
00093 template <typename ViewTypes> inline // Models MPL Random Access Container of models of ImageViewConcept
00094 typename dynamic_xy_step_transposed_type<any_image_view<ViewTypes> >::type transposed_view(const any_image_view<ViewTypes>& src) { 
00095     return apply_operation(src,detail::tranposed_view_fn<typename dynamic_xy_step_transposed_type<any_image_view<ViewTypes> >::type>()); 
00096 }
00097 
00099 template <typename ViewTypes> inline // Models MPL Random Access Container of models of ImageViewConcept
00100 typename dynamic_xy_step_transposed_type<any_image_view<ViewTypes> >::type rotated90cw_view(const any_image_view<ViewTypes>& src) { 
00101     return apply_operation(src,detail::rotated90cw_view_fn<typename dynamic_xy_step_transposed_type<any_image_view<ViewTypes> >::type>()); 
00102 }
00103 
00105 template <typename ViewTypes> inline // Models MPL Random Access Container of models of ImageViewConcept
00106 typename dynamic_xy_step_transposed_type<any_image_view<ViewTypes> >::type rotated90ccw_view(const any_image_view<ViewTypes>& src) { 
00107     return apply_operation(src,detail::rotated90ccw_view_fn<typename dynamic_xy_step_transposed_type<any_image_view<ViewTypes> >::type>()); 
00108 }
00109 
00111 template <typename ViewTypes> inline // Models MPL Random Access Container of models of ImageViewConcept
00112 typename dynamic_xy_step_type<any_image_view<ViewTypes> >::type rotated180_view(const any_image_view<ViewTypes>& src) { 
00113     return apply_operation(src,detail::rotated180_view_fn<typename dynamic_xy_step_type<any_image_view<ViewTypes> >::type>()); 
00114 }
00115 
00117 template <typename ViewTypes> inline // Models MPL Random Access Container of models of ImageViewConcept
00118 any_image_view<ViewTypes> subimage_view(const any_image_view<ViewTypes>& src, const point2<std::ptrdiff_t>& topleft, const point2<std::ptrdiff_t>& dimensions) { 
00119     return apply_operation(src,detail::subimage_view_fn<any_image_view<ViewTypes> >(topleft,dimensions)); 
00120 }
00121 
00123 template <typename ViewTypes> inline // Models MPL Random Access Container of models of ImageViewConcept
00124 any_image_view<ViewTypes> subimage_view(const any_image_view<ViewTypes>& src, int xMin, int yMin, int width, int height) { 
00125     return apply_operation(src,detail::subimage_view_fn<any_image_view<ViewTypes> >(point2<std::ptrdiff_t>(xMin,yMin),point2<std::ptrdiff_t>(width,height))); 
00126 }
00127 
00129 template <typename ViewTypes> inline // Models MPL Random Access Container of models of ImageViewConcept
00130 typename dynamic_xy_step_type<any_image_view<ViewTypes> >::type subsampled_view(const any_image_view<ViewTypes>& src, const point2<std::ptrdiff_t>& step) { 
00131     return apply_operation(src,detail::subsampled_view_fn<typename dynamic_xy_step_type<any_image_view<ViewTypes> >::type>(step)); 
00132 }
00133 
00135 template <typename ViewTypes> inline // Models MPL Random Access Container of models of ImageViewConcept
00136 typename dynamic_xy_step_type<any_image_view<ViewTypes> >::type subsampled_view(const any_image_view<ViewTypes>& src, int xStep, int yStep) { 
00137     return apply_operation(src,detail::subsampled_view_fn<typename dynamic_xy_step_type<any_image_view<ViewTypes> >::type>(point2<std::ptrdiff_t>(xStep,yStep))); 
00138 }
00139 
00140 namespace detail {
00141     template <typename View> struct get_nthchannel_type { typedef typename nth_channel_view_type<View>::type type; };
00142     template <typename Views> struct views_get_nthchannel_type : public mpl::transform<Views, get_nthchannel_type<mpl::_1> > {};
00143 }
00144 
00147 template <typename ViewTypes>
00148 struct nth_channel_view_type<any_image_view<ViewTypes> > {
00149     typedef any_image_view<typename detail::views_get_nthchannel_type<ViewTypes>::type> type;
00150 };
00151 
00153 template <typename ViewTypes> inline // Models MPL Random Access Container of models of ImageViewConcept
00154 typename nth_channel_view_type<any_image_view<ViewTypes> >::type nth_channel_view(const any_image_view<ViewTypes>& src, int n) { 
00155     return apply_operation(src,detail::nth_channel_view_fn<typename nth_channel_view_type<any_image_view<ViewTypes> >::type>(n)); 
00156 }
00157 
00158 namespace detail {
00159     template <typename View, typename DstP, typename CC> struct get_ccv_type : public color_converted_view_type<View, DstP, CC> {};
00160     template <typename Views, typename DstP, typename CC> struct views_get_ccv_type : public mpl::transform<Views, get_ccv_type<mpl::_1,DstP,CC> > {};
00161 }
00162 
00165 template <typename ViewTypes, typename DstP, typename CC>
00166 struct color_converted_view_type<any_image_view<ViewTypes>,DstP,CC> {
00167     typedef any_image_view<typename detail::views_get_ccv_type<ViewTypes, DstP, CC>::type> type;
00168 };
00169 
00172 template <typename DstP, typename ViewTypes, typename CC> inline // Models MPL Random Access Container of models of ImageViewConcept
00173 typename color_converted_view_type<any_image_view<ViewTypes>, DstP, CC>::type color_converted_view(const any_image_view<ViewTypes>& src,CC cc) { 
00174     return apply_operation(src,detail::color_converted_view_fn<DstP,typename color_converted_view_type<any_image_view<ViewTypes>, DstP, CC>::type >()); 
00175 }
00176 
00179 template <typename ViewTypes, typename DstP>
00180 struct color_converted_view_type<any_image_view<ViewTypes>,DstP> {
00181     typedef any_image_view<typename detail::views_get_ccv_type<ViewTypes, DstP, default_color_converter>::type> type;
00182 };
00183 
00186 template <typename DstP, typename ViewTypes> inline // Models MPL Random Access Container of models of ImageViewConcept
00187 typename color_converted_view_type<any_image_view<ViewTypes>, DstP>::type color_converted_view(const any_image_view<ViewTypes>& src) { 
00188     return apply_operation(src,detail::color_converted_view_fn<DstP,typename color_converted_view_type<any_image_view<ViewTypes>, DstP>::type >()); 
00189 }
00190 
00191 
00195 template <typename DstP, typename ViewTypes, typename CC> inline // Models MPL Random Access Container of models of ImageViewConcept
00196 typename color_converted_view_type<any_image_view<ViewTypes>, DstP, CC>::type any_color_converted_view(const any_image_view<ViewTypes>& src,CC cc) { 
00197     return apply_operation(src,detail::color_converted_view_fn<DstP,typename color_converted_view_type<any_image_view<ViewTypes>, DstP, CC>::type >()); 
00198 }
00199 
00203 template <typename DstP, typename ViewTypes> inline // Models MPL Random Access Container of models of ImageViewConcept
00204 typename color_converted_view_type<any_image_view<ViewTypes>, DstP>::type any_color_converted_view(const any_image_view<ViewTypes>& src) { 
00205     return apply_operation(src,detail::color_converted_view_fn<DstP,typename color_converted_view_type<any_image_view<ViewTypes>, DstP>::type >()); 
00206 }
00207 
00209 
00210 } }  // namespace boost::gil
00211 
00212 #endif

Copyright © 2006-2007 Adobe Systems Incorporated.

Use of this website signifies your agreement to the Terms of Use and Online Privacy Policy.

Search powered by Google