1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
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_PALETTEFORMATS_HXX
21 #define INCLUDED_BASEBMP_PALETTEFORMATS_HXX
23 #include <basebmp/color.hxx>
24 #include <basebmp/colortraits.hxx>
25 #include <basebmp/accessor.hxx>
26 #include <basebmp/pixeliterator.hxx>
27 #include <basebmp/packedpixeliterator.hxx>
28 #include <basebmp/pixelformatadapters.hxx>
29 #include <basebmp/paletteimageaccessor.hxx>
30 #include <basebmp/metafunctions.hxx>
32 #include <vigra/numerictraits.hxx>
33 #include <vigra/metaprogramming.hxx>
38 //-----------------------------------------------------------------------------
40 /** Lookup index value for given color value in a PaletteImageAccessor
42 template< class Accessor
> struct ColorLookup
44 typename
Accessor::data_type
operator()( const Accessor
& acc
,
45 typename
Accessor::value_type v
) const
51 //-----------------------------------------------------------------------------
53 // partial specialization of AccessorTraits for PaletteAccessor
54 template< class Accessor
, typename ColorType
> struct AccessorTraits
<
55 PaletteImageAccessor
< Accessor
, ColorType
> >
57 /// value type of described accessor
58 typedef typename PaletteImageAccessor
< Accessor
, ColorType
>::value_type value_type
;
60 /// Retrieve stand-alone color lookup function for given Accessor type
61 typedef ColorLookup
< PaletteImageAccessor
< Accessor
, ColorType
> > color_lookup
;
63 /// Retrieve raw pixel data accessor for given Accessor type
64 typedef Accessor raw_accessor
;
66 /** accessor for XOR setter access is disabled, since the results
67 * are usually completely unintended - you'll usually want to
68 * wrap an xor_accessor with a PaletteAccessor, not the other way
71 typedef vigra::VigraFalseType xor_accessor
;
73 /** accessor for masked setter access is disabled, since the
74 * results are usually completely unintended - you'll usually
75 * want to wrap a masked_accessor with a PaletteAccessor, not the
78 template< class MaskAccessor
,
80 class MaskIterator
> struct masked_accessor
82 typedef vigra::VigraFalseType type
;
86 //-----------------------------------------------------------------------------
88 template< typename ColorType
> struct PaletteAccessorSelector
90 template< class Accessor
> struct wrap_accessor
92 typedef PaletteImageAccessor
< Accessor
, ColorType
> type
;
96 //-----------------------------------------------------------------------------
98 template< class Iterator
,
99 class Accessor
> struct PixelFormatTraitsTemplate_Palette
101 typedef typename
Iterator::value_type pixel_type
;
102 typedef Iterator iterator_type
;
103 typedef Accessor raw_accessor_type
;
104 typedef PaletteAccessorSelector
<Color
> accessor_selector
;
107 template< int BitsPerPixel
,
108 bool MsbFirst
> struct PixelFormatTraitsTemplate_PackedPalette
:
109 public PixelFormatTraitsTemplate_Palette
<
110 PackedPixelIterator
< sal_uInt8
,
113 NonStandardAccessor
< sal_uInt8
> >
116 //-----------------------------------------------------------------------------
119 typedef PixelFormatTraitsTemplate_PackedPalette
<1, true> PixelFormatTraits_PAL1_MSB
;
122 typedef PixelFormatTraitsTemplate_PackedPalette
<1, false> PixelFormatTraits_PAL1_LSB
;
125 typedef PixelFormatTraitsTemplate_PackedPalette
<4, true> PixelFormatTraits_PAL4_MSB
;
128 typedef PixelFormatTraitsTemplate_PackedPalette
<4, false> PixelFormatTraits_PAL4_LSB
;
131 typedef PixelFormatTraitsTemplate_Palette
<
132 PixelIterator
< sal_uInt8
>,
133 StandardAccessor
< sal_uInt8
> > PixelFormatTraits_PAL8
;
135 } // namespace basebmp
137 #endif // INCLUDED_BASEBMP_PALETTEFORMATS_HXX
139 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */