extension/dynamic_image/algorithm.hppGo 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 #ifndef GIL_DYNAMICIMAGE_ALGORITHM_HPP 00013 #define GIL_DYNAMICIMAGE_ALGORITHM_HPP 00014 00015 #include "../../algorithm.hpp" 00016 #include "any_image.hpp" 00017 #include <boost/bind.hpp> 00018 00027 00028 namespace boost { namespace gil { 00029 00030 namespace detail { 00031 struct equal_pixels_fn : public binary_operation_obj<equal_pixels_fn,bool> { 00032 template <typename V1, typename V2> 00033 GIL_FORCEINLINE bool apply_compatible(const V1& v1, const V2& v2) const { 00034 return equal_pixels(v1,v2); 00035 } 00036 }; 00037 } // namespace detail 00038 00040 template <typename Types1, // Model MPL Random Access Container of models of ImageViewConcept 00041 typename View2> // Model MutableImageViewConcept 00042 bool equal_pixels(const any_image_view<Types1>& src, const View2& dst) { 00043 return apply_operation(src,boost::bind(detail::equal_pixels_fn(), _1, dst)); 00044 } 00045 00047 template <typename View1, // Model ImageViewConcept 00048 typename Types2> // Model MPL Random Access Container of models of MutableImageViewConcept 00049 bool equal_pixels(const View1& src, const any_image_view<Types2>& dst) { 00050 return apply_operation(dst,boost::bind(detail::equal_pixels_fn(), src, _1)); 00051 } 00052 00054 template <typename Types1, // Model MPL Random Access Container of models of ImageViewConcept 00055 typename Types2> // Model MPL Random Access Container of models of MutableImageViewConcept 00056 bool equal_pixels(const any_image_view<Types1>& src, const any_image_view<Types2>& dst) { 00057 return apply_operation(src,dst,detail::equal_pixels_fn()); 00058 } 00059 00060 namespace detail { 00061 struct copy_pixels_fn : public binary_operation_obj<copy_pixels_fn> { 00062 template <typename View1, typename View2> 00063 GIL_FORCEINLINE void apply_compatible(const View1& src, const View2& dst) const { 00064 copy_pixels(src,dst); 00065 } 00066 }; 00067 } 00068 00070 template <typename Types1, // Model MPL Random Access Container of models of ImageViewConcept 00071 typename View2> // Model MutableImageViewConcept 00072 void copy_pixels(const any_image_view<Types1>& src, const View2& dst) { 00073 apply_operation(src,boost::bind(detail::copy_pixels_fn(), _1, dst)); 00074 } 00075 00077 template <typename View1, // Model ImageViewConcept 00078 typename Types2> // Model MPL Random Access Container of models of MutableImageViewConcept 00079 void copy_pixels(const View1& src, const any_image_view<Types2>& dst) { 00080 apply_operation(dst,boost::bind(detail::copy_pixels_fn(), src, _1)); 00081 } 00082 00084 template <typename Types1, // Model MPL Random Access Container of models of ImageViewConcept 00085 typename Types2> // Model MPL Random Access Container of models of MutableImageViewConcept 00086 void copy_pixels(const any_image_view<Types1>& src, const any_image_view<Types2>& dst) { 00087 apply_operation(src,dst,detail::copy_pixels_fn()); 00088 } 00089 00090 00091 00092 //forward declaration for default_color_converter (see full definition in color_convert.hpp) 00093 struct default_color_converter; 00094 00096 template <typename Types1, // Model MPL Random Access Container of models of ImageViewConcept 00097 typename View2, // Model MutableImageViewConcept 00098 typename CC> // Model ColorConverterConcept 00099 void copy_and_convert_pixels(const any_image_view<Types1>& src, const View2& dst, CC cc) { 00100 apply_operation(src,boost::bind(detail::copy_and_convert_pixels_fn<CC>(cc), _1, dst)); 00101 } 00102 00104 template <typename Types1, // Model MPL Random Access Container of models of ImageViewConcept 00105 typename View2> // Model MutableImageViewConcept 00106 void copy_and_convert_pixels(const any_image_view<Types1>& src, const View2& dst) { 00107 apply_operation(src,boost::bind(detail::copy_and_convert_pixels_fn<default_color_converter>(), _1, dst)); 00108 } 00109 00111 template <typename View1, // Model ImageViewConcept 00112 typename Types2, // Model MPL Random Access Container of models of MutableImageViewConcept 00113 typename CC> // Model ColorConverterConcept 00114 void copy_and_convert_pixels(const View1& src, const any_image_view<Types2>& dst, CC cc) { 00115 apply_operation(dst,boost::bind(detail::copy_and_convert_pixels_fn<CC>(cc), src, _1)); 00116 } 00117 00119 template <typename View1, // Model ImageViewConcept 00120 typename Types2> // Model MPL Random Access Container of models of MutableImageViewConcept 00121 void copy_and_convert_pixels(const View1& src, const any_image_view<Types2>& dst) { 00122 apply_operation(dst,boost::bind(detail::copy_and_convert_pixels_fn<default_color_converter>(), src, _1)); 00123 } 00124 00126 template <typename Types1, // Model MPL Random Access Container of models of ImageViewConcept 00127 typename Types2, // Model MPL Random Access Container of models of MutableImageViewConcept 00128 typename CC> // Model ColorConverterConcept 00129 void copy_and_convert_pixels(const any_image_view<Types1>& src, const any_image_view<Types2>& dst, CC cc) { 00130 apply_operation(src,dst,detail::copy_and_convert_pixels_fn<CC>(cc)); 00131 } 00132 00134 template <typename Types1, // Model MPL Random Access Container of models of ImageViewConcept 00135 typename Types2> // Model MPL Random Access Container of models of MutableImageViewConcept 00136 void copy_and_convert_pixels(const any_image_view<Types1>& src, const any_image_view<Types2>& dst) { 00137 apply_operation(src,dst,detail::copy_and_convert_pixels_fn<default_color_converter>()); 00138 } 00139 00140 namespace detail { 00141 template <bool COMPATIBLE> struct fill_pixels_fn1 { 00142 template <typename V, typename Value> static void apply(const V& src, const Value& val) { fill_pixels(src,val); } 00143 }; 00144 00145 // copy_pixels invoked on incompatible images 00146 template <> struct fill_pixels_fn1<false> { 00147 template <typename V, typename Value> static void apply(const V& src, const Value& val) { throw std::bad_cast();} 00148 }; 00149 00150 template <typename Value> 00151 struct fill_pixels_fn { 00152 fill_pixels_fn(const Value& val) : _val(val) {} 00153 00154 typedef void result_type; 00155 template <typename V> result_type operator()(const V& img_view) const { 00156 fill_pixels_fn1<pixels_are_compatible<typename V::value_type, Value>::value>::apply(img_view,_val); 00157 } 00158 Value _val; 00159 }; 00160 } 00161 00164 template <typename Types, // Model MPL Random Access Container of models of MutableImageViewConcept 00165 typename Value> 00166 void fill_pixels(const any_image_view<Types>& img_view, const Value& val) { 00167 apply_operation(img_view,detail::fill_pixels_fn<Value>(val)); 00168 } 00169 00170 00171 } } // namespace boost::gil 00172 00173 #endif Generated on Sat May 2 13:50:13 2009 for Generic Image Library by 1.5.6 |