bump product version to 4.2.0.1
[LibreOffice.git] / include / basebmp / pixelformatadapters.hxx
blob09cc9368394d49923c77ac12c722aeaca6fcbd2d
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_PIXELFORMATADAPTERS_HXX
21 #define INCLUDED_BASEBMP_PIXELFORMATADAPTERS_HXX
23 #include <basebmp/accessortraits.hxx>
24 #include <basebmp/accessoradapters.hxx>
26 #include <vigra/metaprogramming.hxx>
28 namespace basebmp
31 // convenience functionality, providing everything necessary for a new
32 // pixel format. simply plug in two conversion functors from/to a
33 // common color format.
35 /** Accessor selection metafunction, used to wrap a given accessor
36 with one converting between the pixel and color types
38 Use the nested template's typedef type, to retrieve an
39 AccessorAdapter which operates on a pixel value accessor, and
40 provides color values to the outside.
42 Nested like this, to avoid template template parameters at other
43 places: an instantiated version of AccessorSelector can be passed
44 to other templates, which in turn can invoke the nested meta
45 function.
47 template< typename Getter,
48 typename Setter > struct AccessorSelector
50 template< typename Accessor > struct wrap_accessor
52 typedef UnaryFunctionAccessorAdapter< Accessor,
53 Getter,
54 Setter > type;
58 //-----------------------------------------------------------------------------
60 /** Convert color value to pixel data type
62 template< class Accessor, typename DataType > struct ColorConvert
64 DataType operator()( const Accessor& acc,
65 typename Accessor::value_type v ) const
67 return acc.setter(v);
71 //-----------------------------------------------------------------------------
73 /** Macro generates partial specialization for color-conversion
74 UnaryFunctionAccessorAdapter, and the given getter/setter functors
76 #define BASEBMP_SPECIALIZE_ACCESSORTRAITS(Getter,Setter) \
77 template< class Accessor > struct AccessorTraits< \
78 UnaryFunctionAccessorAdapter< Accessor, \
79 Getter, \
80 Setter > > \
81 { \
82 typedef typename Accessor::value_type data_type; \
83 typedef UnaryFunctionAccessorAdapter< \
84 Accessor, \
85 Getter, \
86 Setter > accessor_type; \
87 typedef typename accessor_type::value_type value_type; \
88 typedef ColorConvert< accessor_type, \
89 data_type > color_lookup; \
90 typedef Accessor raw_accessor; \
91 typedef vigra::VigraFalseType xor_accessor; \
92 template< class MaskAccessor, \
93 class Iterator, \
94 class MaskIterator > struct masked_accessor\
95 { typedef vigra::VigraFalseType type; }; \
98 } // namespace basebmp
100 #endif /* INCLUDED_BASEBMP_PIXELFORMATADAPTERS_HXX */
102 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */