File: g_i_l_0001.html

package info (click to toggle)
boost1.55 1.55.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 487,824 kB
  • ctags: 673,349
  • sloc: cpp: 2,098,430; xml: 106,036; ansic: 46,744; python: 32,427; sh: 11,864; cs: 2,121; asm: 1,640; makefile: 984; perl: 714; yacc: 456; php: 132; fortran: 43; sql: 13; csh: 6
file content (834 lines) | stat: -rw-r--r-- 91,140 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
<!-- 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_view, <span class="keyword">const</span> Value&amp; val) {
<a name="l00541"></a>00541     <span class="keywordflow">if</span> (img_view.is_1d_traversable()) 
<a name="l00542"></a>00542         detail::uninitialized_fill_aux(img_view.begin().x(), img_view.end().x(), 
<a name="l00543"></a>00543                                        val,is_planar&lt;View&gt;());
<a name="l00544"></a>00544     <span class="keywordflow">else</span> {
<a name="l00545"></a>00545         <span class="keyword">typename</span> View::y_coord_t y;
<a name="l00546"></a>00546         <span class="keywordflow">try</span> {
<a name="l00547"></a>00547             <span class="keywordflow">for</span> (y=0; y&lt;img_view.height(); ++y)
<a name="l00548"></a>00548                 detail::uninitialized_fill_aux(img_view.row_begin(y),img_view.row_end(y),
<a name="l00549"></a>00549                                                val,is_planar&lt;View&gt;());
<a name="l00550"></a>00550         } <span class="keywordflow">catch</span>(...) {
<a name="l00551"></a>00551             <span class="keywordflow">for</span> (<span class="keyword">typename</span> View::y_coord_t y0=0; y0&lt;y; ++y0)
<a name="l00552"></a>00552                 detail::destruct_aux(img_view.row_begin(y0),img_view.row_end(y0), is_planar&lt;View&gt;());
<a name="l00553"></a>00553             <span class="keywordflow">throw</span>;
<a name="l00554"></a>00554         }
<a name="l00555"></a>00555     }
<a name="l00556"></a>00556 }
<a name="l00557"></a>00557 
<a name="l00563"></a>00563 
<a name="l00567"></a>00567 
<a name="l00568"></a>00568 <span class="keyword">namespace </span>detail {
<a name="l00569"></a>00569 
<a name="l00570"></a>00570 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> It&gt; GIL_FORCEINLINE 
<a name="l00571"></a>00571 <span class="keywordtype">void</span> default_construct_range_impl(It first, It last, mpl::true_) {
<a name="l00572"></a>00572     <span class="keyword">typedef</span> <span class="keyword">typename</span> std::iterator_traits&lt;It&gt;::value_type value_t;
<a name="l00573"></a>00573     It first1=first;
<a name="l00574"></a>00574     <span class="keywordflow">try</span> {
<a name="l00575"></a>00575         <span class="keywordflow">while</span> (first!=last) {
<a name="l00576"></a>00576             <span class="keyword">new</span> (first) value_t();
<a name="l00577"></a>00577             ++first;
<a name="l00578"></a>00578         }
<a name="l00579"></a>00579     } <span class="keywordflow">catch</span> (...) {
<a name="l00580"></a>00580         destruct_range(first1,first);
<a name="l00581"></a>00581         <span class="keywordflow">throw</span>;
<a name="l00582"></a>00582     }
<a name="l00583"></a>00583 }
<a name="l00584"></a>00584 
<a name="l00585"></a>00585 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> It&gt; GIL_FORCEINLINE 
<a name="l00586"></a>00586 <span class="keywordtype">void</span> default_construct_range_impl(It first, It last, mpl::false_) {}
<a name="l00587"></a>00587 
<a name="l00588"></a>00588 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> It&gt; GIL_FORCEINLINE 
<a name="l00589"></a>00589 <span class="keywordtype">void</span> default_construct_range(It first, It last) { default_construct_range_impl(first, last, <span class="keyword">typename</span> is_pointer&lt;It&gt;::type()); }
<a name="l00590"></a>00590 
<a name="l00592"></a>00592 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> It&gt;
<a name="l00593"></a>00593 GIL_FORCEINLINE 
<a name="l00594"></a>00594 <span class="keywordtype">void</span> default_construct_aux(It first, It last, mpl::true_) {
<a name="l00595"></a>00595     <span class="keywordtype">int</span> channel=0;
<a name="l00596"></a>00596     <span class="keywordflow">try</span> {
<a name="l00597"></a>00597         <span class="keyword">typedef</span> <span class="keyword">typename</span> std::iterator_traits&lt;It&gt;::value_type pixel_t;
<a name="l00598"></a>00598         <span class="keywordflow">while</span> (channel &lt; num_channels&lt;pixel_t&gt;::value) {
<a name="l00599"></a>00599             default_construct_range(dynamic_at_c(first,channel), dynamic_at_c(last,channel));
<a name="l00600"></a>00600             ++channel;
<a name="l00601"></a>00601         }
<a name="l00602"></a>00602     } <span class="keywordflow">catch</span> (...) {
<a name="l00603"></a>00603         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> c=0; c&lt;channel; ++c)
<a name="l00604"></a>00604             destruct_range(dynamic_at_c(first,c), dynamic_at_c(last,c));
<a name="l00605"></a>00605         <span class="keywordflow">throw</span>;
<a name="l00606"></a>00606     }
<a name="l00607"></a>00607 }
<a name="l00608"></a>00608 
<a name="l00610"></a>00610 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> It&gt;
<a name="l00611"></a>00611 GIL_FORCEINLINE 
<a name="l00612"></a>00612 <span class="keywordtype">void</span> default_construct_aux(It first, It last, mpl::false_) {
<a name="l00613"></a>00613     default_construct_range(first,last);
<a name="l00614"></a>00614 }
<a name="l00615"></a>00615 
<a name="l00616"></a>00616 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View, <span class="keywordtype">bool</span> IsPlanar&gt;
<a name="l00617"></a>00617 <span class="keyword">struct </span>has_trivial_pixel_constructor : <span class="keyword">public</span> boost::has_trivial_constructor&lt;typename View::value_type&gt; {};
<a name="l00618"></a>00618 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt;
<a name="l00619"></a>00619 <span class="keyword">struct </span>has_trivial_pixel_constructor&lt;View, true&gt; : <span class="keyword">public</span> boost::has_trivial_constructor&lt;typename channel_type&lt;View&gt;::type&gt; {};
<a name="l00620"></a>00620 
<a name="l00621"></a>00621 } <span class="comment">// namespace detail</span>
<a name="l00622"></a>00622 
<a name="l00627"></a>00627 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View&gt; 
<a name="l00628"></a><a class="code" href="g_i_l_0146.html#g523e1cfd5c8023f14055cb52489431c8">00628</a> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0146.html#g523e1cfd5c8023f14055cb52489431c8" title="Invokes the in-place default constructor on every pixel of the (uninitialized) view...">default_construct_pixels</a>(<span class="keyword">const</span> View&amp; img_view) {
<a name="l00629"></a>00629     <span class="keywordflow">if</span> (detail::has_trivial_pixel_constructor&lt;View, is_planar&lt;View&gt;::value&gt;::value)
<a name="l00630"></a>00630         <span class="keywordflow">return</span>;
<a name="l00631"></a>00631 
<a name="l00632"></a>00632     <span class="keywordflow">if</span> (img_view.is_1d_traversable()) 
<a name="l00633"></a>00633         detail::default_construct_aux(img_view.begin().x(), img_view.end().x(), is_planar&lt;View&gt;());
<a name="l00634"></a>00634     <span class="keywordflow">else</span> {
<a name="l00635"></a>00635         <span class="keyword">typename</span> View::y_coord_t y;
<a name="l00636"></a>00636         <span class="keywordflow">try</span> {
<a name="l00637"></a>00637             <span class="keywordflow">for</span> (y=0; y&lt;img_view.height(); ++y)
<a name="l00638"></a>00638                 detail::default_construct_aux(img_view.row_begin(y),img_view.row_end(y), is_planar&lt;View&gt;());
<a name="l00639"></a>00639         } <span class="keywordflow">catch</span>(...) {
<a name="l00640"></a>00640             <span class="keywordflow">for</span> (<span class="keyword">typename</span> View::y_coord_t y0=0; y0&lt;y; ++y0)
<a name="l00641"></a>00641                 detail::destruct_aux(img_view.row_begin(y0),img_view.row_end(y0), is_planar&lt;View&gt;());
<a name="l00642"></a>00642             <span class="keywordflow">throw</span>;
<a name="l00643"></a>00643         }
<a name="l00644"></a>00644     }
<a name="l00645"></a>00645 }
<a name="l00646"></a>00646 
<a name="l00647"></a>00647 
<a name="l00653"></a>00653 
<a name="l00657"></a>00657 
<a name="l00658"></a>00658 <span class="keyword">namespace </span>detail {
<a name="l00659"></a>00659 
<a name="l00661"></a>00661 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> It1, <span class="keyword">typename</span> It2&gt;
<a name="l00662"></a>00662 GIL_FORCEINLINE 
<a name="l00663"></a>00663 <span class="keywordtype">void</span> uninitialized_copy_aux(It1 first1, It1 last1,
<a name="l00664"></a>00664                             It2 first2, mpl::true_) {
<a name="l00665"></a>00665     <span class="keywordtype">int</span> channel=0;
<a name="l00666"></a>00666     <span class="keywordflow">try</span> {
<a name="l00667"></a>00667         <span class="keyword">typedef</span> <span class="keyword">typename</span> std::iterator_traits&lt;It1&gt;::value_type pixel_t;
<a name="l00668"></a>00668         <span class="keywordflow">while</span> (channel &lt; num_channels&lt;pixel_t&gt;::value) {
<a name="l00669"></a>00669             std::uninitialized_copy(dynamic_at_c(first1,channel), dynamic_at_c(last1,channel), dynamic_at_c(first2,channel));
<a name="l00670"></a>00670             ++channel;
<a name="l00671"></a>00671         }
<a name="l00672"></a>00672     } <span class="keywordflow">catch</span> (...) {
<a name="l00673"></a>00673         It2 last2=first2;
<a name="l00674"></a>00674         std::advance(last2, std::distance(first1,last1));
<a name="l00675"></a>00675         <span class="keywordflow">for</span> (<span class="keywordtype">int</span> c=0; c&lt;channel; ++c)
<a name="l00676"></a>00676             destruct_range(dynamic_at_c(first2,c), dynamic_at_c(last2,c));
<a name="l00677"></a>00677         <span class="keywordflow">throw</span>;
<a name="l00678"></a>00678     }
<a name="l00679"></a>00679 }
<a name="l00681"></a>00681 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> It1, <span class="keyword">typename</span> It2&gt;
<a name="l00682"></a>00682 GIL_FORCEINLINE 
<a name="l00683"></a>00683 <span class="keywordtype">void</span> uninitialized_copy_aux(It1 first1, It1 last1,
<a name="l00684"></a>00684                             It2 first2,mpl::false_) {
<a name="l00685"></a>00685     std::uninitialized_copy(first1,last1,first2);
<a name="l00686"></a>00686 }
<a name="l00687"></a>00687 } <span class="comment">// namespace detail</span>
<a name="l00688"></a>00688 
<a name="l00693"></a>00693 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View1, <span class="keyword">typename</span> View2&gt; 
<a name="l00694"></a><a class="code" href="g_i_l_0155.html#ge33d703beb3b085809b3b3ca64cc8906">00694</a> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0155.html#ge33d703beb3b085809b3b3ca64cc8906" title="std::uninitialized_copy for image views. Does not support planar heterogeneous views...">uninitialized_copy_pixels</a>(<span class="keyword">const</span> View1&amp; view1, <span class="keyword">const</span> View2&amp; view2) {
<a name="l00695"></a>00695     <span class="keyword">typedef</span> mpl::bool_&lt;is_planar&lt;View1&gt;::value &amp;&amp; is_planar&lt;View2&gt;::value&gt; is_planar;  
<a name="l00696"></a>00696     assert(view1.dimensions()==view2.dimensions());
<a name="l00697"></a>00697     <span class="keywordflow">if</span> (view1.is_1d_traversable() &amp;&amp; view2.is_1d_traversable())
<a name="l00698"></a>00698         detail::uninitialized_copy_aux(view1.begin().x(), view1.end().x(), 
<a name="l00699"></a>00699                                        view2.begin().x(), 
<a name="l00700"></a>00700                                        is_planar());
<a name="l00701"></a>00701     <span class="keywordflow">else</span> {
<a name="l00702"></a>00702         <span class="keyword">typename</span> View1::y_coord_t y;
<a name="l00703"></a>00703         <span class="keywordflow">try</span> {
<a name="l00704"></a>00704             <span class="keywordflow">for</span> (y=0; y&lt;view1.height(); ++y)
<a name="l00705"></a>00705                 detail::uninitialized_copy_aux(view1.row_begin(y), view1.row_end(y),
<a name="l00706"></a>00706                                                view2.row_begin(y),
<a name="l00707"></a>00707                                                is_planar());
<a name="l00708"></a>00708         } <span class="keywordflow">catch</span>(...) {
<a name="l00709"></a>00709             <span class="keywordflow">for</span> (<span class="keyword">typename</span> View1::y_coord_t y0=0; y0&lt;y; ++y0)
<a name="l00710"></a>00710                 detail::destruct_aux(view2.row_begin(y0),view2.row_end(y0), is_planar());
<a name="l00711"></a>00711             <span class="keywordflow">throw</span>;
<a name="l00712"></a>00712         }
<a name="l00713"></a>00713     }
<a name="l00714"></a>00714 }
<a name="l00715"></a>00715 
<a name="l00721"></a>00721 
<a name="l00730"></a>00730 
<a name="l00732"></a>00732 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> V, <span class="keyword">typename</span> F&gt;
<a name="l00733"></a>00733 F for_each_pixel(<span class="keyword">const</span> V&amp; img, F fun) {
<a name="l00734"></a>00734     <span class="keywordflow">if</span> (img.is_1d_traversable()) {
<a name="l00735"></a>00735         <span class="keywordflow">return</span> std::for_each(img.begin().x(), img.end().x(), fun);
<a name="l00736"></a>00736     } <span class="keywordflow">else</span> {
<a name="l00737"></a>00737         <span class="keywordflow">for</span> (std::ptrdiff_t y=0; y&lt;img.height(); ++y)
<a name="l00738"></a>00738             fun = std::for_each(img.row_begin(y),img.row_end(y),fun);
<a name="l00739"></a>00739         <span class="keywordflow">return</span> fun;
<a name="l00740"></a>00740     }
<a name="l00741"></a>00741 }
<a name="l00742"></a>00742 
<a name="l00746"></a>00746 
<a name="l00748"></a>00748 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View, <span class="keyword">typename</span> F&gt;
<a name="l00749"></a>00749 F for_each_pixel_position(<span class="keyword">const</span> View&amp; img, F fun) {
<a name="l00750"></a>00750     <span class="keyword">typename</span> View::xy_locator loc=img.xy_at(0,0);
<a name="l00751"></a>00751     <span class="keywordflow">for</span> (std::ptrdiff_t y=0; y&lt;img.height(); ++y) {
<a name="l00752"></a>00752         <span class="keywordflow">for</span> (std::ptrdiff_t x=0; x&lt;img.width(); ++x, ++loc.x())
<a name="l00753"></a>00753             fun(loc);
<a name="l00754"></a>00754         loc.x()-=img.width(); ++loc.y();
<a name="l00755"></a>00755     }
<a name="l00756"></a>00756     <span class="keywordflow">return</span> fun;
<a name="l00757"></a>00757 }
<a name="l00758"></a>00758 
<a name="l00759"></a>00759 
<a name="l00765"></a>00765 
<a name="l00769"></a>00769 
<a name="l00772"></a>00772 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View, <span class="keyword">typename</span> F&gt;
<a name="l00773"></a><a class="code" href="g_i_l_0152.html#gdce3525a9aa4794ba807cfb8c0100d2f">00773</a> <span class="keywordtype">void</span> <a class="code" href="g_i_l_0152.html#gdce3525a9aa4794ba807cfb8c0100d2f" title="std::generate for image views">generate_pixels</a>(<span class="keyword">const</span> View&amp; v, F fun) {
<a name="l00774"></a>00774     <span class="keywordflow">if</span> (v.is_1d_traversable()) {
<a name="l00775"></a>00775         std::generate(v.begin().x(), v.end().x(), fun);
<a name="l00776"></a>00776     } <span class="keywordflow">else</span> {
<a name="l00777"></a>00777         <span class="keywordflow">for</span> (std::ptrdiff_t y=0; y&lt;v.height(); ++y)
<a name="l00778"></a>00778             std::generate(v.row_begin(y),v.row_end(y),fun);
<a name="l00779"></a>00779     }
<a name="l00780"></a>00780 }
<a name="l00781"></a>00781 
<a name="l00787"></a>00787 
<a name="l00791"></a>00791 
<a name="l00792"></a>00792 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> I1, <span class="keyword">typename</span> I2&gt; GIL_FORCEINLINE <span class="keywordtype">bool</span> equal_n(I1 i1, std::ptrdiff_t n, I2 i2);
<a name="l00793"></a>00793 
<a name="l00794"></a>00794 <span class="keyword">namespace </span>detail {
<a name="l00795"></a>00795 
<a name="l00796"></a>00796 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> I1, <span class="keyword">typename</span> I2&gt;
<a name="l00797"></a>00797 <span class="keyword">struct </span>equal_n_fn {
<a name="l00798"></a>00798     GIL_FORCEINLINE <span class="keywordtype">bool</span> operator()(I1 i1, std::ptrdiff_t n, I2 i2)<span class="keyword"> const </span>{ <span class="keywordflow">return</span> <a class="code" href="g_i_l_0214.html#g4ed3cf71cb0fbf435d1389df8567a4e5" title="std::equal(I1,I1,I2) with I1 and I2 being a iterator_from_2d">std::equal</a>(i1,i1+n, i2); }
<a name="l00799"></a>00799 };
<a name="l00800"></a>00800 
<a name="l00803"></a>00803 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T, <span class="keyword">typename</span> Cs&gt;
<a name="l00804"></a><a class="code" href="g_i_l_0494.html">00804</a> <span class="keyword">struct </span>equal_n_fn&lt;const <a class="code" href="g_i_l_0599.html" title="Represents a pixel value (a container of channels). Models: HomogeneousColorBaseValueConcept...">pixel</a>&lt;T,Cs&gt;*, <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...">pixel&lt;T,Cs&gt;</a>*&gt; {
<a name="l00805"></a>00805     GIL_FORCEINLINE <span class="keywordtype">bool</span> operator()(<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...">pixel&lt;T,Cs&gt;</a>* i1, std::ptrdiff_t n, <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...">pixel&lt;T,Cs&gt;</a>* i2)<span class="keyword"> const </span>{ 
<a name="l00806"></a>00806         <span class="keywordflow">return</span> memcmp(i1, i2, n*<span class="keyword">sizeof</span>(<a class="code" href="g_i_l_0599.html" title="Represents a pixel value (a container of channels). Models: HomogeneousColorBaseValueConcept...">pixel&lt;T,Cs&gt;</a>))==0;
<a name="l00807"></a>00807     }
<a name="l00808"></a>00808 };
<a name="l00809"></a>00809 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> T, <span class="keyword">typename</span> Cs&gt;
<a name="l00810"></a>00810 <span class="keyword">struct </span>equal_n_fn&lt;<a class="code" href="g_i_l_0599.html" title="Represents a pixel value (a container of channels). Models: HomogeneousColorBaseValueConcept...">pixel</a>&lt;T,Cs&gt;*, <a class="code" href="g_i_l_0599.html" title="Represents a pixel value (a container of channels). Models: HomogeneousColorBaseValueConcept...">pixel&lt;T,Cs&gt;</a>*&gt; : equal_n_fn&lt;const pixel&lt;T,Cs&gt;*, <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...">pixel&lt;T,Cs&gt;</a>*&gt; {};
<a name="l00811"></a>00811 
<a name="l00815"></a>00815 <span class="keyword">template</span>&lt;<span class="keyword">typename</span> IC, <span class="keyword">typename</span> Cs&gt;
<a name="l00816"></a><a class="code" href="g_i_l_0496.html">00816</a> <span class="keyword">struct </span>equal_n_fn&lt;<a class="code" href="g_i_l_0609.html" title="An iterator over planar pixels. Models HomogeneousColorBaseConcept, PixelIteratorConcept...">planar_pixel_iterator</a>&lt;IC,Cs&gt;, <a class="code" href="g_i_l_0609.html" title="An iterator over planar pixels. Models HomogeneousColorBaseConcept, PixelIteratorConcept...">planar_pixel_iterator</a>&lt;IC,Cs&gt; &gt; {
<a name="l00817"></a>00817     GIL_FORCEINLINE <span class="keywordtype">bool</span> operator()(<span class="keyword">const</span> <a class="code" href="g_i_l_0609.html" title="An iterator over planar pixels. Models HomogeneousColorBaseConcept, PixelIteratorConcept...">planar_pixel_iterator&lt;IC,Cs&gt;</a> i1, std::ptrdiff_t n, <span class="keyword">const</span> <a class="code" href="g_i_l_0609.html" title="An iterator over planar pixels. Models HomogeneousColorBaseConcept, PixelIteratorConcept...">planar_pixel_iterator&lt;IC,Cs&gt;</a> i2)<span class="keyword"> const </span>{ 
<a name="l00818"></a>00818         ptrdiff_t numBytes=n*<span class="keyword">sizeof</span>(<span class="keyword">typename</span> std::iterator_traits&lt;IC&gt;::value_type);
<a name="l00819"></a>00819 
<a name="l00820"></a>00820         <span class="keywordflow">for</span> (std::ptrdiff_t i=0; i&lt;mpl::size&lt;Cs&gt;::value; ++i)
<a name="l00821"></a>00821             <span class="keywordflow">if</span> (memcmp(dynamic_at_c(i1,i), dynamic_at_c(i2,i), numBytes)!=0)
<a name="l00822"></a>00822                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00823"></a>00823         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00824"></a>00824     }
<a name="l00825"></a>00825 };
<a name="l00826"></a>00826 
<a name="l00827"></a>00827 
<a name="l00829"></a>00829 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Loc, <span class="keyword">typename</span> I2&gt;  <span class="comment">// IL Models ConstPixelLocatorConcept, O Models PixelIteratorConcept</span>
<a name="l00830"></a><a class="code" href="g_i_l_0493.html">00830</a> <span class="keyword">struct </span>equal_n_fn&lt;boost::gil::<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;Loc&gt;,I2&gt; {
<a name="l00831"></a>00831     GIL_FORCEINLINE <span class="keywordtype">bool</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...">boost::gil::iterator_from_2d&lt;Loc&gt;</a> i1, std::ptrdiff_t n, I2 i2)<span class="keyword"> const </span>{
<a name="l00832"></a>00832         gil_function_requires&lt;boost::gil::PixelLocatorConcept&lt;Loc&gt; &gt;();
<a name="l00833"></a>00833         gil_function_requires&lt;boost::gil::PixelIteratorConcept&lt;I2&gt; &gt;();
<a name="l00834"></a>00834         <span class="keywordflow">while</span> (n&gt;0) {
<a name="l00835"></a>00835             std::ptrdiff_t num=std::min&lt;const std::ptrdiff_t&gt;(n, i1.<a class="code" href="g_i_l_0042.html#379c24f2d0a75769afc06dff7b569b8f">width</a>()-i1.<a class="code" href="g_i_l_0042.html#cb3204f0b17472894a99939821d597be">x_pos</a>());
<a name="l00836"></a>00836             <span class="keywordflow">if</span> (!equal_n(i1.<a class="code" href="g_i_l_0042.html#72169bdc650ac7eda288398e4ce1d7f8">x</a>(), num, i2))
<a name="l00837"></a>00837                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00838"></a>00838             i1+=num;
<a name="l00839"></a>00839             i2+=num;
<a name="l00840"></a>00840             n-=num;
<a name="l00841"></a>00841         }
<a name="l00842"></a>00842         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00843"></a>00843     }
<a name="l00844"></a>00844 };
<a name="l00845"></a>00845 
<a name="l00847"></a>00847 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> I1, <span class="keyword">typename</span> Loc&gt; <span class="comment">// I Models PixelIteratorConcept, OL Models PixelLocatorConcept</span>
<a name="l00848"></a><a class="code" href="g_i_l_0489.html">00848</a> <span class="keyword">struct </span>equal_n_fn&lt;I1,boost::gil::<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;Loc&gt; &gt; {
<a name="l00849"></a>00849     GIL_FORCEINLINE <span class="keywordtype">bool</span> operator()(I1 i1, std::ptrdiff_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...">boost::gil::iterator_from_2d&lt;Loc&gt;</a> i2)<span class="keyword"> const </span>{
<a name="l00850"></a>00850         gil_function_requires&lt;boost::gil::PixelIteratorConcept&lt;I1&gt; &gt;();
<a name="l00851"></a>00851         gil_function_requires&lt;boost::gil::PixelLocatorConcept&lt;Loc&gt; &gt;();
<a name="l00852"></a>00852         <span class="keywordflow">while</span> (n&gt;0) {
<a name="l00853"></a>00853             std::ptrdiff_t num=std::min&lt;const std::ptrdiff_t&gt;(n,i2.<a class="code" href="g_i_l_0042.html#379c24f2d0a75769afc06dff7b569b8f">width</a>()-i2.<a class="code" href="g_i_l_0042.html#cb3204f0b17472894a99939821d597be">x_pos</a>());
<a name="l00854"></a>00854             <span class="keywordflow">if</span> (!equal_n(i1, num, i2.<a class="code" href="g_i_l_0042.html#72169bdc650ac7eda288398e4ce1d7f8">x</a>()))
<a name="l00855"></a>00855                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00856"></a>00856             i1+=num;
<a name="l00857"></a>00857             i2+=num;
<a name="l00858"></a>00858             n-=num;
<a name="l00859"></a>00859         }
<a name="l00860"></a>00860         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00861"></a>00861     }
<a name="l00862"></a>00862 };
<a name="l00863"></a>00863 
<a name="l00865"></a>00865 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Loc1, <span class="keyword">typename</span> Loc2&gt;
<a name="l00866"></a><a class="code" href="g_i_l_0490.html">00866</a> <span class="keyword">struct </span>equal_n_fn&lt;boost::gil::<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;Loc1&gt;,boost::gil::<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;Loc2&gt; &gt; {
<a name="l00867"></a>00867    GIL_FORCEINLINE <span class="keywordtype">bool</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...">boost::gil::iterator_from_2d&lt;Loc1&gt;</a> i1, std::ptrdiff_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...">boost::gil::iterator_from_2d&lt;Loc2&gt;</a> i2)<span class="keyword"> const </span>{
<a name="l00868"></a>00868         gil_function_requires&lt;boost::gil::PixelLocatorConcept&lt;Loc1&gt; &gt;();
<a name="l00869"></a>00869         gil_function_requires&lt;boost::gil::PixelLocatorConcept&lt;Loc2&gt; &gt;();
<a name="l00870"></a>00870         <span class="keywordflow">if</span> (i1.<a class="code" href="g_i_l_0042.html#cb3204f0b17472894a99939821d597be">x_pos</a>()!=i2.<a class="code" href="g_i_l_0042.html#cb3204f0b17472894a99939821d597be">x_pos</a>() || i1.<a class="code" href="g_i_l_0042.html#379c24f2d0a75769afc06dff7b569b8f">width</a>()!=i2.<a class="code" href="g_i_l_0042.html#379c24f2d0a75769afc06dff7b569b8f">width</a>()) {
<a name="l00871"></a>00871             <span class="keywordflow">while</span>(n--&gt;0) {
<a name="l00872"></a>00872                 <span class="keywordflow">if</span> (*i1++!=*i2++) <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00873"></a>00873             }
<a name="l00874"></a>00874         }
<a name="l00875"></a>00875         <span class="keywordflow">while</span> (n&gt;0) {
<a name="l00876"></a>00876             std::ptrdiff_t num=std::min&lt;const std::ptrdiff_t&gt;(n,i2.<a class="code" href="g_i_l_0042.html#379c24f2d0a75769afc06dff7b569b8f">width</a>()-i2.<a class="code" href="g_i_l_0042.html#cb3204f0b17472894a99939821d597be">x_pos</a>());
<a name="l00877"></a>00877             <span class="keywordflow">if</span> (!equal_n(i1.<a class="code" href="g_i_l_0042.html#72169bdc650ac7eda288398e4ce1d7f8">x</a>(), num, i2.<a class="code" href="g_i_l_0042.html#72169bdc650ac7eda288398e4ce1d7f8">x</a>()))
<a name="l00878"></a>00878                 <span class="keywordflow">return</span> <span class="keyword">false</span>;
<a name="l00879"></a>00879             i1+=num;
<a name="l00880"></a>00880             i2+=num;
<a name="l00881"></a>00881             n-=num;
<a name="l00882"></a>00882         }
<a name="l00883"></a>00883         <span class="keywordflow">return</span> <span class="keyword">true</span>;
<a name="l00884"></a>00884     }
<a name="l00885"></a>00885 };
<a name="l00886"></a>00886 } <span class="comment">// namespace detail</span>
<a name="l00887"></a>00887 
<a name="l00888"></a>00888 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> I1, <span class="keyword">typename</span> I2&gt; GIL_FORCEINLINE
<a name="l00889"></a>00889 <span class="keywordtype">bool</span> equal_n(I1 i1, std::ptrdiff_t n, I2 i2) {
<a name="l00890"></a>00890     <span class="keywordflow">return</span> detail::equal_n_fn&lt;I1,I2&gt;()(i1,n,i2);
<a name="l00891"></a>00891 }
<a name="l00892"></a>00892 } }  <span class="comment">// namespace boost::gil</span>
<a name="l00893"></a>00893 
<a name="l00894"></a>00894 <span class="keyword">namespace </span>std {
<a name="l00906"></a>00906 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> Loc1, <span class="keyword">typename</span> Loc2&gt; GIL_FORCEINLINE 
<a name="l00907"></a><a class="code" href="g_i_l_0214.html#g4ed3cf71cb0fbf435d1389df8567a4e5">00907</a> <span class="keywordtype">bool</span> <a class="code" href="g_i_l_0214.html#g4ed3cf71cb0fbf435d1389df8567a4e5" title="std::equal(I1,I1,I2) with I1 and I2 being a iterator_from_2d">equal</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;Loc1&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;Loc1&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;Loc2&gt;</a> first2) {
<a name="l00908"></a>00908     boost::gil::gil_function_requires&lt;boost::gil::PixelLocatorConcept&lt;Loc1&gt; &gt;();
<a name="l00909"></a>00909     boost::gil::gil_function_requires&lt;boost::gil::PixelLocatorConcept&lt;Loc2&gt; &gt;();
<a name="l00910"></a>00910     std::ptrdiff_t n=last-first;
<a name="l00911"></a>00911     <span class="keywordflow">if</span> (first.is_1d_traversable()) {
<a name="l00912"></a>00912         <span class="keywordflow">if</span> (first2.<a class="code" href="g_i_l_0042.html#90ccf75aa2deb01fbce509842191cad2">is_1d_traversable</a>())
<a name="l00913"></a>00913             <span class="keywordflow">return</span> boost::gil::detail::equal_n_fn&lt;typename Loc1::x_iterator,typename Loc2::x_iterator&gt;()(first.x(),n, first2.<a class="code" href="g_i_l_0042.html#72169bdc650ac7eda288398e4ce1d7f8">x</a>());
<a name="l00914"></a>00914         <span class="keywordflow">else</span>
<a name="l00915"></a>00915             <span class="keywordflow">return</span> boost::gil::detail::equal_n_fn&lt;typename Loc1::x_iterator,boost::gil::iterator_from_2d&lt;Loc2&gt; &gt;()(first.x(),n, first2);
<a name="l00916"></a>00916     } <span class="keywordflow">else</span> {
<a name="l00917"></a>00917         <span class="keywordflow">if</span> (first2.<a class="code" href="g_i_l_0042.html#90ccf75aa2deb01fbce509842191cad2">is_1d_traversable</a>())
<a name="l00918"></a>00918             <span class="keywordflow">return</span> boost::gil::detail::equal_n_fn&lt;<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;Loc1&gt;</a>,<span class="keyword">typename</span> Loc2::x_iterator&gt;()(first,n, first2.<a class="code" href="g_i_l_0042.html#72169bdc650ac7eda288398e4ce1d7f8">x</a>());
<a name="l00919"></a>00919         <span class="keywordflow">else</span>
<a name="l00920"></a>00920             <span class="keywordflow">return</span> boost::gil::detail::equal_n_fn&lt;boost::gil::iterator_from_2d&lt;Loc1&gt;,<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;Loc2&gt;</a> &gt;()(first,n,first2);
<a name="l00921"></a>00921     }
<a name="l00922"></a>00922 }
<a name="l00923"></a>00923 } <span class="comment">// namespace std</span>
<a name="l00924"></a>00924 
<a name="l00925"></a>00925 <span class="keyword">namespace </span>boost { <span class="keyword">namespace </span>gil {
<a name="l00926"></a>00926 
<a name="l00929"></a>00929 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View1, <span class="keyword">typename</span> View2&gt; GIL_FORCEINLINE 
<a name="l00930"></a><a class="code" href="g_i_l_0148.html#g86a5d26dbacd64b2bc4f53b4b2971a73">00930</a> <span class="keywordtype">bool</span> <a class="code" href="g_i_l_0148.html#g86a5d26dbacd64b2bc4f53b4b2971a73" title="std::equal for image views">equal_pixels</a>(<span class="keyword">const</span> View1&amp; v1, <span class="keyword">const</span> View2&amp; v2) {
<a name="l00931"></a>00931     assert(v1.dimensions()==v2.dimensions());
<a name="l00932"></a>00932     <span class="keywordflow">return</span> <a class="code" href="g_i_l_0214.html#g4ed3cf71cb0fbf435d1389df8567a4e5" title="std::equal(I1,I1,I2) with I1 and I2 being a iterator_from_2d">std::equal</a>(v1.begin(),v1.end(),v2.begin()); <span class="comment">// std::equal has overloads with GIL iterators for optimal performance</span>
<a name="l00933"></a>00933 }
<a name="l00934"></a>00934 
<a name="l00940"></a>00940 
<a name="l00944"></a>00944 
<a name="l00947"></a>00947 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View1, <span class="keyword">typename</span> View2, <span class="keyword">typename</span> F&gt; GIL_FORCEINLINE 
<a name="l00948"></a><a class="code" href="g_i_l_0154.html#g27eed3931b4835e3757642ed41db0984">00948</a> F <a class="code" href="g_i_l_0154.html#gceacc4e2452d2b3adba5902b21c5957b" title="transform_pixels with two sources">transform_pixels</a>(<span class="keyword">const</span> View1&amp; src,<span class="keyword">const</span> View2&amp; dst, F fun) {
<a name="l00949"></a>00949     assert(src.dimensions()==dst.dimensions());
<a name="l00950"></a>00950     <span class="keywordflow">for</span> (std::ptrdiff_t y=0; y&lt;src.height(); ++y) {
<a name="l00951"></a>00951         <span class="keyword">typename</span> View1::x_iterator srcIt=src.row_begin(y);
<a name="l00952"></a>00952         <span class="keyword">typename</span> View2::x_iterator dstIt=dst.row_begin(y);
<a name="l00953"></a>00953         <span class="keywordflow">for</span> (std::ptrdiff_t x=0; x&lt;src.width(); ++x)
<a name="l00954"></a>00954             dstIt[x]=fun(srcIt[x]);
<a name="l00955"></a>00955     }
<a name="l00956"></a>00956     <span class="keywordflow">return</span> fun;
<a name="l00957"></a>00957 }
<a name="l00958"></a>00958 
<a name="l00961"></a>00961 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View1, <span class="keyword">typename</span> View2, <span class="keyword">typename</span> View3, <span class="keyword">typename</span> F&gt; GIL_FORCEINLINE 
<a name="l00962"></a><a class="code" href="g_i_l_0154.html#gceacc4e2452d2b3adba5902b21c5957b">00962</a> F <a class="code" href="g_i_l_0154.html#gceacc4e2452d2b3adba5902b21c5957b" title="transform_pixels with two sources">transform_pixels</a>(<span class="keyword">const</span> View1&amp; src1, <span class="keyword">const</span> View2&amp; src2,<span class="keyword">const</span> View3&amp; dst, F fun) {
<a name="l00963"></a>00963     <span class="keywordflow">for</span> (std::ptrdiff_t y=0; y&lt;dst.height(); ++y) {
<a name="l00964"></a>00964         <span class="keyword">typename</span> View1::x_iterator srcIt1=src1.row_begin(y);
<a name="l00965"></a>00965         <span class="keyword">typename</span> View2::x_iterator srcIt2=src2.row_begin(y);
<a name="l00966"></a>00966         <span class="keyword">typename</span> View3::x_iterator dstIt=dst.row_begin(y);
<a name="l00967"></a>00967         <span class="keywordflow">for</span> (std::ptrdiff_t x=0; x&lt;dst.width(); ++x)
<a name="l00968"></a>00968             dstIt[x]=fun(srcIt1[x],srcIt2[x]);
<a name="l00969"></a>00969     }
<a name="l00970"></a>00970     <span class="keywordflow">return</span> fun;
<a name="l00971"></a>00971 }
<a name="l00972"></a>00972 
<a name="l00976"></a>00976 
<a name="l00979"></a>00979 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View1, <span class="keyword">typename</span> View2, <span class="keyword">typename</span> F&gt; GIL_FORCEINLINE 
<a name="l00980"></a><a class="code" href="g_i_l_0153.html#gc74f3114086b954dfd1735a918f68389">00980</a> F <a class="code" href="g_i_l_0153.html#g1edf36f5d5c954f190235d362002e964" title="transform_pixel_positions with two sources">transform_pixel_positions</a>(<span class="keyword">const</span> View1&amp; src,<span class="keyword">const</span> View2&amp; dst, F fun) {
<a name="l00981"></a>00981     assert(src.dimensions()==dst.dimensions());
<a name="l00982"></a>00982     <span class="keyword">typename</span> View1::xy_locator loc=src.xy_at(0,0);
<a name="l00983"></a>00983     <span class="keywordflow">for</span> (std::ptrdiff_t y=0; y&lt;src.height(); ++y) {
<a name="l00984"></a>00984         <span class="keyword">typename</span> View2::x_iterator dstIt=dst.row_begin(y);
<a name="l00985"></a>00985         <span class="keywordflow">for</span> (std::ptrdiff_t x=0; x&lt;src.width(); ++x, ++loc.x())
<a name="l00986"></a>00986             dstIt[x]=fun(loc);
<a name="l00987"></a>00987         loc.x()-=src.width(); ++loc.y();
<a name="l00988"></a>00988     }
<a name="l00989"></a>00989     <span class="keywordflow">return</span> fun;
<a name="l00990"></a>00990 }
<a name="l00991"></a>00991 
<a name="l00994"></a>00994 <span class="keyword">template</span> &lt;<span class="keyword">typename</span> View1, <span class="keyword">typename</span> View2, <span class="keyword">typename</span> View3, <span class="keyword">typename</span> F&gt; GIL_FORCEINLINE 
<a name="l00995"></a><a class="code" href="g_i_l_0153.html#g1edf36f5d5c954f190235d362002e964">00995</a> F <a class="code" href="g_i_l_0153.html#g1edf36f5d5c954f190235d362002e964" title="transform_pixel_positions with two sources">transform_pixel_positions</a>(<span class="keyword">const</span> View1&amp; src1,<span class="keyword">const</span> View2&amp; src2,<span class="keyword">const</span> View3&amp; dst, F fun) {
<a name="l00996"></a>00996     assert(src1.dimensions()==dst.dimensions());
<a name="l00997"></a>00997     assert(src2.dimensions()==dst.dimensions());
<a name="l00998"></a>00998     <span class="keyword">typename</span> View1::xy_locator loc1=src1.xy_at(0,0);
<a name="l00999"></a>00999     <span class="keyword">typename</span> View2::xy_locator loc2=src2.xy_at(0,0);
<a name="l01000"></a>01000     <span class="keywordflow">for</span> (std::ptrdiff_t y=0; y&lt;src1.height(); ++y) {
<a name="l01001"></a>01001         <span class="keyword">typename</span> View3::x_iterator dstIt=dst.row_begin(y);
<a name="l01002"></a>01002         <span class="keywordflow">for</span> (std::ptrdiff_t x=0; x&lt;src1.width(); ++x, ++loc1.x(), ++loc2.x())
<a name="l01003"></a>01003             dstIt[x]=fun(loc1,loc2);
<a name="l01004"></a>01004         loc1.x()-=src1.width(); ++loc1.y();
<a name="l01005"></a>01005         loc2.x()-=src2.width(); ++loc2.y();
<a name="l01006"></a>01006     }
<a name="l01007"></a>01007     <span class="keywordflow">return</span> fun;
<a name="l01008"></a>01008 }
<a name="l01009"></a>01009 
<a name="l01010"></a>01010 } }  <span class="comment">// namespace boost::gil</span>
<a name="l01011"></a>01011 
<a name="l01012"></a>01012 <span class="comment">//#ifdef _MSC_VER</span>
<a name="l01013"></a>01013 <span class="comment">//#pragma warning(pop)</span>
<a name="l01014"></a>01014 <span class="comment">//#endif</span>
<a name="l01015"></a>01015 
<a name="l01016"></a>01016 <span class="preprocessor">#endif</span>
</pre></div></div>
<hr size="1"><address style="text-align: right;"><small>Generated on Sat May 2 13:50:13 2009 for Generic Image Library by&nbsp;
<a href="http://www.doxygen.org/index.html">
<img src="doxygen.png" alt="doxygen" align="middle" border="0"></a> 1.5.6 </small></address>
</body>
</html>