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_GENERICCOLORIMAGEACCESSOR_HXX
21 : #define INCLUDED_BASEBMP_GENERICCOLORIMAGEACCESSOR_HXX
22 :
23 : #include <basebmp/color.hxx>
24 : #include <basebmp/bitmapdevice.hxx>
25 :
26 : namespace basebmp
27 : {
28 : /** Access a BitmapDevice generically
29 :
30 : This accessor deals with an opaque BitmapDevice generically,
31 : via getPixel()/setPixel() at the published interface.
32 : */
33 3186292 : class GenericColorImageAccessor
34 : {
35 : BitmapDeviceSharedPtr mpDevice;
36 : DrawMode meDrawMode;
37 :
38 : public:
39 : typedef Color value_type;
40 :
41 42464 : explicit GenericColorImageAccessor( BitmapDeviceSharedPtr const& rTarget ) :
42 : mpDevice(rTarget),
43 42464 : meDrawMode(DrawMode_PAINT)
44 42464 : {}
45 :
46 : GenericColorImageAccessor( BitmapDeviceSharedPtr const& rTarget,
47 : DrawMode eDrawMode ) :
48 : mpDevice(rTarget),
49 : meDrawMode(eDrawMode)
50 : {}
51 :
52 : template< typename Iterator >
53 123501648 : Color operator()( Iterator const& i ) const
54 123501648 : { return mpDevice->getPixel( basegfx::B2IPoint( i->x,i->y ) ); }
55 :
56 : template< typename Iterator, typename Difference >
57 : Color operator()( Iterator const& i, Difference const& diff) const
58 : { return mpDevice->getPixel( basegfx::B2IPoint( i[diff]->x,
59 : i[diff]->y ) ); }
60 :
61 : template< typename Iterator >
62 : void set(Color const& value, Iterator const& i) const
63 : { return mpDevice->setPixel( basegfx::B2IPoint( i->x,i->y ),
64 : value, meDrawMode ); }
65 :
66 : template< class Iterator, class Difference >
67 : void set(value_type const& value, Iterator const& i, Difference const& diff) const
68 : { return mpDevice->setPixel( basegfx::B2IPoint( i[diff]->x,
69 : i[diff]->y ),
70 : value, meDrawMode ); }
71 : };
72 : }
73 :
74 : #endif /* INCLUDED_BASEBMP_GENERICCOLORIMAGEACCESSOR_HXX */
75 :
76 : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
|