xref: /aoo41x/main/basebmp/inc/basebmp/fillimage.hxx (revision 48cdb363)
1*48cdb363SAndrew Rist /**************************************************************
2cdf0e10cSrcweir  *
3*48cdb363SAndrew Rist  * Licensed to the Apache Software Foundation (ASF) under one
4*48cdb363SAndrew Rist  * or more contributor license agreements.  See the NOTICE file
5*48cdb363SAndrew Rist  * distributed with this work for additional information
6*48cdb363SAndrew Rist  * regarding copyright ownership.  The ASF licenses this file
7*48cdb363SAndrew Rist  * to you under the Apache License, Version 2.0 (the
8*48cdb363SAndrew Rist  * "License"); you may not use this file except in compliance
9*48cdb363SAndrew Rist  * with the License.  You may obtain a copy of the License at
10*48cdb363SAndrew Rist  *
11*48cdb363SAndrew Rist  *   http://www.apache.org/licenses/LICENSE-2.0
12*48cdb363SAndrew Rist  *
13*48cdb363SAndrew Rist  * Unless required by applicable law or agreed to in writing,
14*48cdb363SAndrew Rist  * software distributed under the License is distributed on an
15*48cdb363SAndrew Rist  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16*48cdb363SAndrew Rist  * KIND, either express or implied.  See the License for the
17*48cdb363SAndrew Rist  * specific language governing permissions and limitations
18*48cdb363SAndrew Rist  * under the License.
19*48cdb363SAndrew Rist  *
20*48cdb363SAndrew Rist  *************************************************************/
21*48cdb363SAndrew Rist 
22*48cdb363SAndrew Rist 
23cdf0e10cSrcweir 
24cdf0e10cSrcweir #ifndef INCLUDED_BASEBMP_FILLIMAGE_HXX
25cdf0e10cSrcweir #define INCLUDED_BASEBMP_FILLIMAGE_HXX
26cdf0e10cSrcweir 
27cdf0e10cSrcweir #include <vigra/tuple.hxx>
28cdf0e10cSrcweir #include <vigra/iteratortraits.hxx>
29cdf0e10cSrcweir 
30cdf0e10cSrcweir namespace basebmp
31cdf0e10cSrcweir {
32cdf0e10cSrcweir 
33cdf0e10cSrcweir template< class DestIterator, class DestAccessor, typename T >
fillImage(DestIterator begin,DestIterator end,DestAccessor ad,T fillVal)34cdf0e10cSrcweir void fillImage( DestIterator begin,
35cdf0e10cSrcweir                 DestIterator end,
36cdf0e10cSrcweir                 DestAccessor ad,
37cdf0e10cSrcweir                 T            fillVal )
38cdf0e10cSrcweir {
39cdf0e10cSrcweir     const int width ( end.x - begin.x );
40cdf0e10cSrcweir     const int height( end.y - begin.y );
41cdf0e10cSrcweir 
42cdf0e10cSrcweir     for( int y=0; y<height; ++y, ++begin.y )
43cdf0e10cSrcweir     {
44cdf0e10cSrcweir         typename vigra::IteratorTraits<DestIterator>::row_iterator
45cdf0e10cSrcweir             rowIter( begin.rowIterator() );
46cdf0e10cSrcweir         const typename vigra::IteratorTraits<DestIterator>::row_iterator
47cdf0e10cSrcweir             rowEnd( rowIter + width );
48cdf0e10cSrcweir 
49cdf0e10cSrcweir         // TODO(P2): Provide specialized span fill methods on the
50cdf0e10cSrcweir         // iterator/accessor
51cdf0e10cSrcweir         while( rowIter != rowEnd )
52cdf0e10cSrcweir             ad.set(fillVal, rowIter++);
53cdf0e10cSrcweir     }
54cdf0e10cSrcweir }
55cdf0e10cSrcweir 
56cdf0e10cSrcweir template< class DestIterator, class DestAccessor, typename T >
fillImage(vigra::triple<DestIterator,DestIterator,DestAccessor> const & src,T fillVal)57cdf0e10cSrcweir inline void fillImage( vigra::triple<DestIterator,DestIterator,DestAccessor> const& src,
58cdf0e10cSrcweir                        T                                                            fillVal )
59cdf0e10cSrcweir {
60cdf0e10cSrcweir     fillImage(src.first,src.second,src.third,fillVal);
61cdf0e10cSrcweir }
62cdf0e10cSrcweir 
63cdf0e10cSrcweir } // namespace basebmp
64cdf0e10cSrcweir 
65cdf0e10cSrcweir #endif /* INCLUDED_BASEBMP_FILLIMAGE_HXX */
66