00001 /*00002 Copyright 2005-2007 Adobe Systems Incorporated00003 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 at00006 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_HPP00013 #define GIL_DYNAMICIMAGE_ALGORITHM_HPP00014
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 returnequal_pixels(v1,v2);
00035 }
00036 };
00037 } // namespace detail00038
00040 template <typename Types1, // Model MPL Random Access Container of models of ImageViewConcept00041 typename View2> // Model MutableImageViewConcept00042 boolequal_pixels(const any_image_view<Types1>& src, const View2& dst) {
00043 returnapply_operation(src,boost::bind(detail::equal_pixels_fn(), _1, dst));
00044 }
00045
00047 template <typename View1, // Model ImageViewConcept00048 typename Types2> // Model MPL Random Access Container of models of MutableImageViewConcept00049 boolequal_pixels(const View1& src, const any_image_view<Types2>& dst) {
00050 returnapply_operation(dst,boost::bind(detail::equal_pixels_fn(), src, _1));
00051 }
00052
00054 template <typename Types1, // Model MPL Random Access Container of models of ImageViewConcept00055 typename Types2> // Model MPL Random Access Container of models of MutableImageViewConcept00056 boolequal_pixels(const any_image_view<Types1>& src, const any_image_view<Types2>& dst) {
00057 returnapply_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 ImageViewConcept00071 typename View2> // Model MutableImageViewConcept00072 voidcopy_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 ImageViewConcept00078 typename Types2> // Model MPL Random Access Container of models of MutableImageViewConcept00079 voidcopy_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 ImageViewConcept00085 typename Types2> // Model MPL Random Access Container of models of MutableImageViewConcept00086 voidcopy_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 ImageViewConcept00097 typename View2, // Model MutableImageViewConcept00098 typename CC> // Model ColorConverterConcept00099 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 ImageViewConcept00105 typename View2> // Model MutableImageViewConcept00106 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 ImageViewConcept00112 typename Types2, // Model MPL Random Access Container of models of MutableImageViewConcept00113 typename CC> // Model ColorConverterConcept00114 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 ImageViewConcept00120 typename Types2> // Model MPL Random Access Container of models of MutableImageViewConcept00121 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 ImageViewConcept00127 typename Types2, // Model MPL Random Access Container of models of MutableImageViewConcept00128 typename CC> // Model ColorConverterConcept00129 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 ImageViewConcept00135 typename Types2> // Model MPL Random Access Container of models of MutableImageViewConcept00136 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> staticvoid apply(const V& src, const Value& val) { fill_pixels(src,val); }
00143 };
00144
00145 // copy_pixels invoked on incompatible images00146 template <> struct fill_pixels_fn1<false> {
00147 template <typename V, typename Value> staticvoid 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 typedefvoid 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 MutableImageViewConcept00165 typename Value>
00166voidfill_pixels(constany_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::gil00172
00173 #endif
Generated on Sat May 2 13:50:13 2009 for Generic Image Library by
1.5.6
Статья Generic Image Library: algorithm.hpp Source File раздела может быть полезна для разработчиков на c++ и boost.
Материалы статей собраны из открытых источников, владелец сайта не претендует на авторство. Там где авторство установить не удалось, материал подаётся без имени автора. В случае если Вы считаете, что Ваши права нарушены, пожалуйста, свяжитесь с владельцем сайта.