00001
00002
00003
00004
00005
00006
00007
00008
00009 #ifndef GIL_DYNAMICIMAGE_ALGORITHM_HPP
00010 #define GIL_DYNAMICIMAGE_ALGORITHM_HPP
00011
00012 #include "../../core/algorithm.hpp"
00013 #include "any_image.hpp"
00014
00023
00024 ADOBE_GIL_NAMESPACE_BEGIN
00025
00026 namespace detail {
00027 struct copy_pixels_fn : public binary_operation_obj<copy_pixels_fn> {
00028 template <typename V1, typename V2>
00029 GIL_FORCEINLINE void apply_compatible(const V1& src, const V2& dst) const {
00030 copy_pixels(src,dst);
00031 }
00032 };
00033 }
00034
00037 template <typename TYPES1,
00038 typename V2>
00039 void copy_pixels(const any_image_view<TYPES1>& src, const V2& dst) {
00040 apply_operation(src,boost::bind(GIL::detail::copy_pixels_fn(), _1, dst));
00041 }
00042
00045 template <typename V1,
00046 typename TYPES2>
00047 void copy_pixels(const V1& src, const any_image_view<TYPES2>& dst) {
00048 apply_operation(dst,boost::bind(GIL::detail::copy_pixels_fn(), src, _2));
00049 }
00050
00053 template <typename TYPES1,
00054 typename TYPES2>
00055 void copy_pixels(const any_image_view<TYPES1>& src, const any_image_view<TYPES2>& dst) {
00056 apply_operation(src,dst,detail::copy_pixels_fn());
00057 }
00058
00059
00060
00061
00063 template <typename TYPES1,
00064 typename V2>
00065 void copy_and_convert_pixels(const any_image_view<TYPES1>& src, const V2& dst) {
00066 apply_operation(src,boost::bind(detail::copy_and_convert_pixels_fn(), _1, dst));
00067 }
00068
00070 template <typename V1,
00071 typename TYPES2>
00072 void copy_and_convert_pixels(const V1& src, const any_image_view<TYPES2>& dst) {
00073 apply_operation(dst,boost::bind(detail::copy_and_convert_pixels_fn(), src, _2));
00074 }
00075
00077 template <typename TYPES1,
00078 typename TYPES2>
00079 void copy_and_convert_pixels(const any_image_view<TYPES1>& src, const any_image_view<TYPES2>& dst) {
00080 apply_operation(src,dst,detail::copy_and_convert_pixels_fn());
00081 }
00082
00083
00084 namespace detail {
00085 template <bool COMPATIBLE> struct fill_pixels_fn1 {
00086 template <typename V, typename VAL> static void apply(const V& src, const VAL& val) { fill_pixels(src,val); }
00087 };
00088
00089
00090 template <> struct fill_pixels_fn1<false> {
00091 template <typename V, typename VAL> static void apply(const V& src, const VAL& val) { throw std::bad_cast();}
00092 };
00093
00094 template <typename VAL>
00095 struct fill_pixels_fn {
00096 fill_pixels_fn(const VAL& val) : _val(val) {}
00097
00098 typedef void result_type;
00099 template <typename V> result_type operator()(const V& img_view) const {
00100 fill_pixels_fn1<pixels_are_compatible<typename V::value_type, VAL>::value>::apply(img_view,_val);
00101 }
00102 VAL _val;
00103 };
00104 }
00105
00108 template <typename TYPES,
00109 typename VAL>
00110 void fill_pixels(const any_image_view<TYPES>& img_view, const VAL& val) {
00111 apply_operation(img_view,GIL::detail::fill_pixels_fn<VAL>(val));
00112 }
00113
00114
00115 ADOBE_GIL_NAMESPACE_END
00116
00117 #endif