LCOV - code coverage report
Current view: top level - include/basebmp - paletteformats.hxx (source / functions) Hit Total Coverage
Test: commit 10e77ab3ff6f4314137acd6e2702a6e5c1ce1fae Lines: 2 2 100.0 %
Date: 2014-11-03 Functions: 1 2 50.0 %
Legend: Lines: hit not hit

          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_PALETTEFORMATS_HXX
      21             : #define INCLUDED_BASEBMP_PALETTEFORMATS_HXX
      22             : 
      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>
      31             : 
      32             : #include <vigra/numerictraits.hxx>
      33             : #include <vigra/metaprogramming.hxx>
      34             : 
      35             : namespace basebmp
      36             : {
      37             : 
      38             : 
      39             : 
      40             : /** Lookup index value for given color value in a PaletteImageAccessor
      41             :  */
      42             : template< class Accessor > struct ColorLookup
      43             : {
      44       44072 :     typename Accessor::data_type operator()( const Accessor&               acc,
      45             :                                              typename Accessor::value_type v ) const
      46             :     {
      47       44072 :         return acc.lookup(v);
      48             :     }
      49             : };
      50             : 
      51             : 
      52             : 
      53             : // partial specialization of AccessorTraits for PaletteAccessor
      54             : template< class Accessor, typename ColorType > struct AccessorTraits<
      55             :     PaletteImageAccessor< Accessor, ColorType > >
      56             : {
      57             :     /// value type of described accessor
      58             :     typedef typename PaletteImageAccessor< Accessor, ColorType >::value_type  value_type;
      59             : 
      60             :     /// Retrieve stand-alone color lookup function for given Accessor type
      61             :     typedef ColorLookup< PaletteImageAccessor< Accessor, ColorType > >        color_lookup;
      62             : 
      63             :     /// Retrieve raw pixel data accessor for given Accessor type
      64             :     typedef Accessor                                                          raw_accessor;
      65             : 
      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
      69             :      *  around.
      70             :      */
      71             :     typedef vigra::VigraFalseType                                             xor_accessor;
      72             : 
      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
      76             :      *  other way around.
      77             :      */
      78             :     template< class MaskAccessor,
      79             :               class Iterator,
      80             :               class MaskIterator > struct                                     masked_accessor
      81             :     {
      82             :         typedef vigra::VigraFalseType type;
      83             :     };
      84             : };
      85             : 
      86             : 
      87             : 
      88             : template< typename ColorType > struct PaletteAccessorSelector
      89             : {
      90             :     template< class Accessor > struct wrap_accessor
      91             :     {
      92             :         typedef PaletteImageAccessor< Accessor, ColorType > type;
      93             :     };
      94             : };
      95             : 
      96             : 
      97             : 
      98             : template< class Iterator,
      99             :           class Accessor > struct PixelFormatTraitsTemplate_Palette
     100             : {
     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;
     105             : };
     106             : 
     107             : template< int BitsPerPixel,
     108             :           bool MsbFirst > struct PixelFormatTraitsTemplate_PackedPalette :
     109             :     public PixelFormatTraitsTemplate_Palette<
     110             :                PackedPixelIterator< sal_uInt8,
     111             :                                     BitsPerPixel,
     112             :                                     MsbFirst >,
     113             :                NonStandardAccessor< sal_uInt8 > >
     114             : {};
     115             : 
     116             : 
     117             : 
     118             : // 1bpp MSB
     119             : typedef PixelFormatTraitsTemplate_PackedPalette<1, true>  PixelFormatTraits_PAL1_MSB;
     120             : 
     121             : // 1bpp LSB
     122             : typedef PixelFormatTraitsTemplate_PackedPalette<1, false> PixelFormatTraits_PAL1_LSB;
     123             : 
     124             : // 4bpp MSB
     125             : typedef PixelFormatTraitsTemplate_PackedPalette<4, true>  PixelFormatTraits_PAL4_MSB;
     126             : 
     127             : // 4bpp LSB
     128             : typedef PixelFormatTraitsTemplate_PackedPalette<4, false> PixelFormatTraits_PAL4_LSB;
     129             : 
     130             : // 8bpp
     131             : typedef PixelFormatTraitsTemplate_Palette<
     132             :     PixelIterator< sal_uInt8 >,
     133             :     StandardAccessor< sal_uInt8 > >                       PixelFormatTraits_PAL8;
     134             : 
     135             : } // namespace basebmp
     136             : 
     137             : #endif // INCLUDED_BASEBMP_PALETTEFORMATS_HXX
     138             : 
     139             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10