UNPKG

boost-react-native-bundle

Version:

Boost library as in https://sourceforge.net/projects/boost/files/boost/1.57.0/

456 lines (451 loc) 92 kB
<!-- Copyright 2008 Lubomir Bourdev and Hailin Jin Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) --> <!-- Copyright 2005-2007 Adobe Systems Incorporated Distributed under the MIT License (see accompanying file LICENSE_1_0_0.txt or a copy at http://stlab.adobe.com/licenses.html) Some files are held under additional license. Please see "http://stlab.adobe.com/licenses.html" for more information. --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en"> <head> <TITLE>Generic Image Library: algorithm.hpp Source File</TITLE> <META HTTP-EQUIV="content-type" CONTENT="text/html;charset=ISO-8859-1"/> <LINK TYPE="text/css" REL="stylesheet" HREF="adobe_source.css"/> </head> <body> <table border="0" cellspacing="0" cellpadding="0" style='width: 100%; margin: 0; padding: 0'><tr> <td width="100%" valign="top" style='padding-left: 10px; padding-right: 10px; padding-bottom: 10px'> <div class="qindex"><a class="qindex" href="index.html">Modules</a> | <a class="qindex" href="classes.html">Alphabetical List</a> | <a class="qindex" href="annotated.html">Class List</a> | <a class="qindex" href="dirs.html">Directories</a> | <a class="qindex" href="files.html">File List</a> | <a class="qindex" href="../index.html">GIL Home Page</a> </div> <!-- End Header --> <!-- Generated by Doxygen 1.5.6 --> <div class="navpath"><a class="el" href="g_i_l_0076.html">boost</a>&nbsp;&raquo&nbsp;<a class="el" href="g_i_l_0079.html">gil</a> </div> <div class="contents"> <h1>algorithm.hpp</h1><a href="algorithm_8hpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/*</span> <a name="l00002"></a>00002 <span class="comment"> Copyright 2005-2007 Adobe Systems Incorporated</span> <a name="l00003"></a>00003 <span class="comment"> </span> <a name="l00004"></a>00004 <span class="comment"> Use, modification and distribution are subject to the Boost Software License,</span> <a name="l00005"></a>00005 <span class="comment"> Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at</span> <a name="l00006"></a>00006 <span class="comment"> http://www.boost.org/LICENSE_1_0.txt).</span> <a name="l00007"></a>00007 <span class="comment"></span> <a name="l00008"></a>00008 <span class="comment"> See http://opensource.adobe.com/gil for most recent version including documentation.</span> <a name="l00009"></a>00009 <span class="comment">*/</span> <a name="l00010"></a>00010 <a name="l00011"></a>00011 <a name="l00012"></a>00012 <span class="comment">/*************************************************************************************************/</span> <a name="l00013"></a>00013 <a name="l00014"></a>00014 <span class="preprocessor">#ifndef GIL_ALGORITHM_HPP</span> <a name="l00015"></a>00015 <span class="preprocessor"></span><span class="preprocessor">#define GIL_ALGORITHM_HPP</span> <a name="l00016"></a>00016 <span class="preprocessor"></span> <a name="l00017"></a>00017 <span class="preprocessor">#include &lt;cassert&gt;</span> <a name="l00018"></a>00018 <span class="preprocessor">#include &lt;cstddef&gt;</span> <a name="l00019"></a>00019 <span class="preprocessor">#include &lt;cstring&gt;</span> <a name="l00020"></a>00020 <span class="preprocessor">#include &lt;algorithm&gt;</span> <a name="l00021"></a>00021 <span class="preprocessor">#include &lt;iterator&gt;</span> <a name="l00022"></a>00022 <span class="preprocessor">#include &lt;memory&gt;</span> <a name="l00023"></a>00023 <span class="preprocessor">#include &lt;typeinfo&gt;</span> <a name="l00024"></a>00024 <span class="preprocessor">#include "<a class="code" href="g_i_l_0094.html" title="GIL configuration file.">gil_config.hpp</a>"</span> <a name="l00025"></a>00025 <span class="preprocessor">#include "<a class="code" href="g_i_l_0092.html" title="Concept check classes for GIL concepts.">gil_concept.hpp</a>"</span> <a name="l00026"></a>00026 <span class="preprocessor">#include "<a class="code" href="g_i_l_0069.html" title="pixel related algorithms">color_base_algorithm.hpp</a>"</span> <a name="l00027"></a>00027 <span class="preprocessor">#include "<a class="code" href="g_i_l_0225.html" title="image view class">image_view.hpp</a>"</span> <a name="l00028"></a>00028 <span class="preprocessor">#include "<a class="code" href="g_i_l_0227.html" title="Methods for constructing image views from raw data or other image views /.">image_view_factory.hpp</a>"</span> <a name="l00029"></a>00029 <span class="preprocessor">#include "<a class="code" href="g_i_l_0011.html" title="A model of a heterogeneous pixel that is not byte aligned. Examples are bitmap (1-bit...">bit_aligned_pixel_iterator.hpp</a>"</span> <a name="l00030"></a>00030 <a name="l00039"></a>00039 <a name="l00040"></a>00040 <span class="comment">//#ifdef _MSC_VER</span> <a name="l00041"></a>00041 <span class="comment">//#pragma warning(push)</span> <a name="l00042"></a>00042 <span class="comment">//#pragma warning(disable : 4244) // conversion from 'gil::image&lt;V,Alloc&gt;::coord_t' to 'int', possible loss of data (visual studio compiler doesn't realize that the two types are the same)</span> <a name="l00043"></a>00043 <span class="comment">//#endif</span> <a name="l00044"></a>00044 <a name="l00045"></a><a class="code" href="namespaceboost.html">00045</a> <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>gil { <a name="l00046"></a>00046 <a name="l00047"></a>00047 <span class="comment">//forward declarations</span> <a name="l00048"></a>00048 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> ChannelPtr, <span class="keyword">typename</span> ColorSpace&gt; <a name="l00049"></a>00049 <span class="keyword">struct </span>planar_pixel_iterator; <a name="l00050"></a>00050 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Iterator&gt; <a name="l00051"></a>00051 <span class="keyword">class </span>memory_based_step_iterator; <a name="l00052"></a>00052 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> StepIterator&gt; <a name="l00053"></a>00053 <span class="keyword">class </span>memory_based_2d_locator; <a name="l00054"></a>00054 <a name="l00055"></a>00055 <span class="comment">// a tag denoting incompatible arguments</span> <a name="l00056"></a>00056 <span class="keyword">struct </span>error_t {}; <a name="l00057"></a>00057 <a name="l00082"></a>00082 <a name="l00083"></a>00083 <a name="l00087"></a>00087 <a name="l00096"></a>00096 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Derived, <span class="keyword">typename</span> Result=<span class="keywordtype">void</span>&gt; <a name="l00097"></a><a class="code" href="g_i_l_0387.html">00097</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0387.html" title="A generic binary operation on viewsUse this class as a convenience superclass when...">binary_operation_obj</a> { <a name="l00098"></a>00098 <span class="keyword">typedef</span> Result result_type; <a name="l00099"></a>00099 <a name="l00100"></a>00100 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> V1, <span class="keyword">typename</span> V2&gt; GIL_FORCEINLINE <a name="l00101"></a>00101 result_type operator()(<span class="keyword">const</span> std::pair&lt;const V1*,const V2*&gt;&amp; p)<span class="keyword"> const </span>{ <a name="l00102"></a>00102 <span class="keywordflow">return</span> apply(*p.first, *p.second, <span class="keyword">typename</span> <a class="code" href="g_i_l_0636.html" title="Returns whether two views are compatible.">views_are_compatible&lt;V1,V2&gt;::type</a>()); <a name="l00103"></a>00103 } <a name="l00104"></a>00104 <a name="l00105"></a>00105 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> V1, <span class="keyword">typename</span> V2&gt; GIL_FORCEINLINE <a name="l00106"></a>00106 result_type operator()(<span class="keyword">const</span> V1&amp; v1, <span class="keyword">const</span> V2&amp; v2)<span class="keyword"> const </span>{ <a name="l00107"></a>00107 <span class="keywordflow">return</span> apply(v1, v2, <span class="keyword">typename</span> <a class="code" href="g_i_l_0636.html" title="Returns whether two views are compatible.">views_are_compatible&lt;V1,V2&gt;::type</a>()); <a name="l00108"></a>00108 } <a name="l00109"></a>00109 <a name="l00110"></a>00110 result_type operator()(<span class="keyword">const</span> error_t&amp;)<span class="keyword"> const </span>{ <span class="keywordflow">throw</span> std::bad_cast(); } <a name="l00111"></a>00111 <span class="keyword">private</span>: <a name="l00112"></a>00112 <a name="l00113"></a>00113 <span class="comment">// dispatch from apply overload to a function with distinct name</span> <a name="l00114"></a>00114 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> V1, <span class="keyword">typename</span> V2&gt; <a name="l00115"></a>00115 GIL_FORCEINLINE result_type apply(<span class="keyword">const</span> V1&amp; v1, <span class="keyword">const</span> V2&amp; v2, mpl::false_)<span class="keyword"> const </span>{ <a name="l00116"></a>00116 <span class="keywordflow">return</span> ((<span class="keyword">const</span> Derived*)<span class="keyword">this</span>)-&gt;apply_incompatible(v1,v2); <a name="l00117"></a>00117 } <a name="l00118"></a>00118 <a name="l00119"></a>00119 <span class="comment">// dispatch from apply overload to a function with distinct name</span> <a name="l00120"></a>00120 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> V1, <span class="keyword">typename</span> V2&gt; <a name="l00121"></a>00121 GIL_FORCEINLINE result_type apply(<span class="keyword">const</span> V1&amp; v1, <span class="keyword">const</span> V2&amp; v2, mpl::true_)<span class="keyword"> const </span>{ <a name="l00122"></a>00122 <span class="keywordflow">return</span> ((<span class="keyword">const</span> Derived*)<span class="keyword">this</span>)-&gt;apply_compatible(v1,v2); <a name="l00123"></a>00123 } <a name="l00124"></a>00124 <a name="l00125"></a>00125 <span class="comment">// function with distinct name - it can be overloaded by subclasses</span> <a name="l00126"></a>00126 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> V1, <span class="keyword">typename</span> V2&gt; <a name="l00127"></a>00127 GIL_FORCEINLINE result_type apply_incompatible(<span class="keyword">const</span> V1&amp; v1, <span class="keyword">const</span> V2&amp; v2)<span class="keyword"> const </span>{ <a name="l00128"></a>00128 <span class="keywordflow">throw</span> std::bad_cast(); <a name="l00129"></a>00129 } <a name="l00130"></a>00130 }; <a name="l00131"></a>00131 } } <span class="comment">// namespace boost::gil</span> <a name="l00132"></a>00132 <a name="l00138"></a>00138 <a name="l00142"></a>00142 <a name="l00143"></a>00143 <span class="keyword">namespace </span>std { <a name="l00144"></a>00144 <a name="l00147"></a>00147 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T, <span class="keyword">typename</span> Cs&gt; <a name="l00148"></a>00148 GIL_FORCEINLINE <a class="code" href="g_i_l_0599.html" title="Represents a pixel value (a container of channels). Models: HomogeneousColorBaseValueConcept...">boost::gil::pixel&lt;T,Cs&gt;</a>* <a name="l00149"></a><a class="code" href="g_i_l_0214.html#gc2faa90ab27d7fb0253d19839c75d341">00149</a> <a class="code" href="g_i_l_0214.html#g4e8a9e1bb08e76c93dc56a4626231ee1" title="Copy when both src and dst are planar pointers is copy for each channel.">copy</a>(<a class="code" href="g_i_l_0599.html" title="Represents a pixel value (a container of channels). Models: HomogeneousColorBaseValueConcept...">boost::gil::pixel&lt;T,Cs&gt;</a>* first, <a class="code" href="g_i_l_0599.html" title="Represents a pixel value (a container of channels). Models: HomogeneousColorBaseValueConcept...">boost::gil::pixel&lt;T,Cs&gt;</a>* last, <a name="l00150"></a>00150 <a class="code" href="g_i_l_0599.html" title="Represents a pixel value (a container of channels). Models: HomogeneousColorBaseValueConcept...">boost::gil::pixel&lt;T,Cs&gt;</a>* dst) { <a name="l00151"></a>00151 <span class="keywordflow">return</span> (<a class="code" href="g_i_l_0599.html" title="Represents a pixel value (a container of channels). Models: HomogeneousColorBaseValueConcept...">boost::gil::pixel&lt;T,Cs&gt;</a>*)<a class="code" href="g_i_l_0214.html#g4e8a9e1bb08e76c93dc56a4626231ee1" title="Copy when both src and dst are planar pointers is copy for each channel.">std::copy</a>((<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>*)first,(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>*)last, (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>*)dst); <a name="l00152"></a>00152 } <a name="l00153"></a>00153 <a name="l00156"></a>00156 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T, <span class="keyword">typename</span> Cs&gt; <a name="l00157"></a>00157 GIL_FORCEINLINE <a class="code" href="g_i_l_0599.html" title="Represents a pixel value (a container of channels). Models: HomogeneousColorBaseValueConcept...">boost::gil::pixel&lt;T,Cs&gt;</a>* <a name="l00158"></a><a class="code" href="g_i_l_0214.html#g85354afb86367e7d21162317463e8743">00158</a> <a class="code" href="g_i_l_0214.html#g4e8a9e1bb08e76c93dc56a4626231ee1" title="Copy when both src and dst are planar pointers is copy for each channel.">copy</a>(<span class="keyword">const</span> <a class="code" href="g_i_l_0599.html" title="Represents a pixel value (a container of channels). Models: HomogeneousColorBaseValueConcept...">boost::gil::pixel&lt;T,Cs&gt;</a>* first, <span class="keyword">const</span> <a class="code" href="g_i_l_0599.html" title="Represents a pixel value (a container of channels). Models: HomogeneousColorBaseValueConcept...">boost::gil::pixel&lt;T,Cs&gt;</a>* last, <a name="l00159"></a>00159 <a class="code" href="g_i_l_0599.html" title="Represents a pixel value (a container of channels). Models: HomogeneousColorBaseValueConcept...">boost::gil::pixel&lt;T,Cs&gt;</a>* dst) { <a name="l00160"></a>00160 <span class="keywordflow">return</span> (<a class="code" href="g_i_l_0599.html" title="Represents a pixel value (a container of channels). Models: HomogeneousColorBaseValueConcept...">boost::gil::pixel&lt;T,Cs&gt;</a>*)<a class="code" href="g_i_l_0214.html#g4e8a9e1bb08e76c93dc56a4626231ee1" title="Copy when both src and dst are planar pointers is copy for each channel.">std::copy</a>((<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>*)first,(<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>*)last, (<span class="keywordtype">unsigned</span> <span class="keywordtype">char</span>*)dst); <a name="l00161"></a>00161 } <a name="l00162"></a>00162 } <span class="comment">// namespace std</span> <a name="l00163"></a>00163 <a name="l00164"></a>00164 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>gil { <a name="l00165"></a>00165 <span class="keyword">namespace </span>detail { <a name="l00166"></a>00166 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> I, <span class="keyword">typename</span> O&gt; <span class="keyword">struct </span>copy_fn { <a name="l00167"></a>00167 GIL_FORCEINLINE I operator()(I first, I last, O dst)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="g_i_l_0214.html#g4e8a9e1bb08e76c93dc56a4626231ee1" title="Copy when both src and dst are planar pointers is copy for each channel.">std::copy</a>(first,last,dst); } <a name="l00168"></a>00168 }; <a name="l00169"></a>00169 } <span class="comment">// namespace detail</span> <a name="l00170"></a>00170 } } <span class="comment">// namespace boost::gil</span> <a name="l00171"></a>00171 <a name="l00172"></a>00172 <span class="keyword">namespace </span>std { <a name="l00175"></a>00175 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> Cs, <span class="keyword">typename</span> IC1, <span class="keyword">typename</span> IC2&gt; GIL_FORCEINLINE <a name="l00176"></a><a class="code" href="g_i_l_0214.html#g4e8a9e1bb08e76c93dc56a4626231ee1">00176</a> <a class="code" href="g_i_l_0609.html" title="An iterator over planar pixels. Models HomogeneousColorBaseConcept, PixelIteratorConcept...">boost::gil::planar_pixel_iterator&lt;IC2,Cs&gt;</a> <a class="code" href="g_i_l_0214.html#g4e8a9e1bb08e76c93dc56a4626231ee1" title="Copy when both src and dst are planar pointers is copy for each channel.">copy</a>(<a class="code" href="g_i_l_0609.html" title="An iterator over planar pixels. Models HomogeneousColorBaseConcept, PixelIteratorConcept...">boost::gil::planar_pixel_iterator&lt;IC1,Cs&gt;</a> first, <a class="code" href="g_i_l_0609.html" title="An iterator over planar pixels. Models HomogeneousColorBaseConcept, PixelIteratorConcept...">boost::gil::planar_pixel_iterator&lt;IC1,Cs&gt;</a> last, <a class="code" href="g_i_l_0609.html" title="An iterator over planar pixels. Models HomogeneousColorBaseConcept, PixelIteratorConcept...">boost::gil::planar_pixel_iterator&lt;IC2,Cs&gt;</a> dst) { <a name="l00177"></a>00177 boost::gil::gil_function_requires&lt;boost::gil::ChannelsCompatibleConcept&lt;typename std::iterator_traits&lt;IC1&gt;::value_type,<span class="keyword">typename</span> std::iterator_traits&lt;IC2&gt;::value_type&gt; &gt;(); <a name="l00178"></a>00178 static_for_each(first,last,dst,boost::gil::detail::copy_fn&lt;IC1,IC2&gt;()); <a name="l00179"></a>00179 <span class="keywordflow">return</span> dst+(last-first); <a name="l00180"></a>00180 } <a name="l00181"></a>00181 } <span class="comment">// namespace std</span> <a name="l00182"></a>00182 <a name="l00183"></a>00183 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>gil { <a name="l00184"></a>00184 <span class="keyword">namespace </span>detail { <a name="l00187"></a>00187 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> I, <span class="keyword">typename</span> O&gt; <a name="l00188"></a><a class="code" href="g_i_l_0479.html">00188</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0479.html">copier_n</a> { <a name="l00189"></a>00189 GIL_FORCEINLINE <span class="keywordtype">void</span> operator()(I src, <span class="keyword">typename</span> std::iterator_traits&lt;I&gt;::difference_type n, O dst)<span class="keyword"> const </span>{ <a class="code" href="g_i_l_0214.html#g4e8a9e1bb08e76c93dc56a4626231ee1" title="Copy when both src and dst are planar pointers is copy for each channel.">std::copy</a>(src,src+n, dst); } <a name="l00190"></a>00190 }; <a name="l00191"></a>00191 <a name="l00193"></a>00193 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> IL, <span class="keyword">typename</span> O&gt; <span class="comment">// IL Models ConstPixelLocatorConcept, O Models PixelIteratorConcept</span> <a name="l00194"></a><a class="code" href="g_i_l_0483.html">00194</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0479.html">copier_n</a>&lt;<a class="code" href="g_i_l_0042.html" title="Provides 1D random-access navigation to the pixels of the image. Models: PixelIteratorConcept...">iterator_from_2d</a>&lt;IL&gt;,O&gt; { <a name="l00195"></a>00195 <span class="keyword">typedef</span> <span class="keyword">typename</span> std::iterator_traits&lt;iterator_from_2d&lt;IL&gt; &gt;::difference_type diff_t; <a name="l00196"></a>00196 GIL_FORCEINLINE <span class="keywordtype">void</span> operator()(<a class="code" href="g_i_l_0042.html" title="Provides 1D random-access navigation to the pixels of the image. Models: PixelIteratorConcept...">iterator_from_2d&lt;IL&gt;</a> src, diff_t n, O dst)<span class="keyword"> const </span>{ <a name="l00197"></a>00197 gil_function_requires&lt;PixelLocatorConcept&lt;IL&gt; &gt;(); <a name="l00198"></a>00198 gil_function_requires&lt;MutablePixelIteratorConcept&lt;O&gt; &gt;(); <a name="l00199"></a>00199 <span class="keywordflow">while</span> (n&gt;0) { <a name="l00200"></a>00200 <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="g_i_l_0042.html" title="Provides 1D random-access navigation to the pixels of the image. Models: PixelIteratorConcept...">iterator_from_2d&lt;IL&gt;::difference_type</a> diff_t; <a name="l00201"></a>00201 diff_t l=src.<a class="code" href="g_i_l_0042.html#379c24f2d0a75769afc06dff7b569b8f">width</a>()-src.<a class="code" href="g_i_l_0042.html#cb3204f0b17472894a99939821d597be">x_pos</a>(); <a name="l00202"></a>00202 diff_t numToCopy=(n&lt;l ? n:l); <a name="l00203"></a>00203 detail::copy_n(src.<a class="code" href="g_i_l_0042.html#72169bdc650ac7eda288398e4ce1d7f8">x</a>(), numToCopy, dst); <a name="l00204"></a>00204 dst+=numToCopy; <a name="l00205"></a>00205 src+=numToCopy; <a name="l00206"></a>00206 n-=numToCopy; <a name="l00207"></a>00207 } <a name="l00208"></a>00208 } <a name="l00209"></a>00209 }; <a name="l00210"></a>00210 <a name="l00212"></a>00212 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> I, <span class="keyword">typename</span> OL&gt; <span class="comment">// I Models ConstPixelIteratorConcept, OL Models PixelLocatorConcept</span> <a name="l00213"></a><a class="code" href="g_i_l_0481.html">00213</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0479.html">copier_n</a>&lt;I,<a class="code" href="g_i_l_0042.html" title="Provides 1D random-access navigation to the pixels of the image. Models: PixelIteratorConcept...">iterator_from_2d</a>&lt;OL&gt; &gt; { <a name="l00214"></a>00214 <span class="keyword">typedef</span> <span class="keyword">typename</span> std::iterator_traits&lt;I&gt;::difference_type diff_t; <a name="l00215"></a>00215 GIL_FORCEINLINE <span class="keywordtype">void</span> operator()(I src, diff_t n, <a class="code" href="g_i_l_0042.html" title="Provides 1D random-access navigation to the pixels of the image. Models: PixelIteratorConcept...">iterator_from_2d&lt;OL&gt;</a> dst)<span class="keyword"> const </span>{ <a name="l00216"></a>00216 gil_function_requires&lt;PixelIteratorConcept&lt;I&gt; &gt;(); <a name="l00217"></a>00217 gil_function_requires&lt;MutablePixelLocatorConcept&lt;OL&gt; &gt;(); <a name="l00218"></a>00218 <span class="keywordflow">while</span> (n&gt;0) { <a name="l00219"></a>00219 diff_t l=dst.<a class="code" href="g_i_l_0042.html#379c24f2d0a75769afc06dff7b569b8f">width</a>()-dst.<a class="code" href="g_i_l_0042.html#cb3204f0b17472894a99939821d597be">x_pos</a>(); <a name="l00220"></a>00220 diff_t numToCopy=(n&lt;l ? n:l); <a name="l00221"></a>00221 detail::copy_n(src, numToCopy, dst.<a class="code" href="g_i_l_0042.html#72169bdc650ac7eda288398e4ce1d7f8">x</a>()); <a name="l00222"></a>00222 dst+=numToCopy; <a name="l00223"></a>00223 src+=numToCopy; <a name="l00224"></a>00224 n-=numToCopy; <a name="l00225"></a>00225 } <a name="l00226"></a>00226 } <a name="l00227"></a>00227 }; <a name="l00228"></a>00228 <a name="l00230"></a>00230 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> IL, <span class="keyword">typename</span> OL&gt; <a name="l00231"></a><a class="code" href="g_i_l_0485.html">00231</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0479.html">copier_n</a>&lt;<a class="code" href="g_i_l_0042.html" title="Provides 1D random-access navigation to the pixels of the image. Models: PixelIteratorConcept...">iterator_from_2d</a>&lt;IL&gt;,<a class="code" href="g_i_l_0042.html" title="Provides 1D random-access navigation to the pixels of the image. Models: PixelIteratorConcept...">iterator_from_2d</a>&lt;OL&gt; &gt; { <a name="l00232"></a>00232 <span class="keyword">typedef</span> <span class="keyword">typename</span> <a class="code" href="g_i_l_0042.html" title="Provides 1D random-access navigation to the pixels of the image. Models: PixelIteratorConcept...">iterator_from_2d&lt;IL&gt;::difference_type</a> diff_t; <a name="l00233"></a>00233 GIL_FORCEINLINE <span class="keywordtype">void</span> operator()(<a class="code" href="g_i_l_0042.html" title="Provides 1D random-access navigation to the pixels of the image. Models: PixelIteratorConcept...">iterator_from_2d&lt;IL&gt;</a> src, diff_t n, <a class="code" href="g_i_l_0042.html" title="Provides 1D random-access navigation to the pixels of the image. Models: PixelIteratorConcept...">iterator_from_2d&lt;OL&gt;</a> dst)<span class="keyword"> const </span>{ <a name="l00234"></a>00234 gil_function_requires&lt;PixelLocatorConcept&lt;IL&gt; &gt;(); <a name="l00235"></a>00235 gil_function_requires&lt;MutablePixelLocatorConcept&lt;OL&gt; &gt;(); <a name="l00236"></a>00236 <span class="keywordflow">if</span> (src.<a class="code" href="g_i_l_0042.html#cb3204f0b17472894a99939821d597be">x_pos</a>()!=dst.<a class="code" href="g_i_l_0042.html#cb3204f0b17472894a99939821d597be">x_pos</a>() || src.<a class="code" href="g_i_l_0042.html#379c24f2d0a75769afc06dff7b569b8f">width</a>()!=dst.<a class="code" href="g_i_l_0042.html#379c24f2d0a75769afc06dff7b569b8f">width</a>()) { <a name="l00237"></a>00237 <span class="keywordflow">while</span>(n--&gt;0) { <a name="l00238"></a>00238 *dst++=*src++; <a name="l00239"></a>00239 } <a name="l00240"></a>00240 } <a name="l00241"></a>00241 <span class="keywordflow">while</span> (n&gt;0) { <a name="l00242"></a>00242 diff_t l=dst.<a class="code" href="g_i_l_0042.html#379c24f2d0a75769afc06dff7b569b8f">width</a>()-dst.<a class="code" href="g_i_l_0042.html#cb3204f0b17472894a99939821d597be">x_pos</a>(); <a name="l00243"></a>00243 diff_t numToCopy=(n&lt;l ? n : l); <a name="l00244"></a>00244 detail::copy_n(src.<a class="code" href="g_i_l_0042.html#72169bdc650ac7eda288398e4ce1d7f8">x</a>(), numToCopy, dst.<a class="code" href="g_i_l_0042.html#72169bdc650ac7eda288398e4ce1d7f8">x</a>()); <a name="l00245"></a>00245 dst+=numToCopy; <a name="l00246"></a>00246 src+=numToCopy; <a name="l00247"></a>00247 n-=numToCopy; <a name="l00248"></a>00248 } <a name="l00249"></a>00249 } <a name="l00250"></a>00250 }; <a name="l00251"></a>00251 <a name="l00252"></a>00252 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> SrcIterator, <span class="keyword">typename</span> DstIterator&gt; <a name="l00253"></a>00253 GIL_FORCEINLINE DstIterator copy_with_2d_iterators(SrcIterator first, SrcIterator last, DstIterator dst) { <a name="l00254"></a>00254 <span class="keyword">typedef</span> <span class="keyword">typename</span> SrcIterator::x_iterator src_x_iterator; <a name="l00255"></a>00255 <span class="keyword">typedef</span> <span class="keyword">typename</span> DstIterator::x_iterator dst_x_iterator; <a name="l00256"></a>00256 <a name="l00257"></a>00257 <span class="keyword">typename</span> SrcIterator::difference_type n = last - first; <a name="l00258"></a>00258 <a name="l00259"></a>00259 <span class="keywordflow">if</span> (first.is_1d_traversable()) { <a name="l00260"></a>00260 <span class="keywordflow">if</span> (dst.is_1d_traversable()) <a name="l00261"></a>00261 <a class="code" href="g_i_l_0479.html">copier_n&lt;src_x_iterator,dst_x_iterator&gt;</a>()(first.x(),n, dst.x()); <a name="l00262"></a>00262 <span class="keywordflow">else</span> <a name="l00263"></a>00263 <a class="code" href="g_i_l_0479.html">copier_n&lt;src_x_iterator,DstIterator &gt;</a>()(first.x(),n, dst); <a name="l00264"></a>00264 } <span class="keywordflow">else</span> { <a name="l00265"></a>00265 <span class="keywordflow">if</span> (dst.is_1d_traversable()) <a name="l00266"></a>00266 copier_n&lt;SrcIterator,dst_x_iterator&gt;()(first,n, dst.x()); <a name="l00267"></a>00267 <span class="keywordflow">else</span> <a name="l00268"></a>00268 copier_n&lt;SrcIterator,DstIterator&gt;()(first,n,dst); <a name="l00269"></a>00269 } <a name="l00270"></a>00270 <span class="keywordflow">return</span> dst+n; <a name="l00271"></a>00271 } <a name="l00272"></a>00272 <a name="l00273"></a>00273 } <span class="comment">// namespace detail</span> <a name="l00274"></a>00274 } } <span class="comment">// namespace boost::gil</span> <a name="l00275"></a>00275 <a name="l00276"></a>00276 <span class="keyword">namespace </span>std { <a name="l00279"></a>00279 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> IL, <span class="keyword">typename</span> OL&gt; <a name="l00280"></a><a class="code" href="g_i_l_0214.html#g12594bf8bdb7b27c070987a3d30293ba">00280</a> GIL_FORCEINLINE <a class="code" href="g_i_l_0042.html" title="Provides 1D random-access navigation to the pixels of the image. Models: PixelIteratorConcept...">boost::gil::iterator_from_2d&lt;OL&gt;</a> <a class="code" href="g_i_l_0214.html#g12594bf8bdb7b27c070987a3d30293ba" title="std::copy(I1,I1,I2) with I1 and I2 being a iterator_from_2d">copy1</a>(<a class="code" href="g_i_l_0042.html" title="Provides 1D random-access navigation to the pixels of the image. Models: PixelIteratorConcept...">boost::gil::iterator_from_2d&lt;IL&gt;</a> first, <a class="code" href="g_i_l_0042.html" title="Provides 1D random-access navigation to the pixels of the image. Models: PixelIteratorConcept...">boost::gil::iterator_from_2d&lt;IL&gt;</a> last, <a class="code" href="g_i_l_0042.html" title="Provides 1D random-access navigation to the pixels of the image. Models: PixelIteratorConcept...">boost::gil::iterator_from_2d&lt;OL&gt;</a> dst) { <a name="l00281"></a>00281 <span class="keywordflow">return</span> boost::gil::detail::copy_with_2d_iterators(first,last,dst); <a name="l00282"></a>00282 } <a name="l00283"></a>00283 <a name="l00284"></a>00284 } <span class="comment">// namespace std</span> <a name="l00285"></a>00285 <a name="l00286"></a>00286 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>gil { <a name="l00287"></a>00287 <a name="l00288"></a>00288 <a name="l00291"></a>00291 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View1, <span class="keyword">typename</span> View2&gt; GIL_FORCEINLINE <a name="l00292"></a><a class="code" href="g_i_l_0145.html#g16f18749152217a2b84733c330a2b415">00292</a> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0145.html#g16f18749152217a2b84733c330a2b415" title="std::copy for image views">copy_pixels</a>(<span class="keyword">const</span> View1&amp; src, <span class="keyword">const</span> View2&amp; dst) { <a name="l00293"></a>00293 assert(src.dimensions()==dst.dimensions()); <a name="l00294"></a>00294 detail::copy_with_2d_iterators(src.begin(),src.end(),dst.begin()); <a name="l00295"></a>00295 } <a name="l00296"></a>00296 <a name="l00302"></a>00302 <a name="l00308"></a>00308 <a name="l00309"></a>00309 <span class="keyword">namespace </span>detail { <a name="l00310"></a>00310 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> CC&gt; <a name="l00311"></a>00311 <span class="keyword">class </span>copy_and_convert_pixels_fn : <span class="keyword">public</span> binary_operation_obj&lt;copy_and_convert_pixels_fn&lt;CC&gt; &gt; { <a name="l00312"></a>00312 <span class="keyword">private</span>: <a name="l00313"></a>00313 CC _cc; <a name="l00314"></a>00314 <span class="keyword">public</span>: <a name="l00315"></a>00315 <span class="keyword">typedef</span> <span class="keyword">typename</span> binary_operation_obj&lt;copy_and_convert_pixels_fn&lt;CC&gt; &gt;::result_type result_type; <a name="l00316"></a>00316 copy_and_convert_pixels_fn() {} <a name="l00317"></a>00317 copy_and_convert_pixels_fn(CC cc_in) : _cc(cc_in) {} <a name="l00318"></a>00318 <span class="comment">// when the two color spaces are incompatible, a color conversion is performed</span> <a name="l00319"></a>00319 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> V1, <span class="keyword">typename</span> V2&gt; GIL_FORCEINLINE <a name="l00320"></a>00320 result_type apply_incompatible(<span class="keyword">const</span> V1&amp; src, <span class="keyword">const</span> V2&amp; dst)<span class="keyword"> const </span>{ <a name="l00321"></a>00321 <a class="code" href="g_i_l_0145.html#g16f18749152217a2b84733c330a2b415" title="std::copy for image views">copy_pixels</a>(color_converted_view&lt;typename V2::value_type&gt;(src,_cc),dst); <a name="l00322"></a>00322 } <a name="l00323"></a>00323 <a name="l00324"></a>00324 <span class="comment">// If the two color spaces are compatible, copy_and_convert is just copy</span> <a name="l00325"></a>00325 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> V1, <span class="keyword">typename</span> V2&gt; GIL_FORCEINLINE <a name="l00326"></a>00326 result_type apply_compatible(<span class="keyword">const</span> V1&amp; src, <span class="keyword">const</span> V2&amp; dst)<span class="keyword"> const </span>{ <a name="l00327"></a>00327 <a class="code" href="g_i_l_0145.html#g16f18749152217a2b84733c330a2b415" title="std::copy for image views">copy_pixels</a>(src,dst); <a name="l00328"></a>00328 } <a name="l00329"></a>00329 }; <a name="l00330"></a>00330 } <span class="comment">// namespace detail</span> <a name="l00331"></a>00331 <a name="l00333"></a>00333 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> V1, <span class="keyword">typename</span> V2,<span class="keyword">typename</span> CC&gt; <a name="l00334"></a>00334 GIL_FORCEINLINE <a name="l00335"></a>00335 <span class="keywordtype">void</span> copy_and_convert_pixels(<span class="keyword">const</span> V1&amp; src, <span class="keyword">const</span> V2&amp; dst,CC cc) { <a name="l00336"></a>00336 detail::copy_and_convert_pixels_fn&lt;CC&gt; ccp(cc); <a name="l00337"></a>00337 ccp(src,dst); <a name="l00338"></a>00338 } <a name="l00339"></a>00339 <a name="l00340"></a>00340 <span class="keyword">struct </span>default_color_converter; <a name="l00341"></a>00341 <a name="l00343"></a>00343 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View1, <span class="keyword">typename</span> View2&gt; <a name="l00344"></a>00344 GIL_FORCEINLINE <a name="l00345"></a>00345 <span class="keywordtype">void</span> copy_and_convert_pixels(<span class="keyword">const</span> View1&amp; src, <span class="keyword">const</span> View2&amp; dst) { <a name="l00346"></a>00346 detail::copy_and_convert_pixels_fn&lt;default_color_converter&gt; ccp; <a name="l00347"></a>00347 ccp(src,dst); <a name="l00348"></a>00348 } <a name="l00349"></a>00349 <a name="l00350"></a>00350 } } <span class="comment">// namespace boost::gil</span> <a name="l00351"></a>00351 <a name="l00353"></a>00353 <span class="comment">//</span> <a name="l00354"></a>00354 <span class="comment">// std::fill and gil::fill_pixels</span> <a name="l00355"></a>00355 <span class="comment">//</span> <a name="l00357"></a>00357 <span class="comment"></span> <a name="l00361"></a>00361 <a name="l00362"></a>00362 <a name="l00363"></a>00363 <span class="keyword">namespace </span>std { <a name="l00372"></a>00372 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> IL, <span class="keyword">typename</span> V&gt; <a name="l00373"></a><a class="code" href="g_i_l_0214.html#g718772a47188f4e2ecfce2f28fa3dc4f">00373</a> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0214.html#g718772a47188f4e2ecfce2f28fa3dc4f" title="std::fill(I,I,V) with I being a iterator_from_2d">fill</a>(<a class="code" href="g_i_l_0042.html" title="Provides 1D random-access navigation to the pixels of the image. Models: PixelIteratorConcept...">boost::gil::iterator_from_2d&lt;IL&gt;</a> first, <a class="code" href="g_i_l_0042.html" title="Provides 1D random-access navigation to the pixels of the image. Models: PixelIteratorConcept...">boost::gil::iterator_from_2d&lt;IL&gt;</a> last, <span class="keyword">const</span> V&amp; val) { <a name="l00374"></a>00374 boost::gil::gil_function_requires&lt;boost::gil::MutablePixelLocatorConcept&lt;IL&gt; &gt;(); <a name="l00375"></a>00375 <span class="keywordflow">if</span> (first.<a class="code" href="g_i_l_0042.html#90ccf75aa2deb01fbce509842191cad2">is_1d_traversable</a>()) { <a name="l00376"></a>00376 <a class="code" href="g_i_l_0214.html#g718772a47188f4e2ecfce2f28fa3dc4f" title="std::fill(I,I,V) with I being a iterator_from_2d">std::fill</a>(first.<a class="code" href="g_i_l_0042.html#72169bdc650ac7eda288398e4ce1d7f8">x</a>(), last.<a class="code" href="g_i_l_0042.html#72169bdc650ac7eda288398e4ce1d7f8">x</a>(), val); <a name="l00377"></a>00377 } <span class="keywordflow">else</span> { <a name="l00378"></a>00378 <span class="comment">// fill row by row</span> <a name="l00379"></a>00379 std::ptrdiff_t n=last-first; <a name="l00380"></a>00380 <span class="keywordflow">while</span> (n&gt;0) { <a name="l00381"></a>00381 std::ptrdiff_t numToDo=std::min&lt;const std::ptrdiff_t&gt;(n,(std::ptrdiff_t)(first.width()-first.x_pos())); <a name="l00382"></a>00382 fill_n(first.x(), numToDo, val); <a name="l00383"></a>00383 first+=numToDo; <a name="l00384"></a>00384 n-=numToDo; <a name="l00385"></a>00385 } <a name="l00386"></a>00386 } <a name="l00387"></a>00387 } <a name="l00388"></a>00388 } <span class="comment">// namespace std</span> <a name="l00389"></a>00389 <a name="l00390"></a>00390 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>gil { <a name="l00391"></a>00391 <a name="l00392"></a>00392 <span class="keyword">namespace </span>detail { <a name="l00394"></a><a class="code" href="g_i_l_0521.html">00394</a> <span class="keyword">struct </span><a class="code" href="g_i_l_0521.html" title="struct to do std::fill">std_fill_t</a> { <a name="l00395"></a>00395 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> It, <span class="keyword">typename</span> P&gt; <a name="l00396"></a>00396 <span class="keywordtype">void</span> operator()(It first, It last, <span class="keyword">const</span> P&amp; p_in) { <a name="l00397"></a>00397 <a class="code" href="g_i_l_0214.html#g718772a47188f4e2ecfce2f28fa3dc4f" title="std::fill(I,I,V) with I being a iterator_from_2d">std::fill</a>(first,last,p_in); <a name="l00398"></a>00398 } <a name="l00399"></a>00399 }; <a name="l00401"></a>00401 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> It, <span class="keyword">typename</span> P&gt; <a name="l00402"></a>00402 GIL_FORCEINLINE <a name="l00403"></a>00403 <span class="keywordtype">void</span> fill_aux(It first, It last, <span class="keyword">const</span> P&amp; p, mpl::true_) { <a name="l00404"></a>00404 static_for_each(first,last,p,<a class="code" href="g_i_l_0521.html" title="struct to do std::fill">std_fill_t</a>()); <a name="l00405"></a>00405 } <a name="l00407"></a>00407 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> It, <span class="keyword">typename</span> P&gt; <a name="l00408"></a>00408 GIL_FORCEINLINE <a name="l00409"></a>00409 <span class="keywordtype">void</span> fill_aux(It first, It last, <span class="keyword">const</span> P&amp; p,mpl::false_) { <a name="l00410"></a>00410 <a class="code" href="g_i_l_0214.html#g718772a47188f4e2ecfce2f28fa3dc4f" title="std::fill(I,I,V) with I being a iterator_from_2d">std::fill</a>(first,last,p); <a name="l00411"></a>00411 } <a name="l00412"></a>00412 } <span class="comment">// namespace detail</span> <a name="l00413"></a>00413 <a name="l00416"></a>00416 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View, <span class="keyword">typename</span> Value&gt; GIL_FORCEINLINE <a name="l00417"></a><a class="code" href="g_i_l_0149.html#g3b28c66102763fd1d42f69e4eefa631f">00417</a> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0149.html#gd38040bb50f5ea498151dd846d4d7873" title="fill_pixels for any image view. The pixel to fill with must be compatible with the...">fill_pixels</a>(<span class="keyword">const</span> View&amp; img_view, <span class="keyword">const</span> Value&amp; val) { <a name="l00418"></a>00418 <span class="keywordflow">if</span> (img_view.is_1d_traversable()) <a name="l00419"></a>00419 detail::fill_aux(img_view.begin().x(), img_view.end().x(), <a name="l00420"></a>00420 val,is_planar&lt;View&gt;()); <a name="l00421"></a>00421 <span class="keywordflow">else</span> <a name="l00422"></a>00422 <span class="keywordflow">for</span> (std::ptrdiff_t y=0; y&lt;img_view.height(); ++y) <a name="l00423"></a>00423 detail::fill_aux(img_view.row_begin(y),img_view.row_end(y), <a name="l00424"></a>00424 val,is_planar&lt;View&gt;()); <a name="l00425"></a>00425 } <a name="l00426"></a>00426 <a name="l00432"></a>00432 <a name="l00436"></a>00436 <a name="l00437"></a>00437 <a name="l00438"></a>00438 <span class="keyword">namespace </span>detail { <a name="l00439"></a>00439 <a name="l00440"></a>00440 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> It&gt; GIL_FORCEINLINE <a name="l00441"></a>00441 <span class="keywordtype">void</span> destruct_range_impl(It first, It last, mpl::true_) { <a name="l00442"></a>00442 <span class="keyword">typedef</span> <span class="keyword">typename</span> std::iterator_traits&lt;It&gt;::value_type value_t; <a name="l00443"></a>00443 <span class="keywordflow">if</span> (boost::has_trivial_destructor&lt;value_t&gt;::value) <a name="l00444"></a>00444 <span class="keywordflow">return</span>; <a name="l00445"></a>00445 <span class="keywordflow">while</span> (first!=last) { <a name="l00446"></a>00446 first-&gt;~value_t(); <a name="l00447"></a>00447 ++first; <a name="l00448"></a>00448 } <a name="l00449"></a>00449 } <a name="l00450"></a>00450 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> It&gt; GIL_FORCEINLINE <a name="l00451"></a>00451 <span class="keywordtype">void</span> destruct_range_impl(It first, It last, mpl::false_) {} <a name="l00452"></a>00452 <a name="l00453"></a>00453 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> It&gt; GIL_FORCEINLINE <a name="l00454"></a>00454 <span class="keywordtype">void</span> destruct_range(It first, It last) { <a name="l00455"></a>00455 destruct_range_impl(first,last,<span class="keyword">typename</span> is_pointer&lt;It&gt;::type()); <a name="l00456"></a>00456 } <a name="l00457"></a>00457 <a name="l00458"></a>00458 <span class="keyword">struct </span>std_destruct_t { <a name="l00459"></a>00459 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> It&gt; <span class="keywordtype">void</span> operator()(It first, It last)<span class="keyword"> const </span>{ destruct_range(first,last); } <a name="l00460"></a>00460 }; <a name="l00461"></a>00461 <a name="l00463"></a>00463 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> It&gt; <a name="l00464"></a>00464 GIL_FORCEINLINE <a name="l00465"></a>00465 <span class="keywordtype">void</span> destruct_aux(It first, It last, mpl::true_) { <a name="l00466"></a>00466 static_for_each(first,last,std_destruct_t()); <a name="l00467"></a>00467 } <a name="l00469"></a>00469 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> It&gt; <a name="l00470"></a>00470 GIL_FORCEINLINE <a name="l00471"></a>00471 <span class="keywordtype">void</span> destruct_aux(It first, It last, mpl::false_) { <a name="l00472"></a>00472 destruct_range(first,last); <a name="l00473"></a>00473 } <a name="l00474"></a>00474 <a name="l00475"></a>00475 } <span class="comment">// namespace detail</span> <a name="l00476"></a>00476 <a name="l00479"></a>00479 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt; GIL_FORCEINLINE <a name="l00480"></a><a class="code" href="g_i_l_0147.html#g5c465a97a10e15d9ce18a3c2fff7f91d">00480</a> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0147.html#g5c465a97a10e15d9ce18a3c2fff7f91d" title="Invokes the in-place destructor on every pixel of the view.">destruct_pixels</a>(<span class="keyword">const</span> View&amp; img_view) { <a name="l00481"></a>00481 <span class="keywordflow">if</span> (img_view.is_1d_traversable()) <a name="l00482"></a>00482 detail::destruct_aux(img_view.begin().x(), img_view.end().x(), <a name="l00483"></a>00483 is_planar&lt;View&gt;()); <a name="l00484"></a>00484 <span class="keywordflow">else</span> <a name="l00485"></a>00485 <span class="keywordflow">for</span> (std::ptrdiff_t y=0; y&lt;img_view.height(); ++y) <a name="l00486"></a>00486 detail::destruct_aux(img_view.row_begin(y),img_view.row_end(y), <a name="l00487"></a>00487 is_planar&lt;View&gt;()); <a name="l00488"></a>00488 } <a name="l00489"></a>00489 <a name="l00495"></a>00495 <a name="l00499"></a>00499 <a name="l00500"></a>00500 <a name="l00501"></a>00501 <span class="keyword">namespace </span>detail { <a name="l00502"></a>00502 <a name="l00505"></a>00505 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> It, <span class="keyword">typename</span> P&gt; <a name="l00506"></a>00506 GIL_FORCEINLINE <a name="l00507"></a>00507 <span class="keywordtype">void</span> uninitialized_fill_aux(It first, It last, <a name="l00508"></a>00508 <span class="keyword">const</span> P&amp; p, mpl::true_) { <a name="l00509"></a>00509 <span class="keywordtype">int</span> channel=0; <a name="l00510"></a>00510 <span class="keywordflow">try</span> { <a name="l00511"></a>00511 <span class="keyword">typedef</span> <span class="keyword">typename</span> std::iterator_traits&lt;It&gt;::value_type pixel_t; <a name="l00512"></a>00512 <span class="keywordflow">while</span> (channel &lt; num_channels&lt;pixel_t&gt;::value) { <a name="l00513"></a>00513 std::uninitialized_fill(dynamic_at_c(first,channel), dynamic_at_c(last,channel), <a name="l00514"></a>00514 dynamic_at_c(p,channel)); <a name="l00515"></a>00515 ++channel; <a name="l00516"></a>00516 } <a name="l00517"></a>00517 } <span class="keywordflow">catch</span> (...) { <a name="l00518"></a>00518 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> c=0; c&lt;channel; ++c) <a name="l00519"></a>00519 destruct_range(dynamic_at_c(first,c), dynamic_at_c(last,c)); <a name="l00520"></a>00520 <span class="keywordflow">throw</span>; <a name="l00521"></a>00521 } <a name="l00522"></a>00522 } <a name="l00523"></a>00523 <a name="l00526"></a>00526 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> It, <span class="keyword">typename</span> P&gt; <a name="l00527"></a>00527 GIL_FORCEINLINE <a name="l00528"></a>00528 <span class="keywordtype">void</span> uninitialized_fill_aux(It first, It last, <a name="l00529"></a>00529 <span class="keyword">const</span> P&amp; p,mpl::false_) { <a name="l00530"></a>00530 std::uninitialized_fill(first,last,p); <a name="l00531"></a>00531 } <a name="l00532"></a>00532 <a name="l00533"></a>00533 } <span class="comment">// namespace detail</span> <a name="l00534"></a>00534 <a name="l00539"></a>00539 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View, <span class="keyword">typename</span> Value&gt; <a name="l00540"></a><a class="code" href="g_i_l_0156.html#g4f5edbc3fe6b776c6aa1939902333cf3">00540</a> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0156.html#g4f5edbc3fe6b776c6aa1939902333cf3" title="std::uninitialized_fill for image views. Does not support planar heterogeneous views...">uninitialized_fill_pixels</a>(<span class="keyword">const</span> View&amp; img