annotate DEPENDENCIES/generic/include/boost/gil/extension/dynamic_image/algorithm.hpp @ 133:4acb5d8d80b6 tip

Don't fail environmental check if README.md exists (but .txt and no-suffix don't)
author Chris Cannam
date Tue, 30 Jul 2019 12:25:44 +0100
parents 2665513ce2d3
children
rev   line source
Chris@16 1 /*
Chris@16 2 Copyright 2005-2007 Adobe Systems Incorporated
Chris@16 3
Chris@16 4 Use, modification and distribution are subject to the Boost Software License,
Chris@16 5 Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
Chris@16 6 http://www.boost.org/LICENSE_1_0.txt).
Chris@16 7
Chris@16 8 See http://opensource.adobe.com/gil for most recent version including documentation.
Chris@16 9 */
Chris@16 10 /*************************************************************************************************/
Chris@16 11
Chris@16 12 #ifndef GIL_DYNAMICIMAGE_ALGORITHM_HPP
Chris@16 13 #define GIL_DYNAMICIMAGE_ALGORITHM_HPP
Chris@16 14
Chris@16 15 #include "../../algorithm.hpp"
Chris@16 16 #include "any_image.hpp"
Chris@16 17 #include <boost/bind.hpp>
Chris@16 18
Chris@16 19 ////////////////////////////////////////////////////////////////////////////////////////
Chris@16 20 /// \file
Chris@16 21 /// \brief Some basic STL-style algorithms when applied to runtime type specified image views
Chris@16 22 /// \author Lubomir Bourdev and Hailin Jin \n
Chris@16 23 /// Adobe Systems Incorporated
Chris@16 24 /// \date 2005-2007 \n Last updated on September 24, 2006
Chris@16 25 ///
Chris@16 26 ////////////////////////////////////////////////////////////////////////////////////////
Chris@16 27
Chris@16 28 namespace boost { namespace gil {
Chris@16 29
Chris@16 30 namespace detail {
Chris@16 31 struct equal_pixels_fn : public binary_operation_obj<equal_pixels_fn,bool> {
Chris@16 32 template <typename V1, typename V2>
Chris@16 33 GIL_FORCEINLINE bool apply_compatible(const V1& v1, const V2& v2) const {
Chris@16 34 return equal_pixels(v1,v2);
Chris@16 35 }
Chris@16 36 };
Chris@16 37 } // namespace detail
Chris@16 38
Chris@16 39 /// \ingroup ImageViewSTLAlgorithmsEqualPixels
Chris@16 40 template <typename Types1, // Model MPL Random Access Container of models of ImageViewConcept
Chris@16 41 typename View2> // Model MutableImageViewConcept
Chris@16 42 bool equal_pixels(const any_image_view<Types1>& src, const View2& dst) {
Chris@16 43 return apply_operation(src,boost::bind(detail::equal_pixels_fn(), _1, dst));
Chris@16 44 }
Chris@16 45
Chris@16 46 /// \ingroup ImageViewSTLAlgorithmsEqualPixels
Chris@16 47 template <typename View1, // Model ImageViewConcept
Chris@16 48 typename Types2> // Model MPL Random Access Container of models of MutableImageViewConcept
Chris@16 49 bool equal_pixels(const View1& src, const any_image_view<Types2>& dst) {
Chris@16 50 return apply_operation(dst,boost::bind(detail::equal_pixels_fn(), src, _1));
Chris@16 51 }
Chris@16 52
Chris@16 53 /// \ingroup ImageViewSTLAlgorithmsEqualPixels
Chris@16 54 template <typename Types1, // Model MPL Random Access Container of models of ImageViewConcept
Chris@16 55 typename Types2> // Model MPL Random Access Container of models of MutableImageViewConcept
Chris@16 56 bool equal_pixels(const any_image_view<Types1>& src, const any_image_view<Types2>& dst) {
Chris@16 57 return apply_operation(src,dst,detail::equal_pixels_fn());
Chris@16 58 }
Chris@16 59
Chris@16 60 namespace detail {
Chris@16 61 struct copy_pixels_fn : public binary_operation_obj<copy_pixels_fn> {
Chris@16 62 template <typename View1, typename View2>
Chris@16 63 GIL_FORCEINLINE void apply_compatible(const View1& src, const View2& dst) const {
Chris@16 64 copy_pixels(src,dst);
Chris@16 65 }
Chris@16 66 };
Chris@16 67 }
Chris@16 68
Chris@16 69 /// \ingroup ImageViewSTLAlgorithmsCopyPixels
Chris@16 70 template <typename Types1, // Model MPL Random Access Container of models of ImageViewConcept
Chris@16 71 typename View2> // Model MutableImageViewConcept
Chris@16 72 void copy_pixels(const any_image_view<Types1>& src, const View2& dst) {
Chris@16 73 apply_operation(src,boost::bind(detail::copy_pixels_fn(), _1, dst));
Chris@16 74 }
Chris@16 75
Chris@16 76 /// \ingroup ImageViewSTLAlgorithmsCopyPixels
Chris@16 77 template <typename View1, // Model ImageViewConcept
Chris@16 78 typename Types2> // Model MPL Random Access Container of models of MutableImageViewConcept
Chris@16 79 void copy_pixels(const View1& src, const any_image_view<Types2>& dst) {
Chris@16 80 apply_operation(dst,boost::bind(detail::copy_pixels_fn(), src, _1));
Chris@16 81 }
Chris@16 82
Chris@16 83 /// \ingroup ImageViewSTLAlgorithmsCopyPixels
Chris@16 84 template <typename Types1, // Model MPL Random Access Container of models of ImageViewConcept
Chris@16 85 typename Types2> // Model MPL Random Access Container of models of MutableImageViewConcept
Chris@16 86 void copy_pixels(const any_image_view<Types1>& src, const any_image_view<Types2>& dst) {
Chris@16 87 apply_operation(src,dst,detail::copy_pixels_fn());
Chris@16 88 }
Chris@16 89
Chris@16 90
Chris@16 91
Chris@16 92 //forward declaration for default_color_converter (see full definition in color_convert.hpp)
Chris@16 93 struct default_color_converter;
Chris@16 94
Chris@16 95 /// \ingroup ImageViewSTLAlgorithmsCopyAndConvertPixels
Chris@16 96 template <typename Types1, // Model MPL Random Access Container of models of ImageViewConcept
Chris@16 97 typename View2, // Model MutableImageViewConcept
Chris@16 98 typename CC> // Model ColorConverterConcept
Chris@16 99 void copy_and_convert_pixels(const any_image_view<Types1>& src, const View2& dst, CC cc) {
Chris@16 100 apply_operation(src,boost::bind(detail::copy_and_convert_pixels_fn<CC>(cc), _1, dst));
Chris@16 101 }
Chris@16 102
Chris@16 103 /// \ingroup ImageViewSTLAlgorithmsCopyAndConvertPixels
Chris@16 104 template <typename Types1, // Model MPL Random Access Container of models of ImageViewConcept
Chris@16 105 typename View2> // Model MutableImageViewConcept
Chris@16 106 void copy_and_convert_pixels(const any_image_view<Types1>& src, const View2& dst) {
Chris@16 107 apply_operation(src,boost::bind(detail::copy_and_convert_pixels_fn<default_color_converter>(), _1, dst));
Chris@16 108 }
Chris@16 109
Chris@16 110 /// \ingroup ImageViewSTLAlgorithmsCopyAndConvertPixels
Chris@16 111 template <typename View1, // Model ImageViewConcept
Chris@16 112 typename Types2, // Model MPL Random Access Container of models of MutableImageViewConcept
Chris@16 113 typename CC> // Model ColorConverterConcept
Chris@16 114 void copy_and_convert_pixels(const View1& src, const any_image_view<Types2>& dst, CC cc) {
Chris@16 115 apply_operation(dst,boost::bind(detail::copy_and_convert_pixels_fn<CC>(cc), src, _1));
Chris@16 116 }
Chris@16 117
Chris@16 118 /// \ingroup ImageViewSTLAlgorithmsCopyAndConvertPixels
Chris@16 119 template <typename View1, // Model ImageViewConcept
Chris@16 120 typename Types2> // Model MPL Random Access Container of models of MutableImageViewConcept
Chris@16 121 void copy_and_convert_pixels(const View1& src, const any_image_view<Types2>& dst) {
Chris@16 122 apply_operation(dst,boost::bind(detail::copy_and_convert_pixels_fn<default_color_converter>(), src, _1));
Chris@16 123 }
Chris@16 124
Chris@16 125 /// \ingroup ImageViewSTLAlgorithmsCopyAndConvertPixels
Chris@16 126 template <typename Types1, // Model MPL Random Access Container of models of ImageViewConcept
Chris@16 127 typename Types2, // Model MPL Random Access Container of models of MutableImageViewConcept
Chris@16 128 typename CC> // Model ColorConverterConcept
Chris@16 129 void copy_and_convert_pixels(const any_image_view<Types1>& src, const any_image_view<Types2>& dst, CC cc) {
Chris@16 130 apply_operation(src,dst,detail::copy_and_convert_pixels_fn<CC>(cc));
Chris@16 131 }
Chris@16 132
Chris@16 133 /// \ingroup ImageViewSTLAlgorithmsCopyAndConvertPixels
Chris@16 134 template <typename Types1, // Model MPL Random Access Container of models of ImageViewConcept
Chris@16 135 typename Types2> // Model MPL Random Access Container of models of MutableImageViewConcept
Chris@16 136 void copy_and_convert_pixels(const any_image_view<Types1>& src, const any_image_view<Types2>& dst) {
Chris@16 137 apply_operation(src,dst,detail::copy_and_convert_pixels_fn<default_color_converter>());
Chris@16 138 }
Chris@16 139
Chris@16 140 namespace detail {
Chris@16 141 template <bool COMPATIBLE> struct fill_pixels_fn1 {
Chris@16 142 template <typename V, typename Value> static void apply(const V& src, const Value& val) { fill_pixels(src,val); }
Chris@16 143 };
Chris@16 144
Chris@16 145 // copy_pixels invoked on incompatible images
Chris@16 146 template <> struct fill_pixels_fn1<false> {
Chris@16 147 template <typename V, typename Value> static void apply(const V& src, const Value& val) { throw std::bad_cast();}
Chris@16 148 };
Chris@16 149
Chris@16 150 template <typename Value>
Chris@16 151 struct fill_pixels_fn {
Chris@16 152 fill_pixels_fn(const Value& val) : _val(val) {}
Chris@16 153
Chris@16 154 typedef void result_type;
Chris@16 155 template <typename V> result_type operator()(const V& img_view) const {
Chris@16 156 fill_pixels_fn1<pixels_are_compatible<typename V::value_type, Value>::value>::apply(img_view,_val);
Chris@16 157 }
Chris@16 158 Value _val;
Chris@16 159 };
Chris@16 160 }
Chris@16 161
Chris@16 162 /// \ingroup ImageViewSTLAlgorithmsFillPixels
Chris@16 163 /// \brief fill_pixels for any image view. The pixel to fill with must be compatible with the current view
Chris@16 164 template <typename Types, // Model MPL Random Access Container of models of MutableImageViewConcept
Chris@16 165 typename Value>
Chris@16 166 void fill_pixels(const any_image_view<Types>& img_view, const Value& val) {
Chris@16 167 apply_operation(img_view,detail::fill_pixels_fn<Value>(val));
Chris@16 168 }
Chris@16 169
Chris@16 170
Chris@16 171 } } // namespace boost::gil
Chris@16 172
Chris@16 173 #endif