bump product version to 4.2.0.1
[LibreOffice.git] / include / basebmp / genericcolorimageaccessor.hxx
blob5aaa953271761adf79e4d085516ce5e9650a546c
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3 * This file is part of the LibreOffice project.
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/.
9 * This file incorporates work covered by the following license notice:
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 .
20 #ifndef INCLUDED_BASEBMP_GENERICCOLORIMAGEACCESSOR_HXX
21 #define INCLUDED_BASEBMP_GENERICCOLORIMAGEACCESSOR_HXX
23 #include <basebmp/color.hxx>
24 #include <basebmp/bitmapdevice.hxx>
26 namespace basebmp
28 /** Access a BitmapDevice generically
30 This accessor deals with an opaque BitmapDevice generically,
31 via getPixel()/setPixel() at the published interface.
33 class GenericColorImageAccessor
35 BitmapDeviceSharedPtr mpDevice;
36 DrawMode meDrawMode;
38 public:
39 typedef Color value_type;
41 explicit GenericColorImageAccessor( BitmapDeviceSharedPtr const& rTarget ) :
42 mpDevice(rTarget),
43 meDrawMode(DrawMode_PAINT)
46 GenericColorImageAccessor( BitmapDeviceSharedPtr const& rTarget,
47 DrawMode eDrawMode ) :
48 mpDevice(rTarget),
49 meDrawMode(eDrawMode)
52 template< typename Iterator >
53 Color operator()( Iterator const& i ) const
54 { return mpDevice->getPixel( basegfx::B2IPoint( i->x,i->y ) ); }
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 ) ); }
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 ); }
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 ); }
74 #endif /* INCLUDED_BASEBMP_GENERICCOLORIMAGEACCESSOR_HXX */
76 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */