Line data Source code
1 : /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 : /*
3 : * This file is part of the LibreOffice project.
4 : *
5 : * This Source Code Form is subject to the terms of the Mozilla Public
6 : * License, v. 2.0. If a copy of the MPL was not distributed with this
7 : * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 : *
9 : * This file incorporates work covered by the following license notice:
10 : *
11 : * Licensed to the Apache Software Foundation (ASF) under one or more
12 : * contributor license agreements. See the NOTICE file distributed
13 : * with this work for additional information regarding copyright
14 : * ownership. The ASF licenses this file to you under the Apache
15 : * License, Version 2.0 (the "License"); you may not use this file
16 : * except in compliance with the License. You may obtain a copy of
17 : * the License at http://www.apache.org/licenses/LICENSE-2.0 .
18 : */
19 :
20 : #ifndef INCLUDED_BASEBMP_TOOLS_HXX
21 : #define INCLUDED_BASEBMP_TOOLS_HXX
22 :
23 : #include <basegfx/range/b2ibox.hxx>
24 : #include <basegfx/point/b2ipoint.hxx>
25 : #include <vigra/tuple.hxx>
26 : #include <vigra/diff2d.hxx>
27 :
28 : namespace basebmp
29 : {
30 1478546 : inline vigra::Diff2D topLeft( const basegfx::B2IBox& rRange )
31 1478546 : { return vigra::Diff2D(rRange.getMinX(),rRange.getMinY()); }
32 :
33 1478546 : inline vigra::Diff2D bottomRight( const basegfx::B2IBox& rRange )
34 1478546 : { return vigra::Diff2D(rRange.getMaxX(),rRange.getMaxY()); }
35 :
36 : template< class Iterator, class Accessor >
37 : inline vigra::triple<Iterator,Iterator,Accessor>
38 73581 : destIterRange(Iterator const& begin,
39 : Accessor const& accessor,
40 : const basegfx::B2IBox& rRange)
41 : {
42 : return vigra::triple<Iterator,Iterator,Accessor>(
43 145710 : begin + topLeft(rRange),
44 145710 : begin + bottomRight(rRange),
45 292146 : accessor);
46 : }
47 :
48 : template< class Iterator, class Accessor >
49 : inline vigra::triple<Iterator,Iterator,Accessor>
50 1404965 : srcIterRange(Iterator const& begin,
51 : Accessor const& accessor,
52 : const basegfx::B2IBox& rRange)
53 : {
54 : return vigra::triple<Iterator,Iterator,Accessor>(
55 2702046 : begin + topLeft(rRange),
56 2702046 : begin + bottomRight(rRange),
57 5458034 : accessor);
58 : }
59 :
60 : template< class Iterator, class Accessor >
61 : inline vigra::pair<Iterator,Accessor>
62 : srcIter(Iterator const& begin,
63 : Accessor const& accessor,
64 : const basegfx::B2IPoint& rPt)
65 : {
66 : return vigra::pair<Iterator,Accessor>(
67 : begin + vigra::Diff2D(rPt.getX(),rPt.getY()),
68 : accessor);
69 : }
70 :
71 : template< class Iterator, class Accessor >
72 : inline vigra::pair<Iterator,Accessor>
73 1343815 : destIter(Iterator const& begin,
74 : Accessor const& accessor,
75 : const basegfx::B2IPoint& rPt)
76 : {
77 : return vigra::pair<Iterator,Accessor>(
78 2686234 : begin + vigra::Diff2D(rPt.getX(),rPt.getY()),
79 2686932 : accessor);
80 : }
81 : }
82 :
83 : #endif /* INCLUDED_BASEBMP_TOOLS_HXX */
84 :
85 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|