LCOV - code coverage report
Current view: top level - libreoffice/sd/source/ui/slidesorter/cache - SlsBitmapCompressor.hxx (source / functions) Hit Total Coverage
Test: libreoffice_filtered.info Lines: 0 13 0.0 %
Date: 2012-12-27 Functions: 0 17 0.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 SD_SLIDESORTER_BITMAP_COMPRESSOR_HXX
      21             : #define SD_SLIDESORTER_BITMAP_COMPRESSOR_HXX
      22             : 
      23             : #include <sal/types.h>
      24             : #include <tools/gen.hxx>
      25             : #include <boost/shared_ptr.hpp>
      26             : 
      27             : 
      28             : class Bitmap;
      29             : 
      30             : namespace sd { namespace slidesorter { namespace cache {
      31             : 
      32             : class BitmapReplacement;
      33             : 
      34             : 
      35             : /** This interface class provides the minimal method set for classes that
      36             :     implement the compression and decompression of preview bitmaps.
      37             : */
      38           0 : class BitmapCompressor
      39             : {
      40             : public:
      41             :     /** Compress the given bitmap into a replacement format that is specific
      42             :         to the compressor class.
      43             :     */
      44             :     virtual ::boost::shared_ptr<BitmapReplacement> Compress (const Bitmap& rBitmap) const = 0;
      45             : 
      46             :     /** Decompress the given replacement data into a preview bitmap.
      47             :         Depending on the compression technique the returned bitmap may
      48             :         differ from the original bitmap given to the Compress() method.  It
      49             :         may even of the wrong size or empty or the NULL pointer.  It is the
      50             :         task of the caller to create a new preview bitmap if the returned
      51             :         one is not as desired.
      52             :     */
      53             :     virtual Bitmap Decompress (const BitmapReplacement& rBitmapData)const=0;
      54             : 
      55             :     /** Return whether the compression and decompression is lossless.  This
      56             :         value is used by the caller of Decompress() to decide whether to use
      57             :         the returned bitmap as is or if a new preview has to be created.
      58             :     */
      59             :     virtual bool IsLossless (void) const = 0;
      60             : 
      61             : protected:
      62           0 :     ~BitmapCompressor() {}
      63             : };
      64             : 
      65             : 
      66             : 
      67             : /** Interface for preview bitmap replacements.  Each bitmap
      68             :     compressor/decompressor has to provide an implementation that is
      69             :     suitable to store the compressed bitmaps.
      70             : */
      71           0 : class BitmapReplacement
      72             : {
      73             : public:
      74           0 :     virtual sal_Int32 GetMemorySize (void) const { return 0; }
      75             : 
      76             : protected:
      77           0 :     ~BitmapReplacement() {}
      78             : };
      79             : 
      80             : 
      81             : 
      82             : 
      83             : /** This is one trivial bitmap compressor.  It stores bitmaps unmodified
      84             :     instead of compressing them.
      85             :     This compressor is lossless.
      86             : */
      87           0 : class NoBitmapCompression
      88             :     : public BitmapCompressor
      89             : {
      90             :     class DummyReplacement;
      91             : public:
      92           0 :     virtual ~NoBitmapCompression() {}
      93             :     virtual ::boost::shared_ptr<BitmapReplacement> Compress (const Bitmap& rpBitmap) const;
      94             :     virtual Bitmap Decompress (const BitmapReplacement& rBitmapData) const;
      95             :     virtual bool IsLossless (void) const;
      96             : };
      97             : 
      98             : 
      99             : 
     100             : 
     101             : /** This is another trivial bitmap compressor.  Instead of compressing a
     102             :     bitmap, it throws the bitmap away.  Its Decompress() method returns a
     103             :     NULL pointer.  The caller has to create a new preview bitmap instead.
     104             :     This compressor clearly is not lossless.
     105             : */
     106           0 : class CompressionByDeletion
     107             :     : public BitmapCompressor
     108             : {
     109             : public:
     110           0 :     virtual ~CompressionByDeletion() {}
     111             :     virtual ::boost::shared_ptr<BitmapReplacement> Compress (const Bitmap& rBitmap) const;
     112             :     virtual Bitmap Decompress (const BitmapReplacement& rBitmapData) const;
     113             :     virtual bool IsLossless (void) const;
     114             : };
     115             : 
     116             : 
     117             : 
     118             : 
     119             : /** Compress a preview bitmap by reducing its resolution.  While the aspect
     120             :     ratio is maintained the horizontal resolution is scaled down to 100
     121             :     pixels.
     122             :     This compressor is not lossless.
     123             : */
     124           0 : class ResolutionReduction
     125             :     : public BitmapCompressor
     126             : {
     127             :     class ResolutionReducedReplacement;
     128             :     static const sal_Int32 mnWidth = 100;
     129             : public:
     130           0 :     virtual ~ResolutionReduction() {}
     131             :     virtual ::boost::shared_ptr<BitmapReplacement> Compress (const Bitmap& rpBitmap) const;
     132             :     /** Scale the replacement bitmap up to the original size.
     133             :     */
     134             :     virtual Bitmap Decompress (const BitmapReplacement& rBitmapData) const;
     135             :     virtual bool IsLossless (void) const;
     136             : };
     137             : 
     138             : 
     139             : 
     140             : 
     141             : /** Compress preview bitmaps using the PNG format.
     142             :     This compressor is lossless.
     143             : */
     144           0 : class PngCompression
     145             :     : public BitmapCompressor
     146             : {
     147             :     class PngReplacement;
     148             : public:
     149           0 :     virtual ~PngCompression() {}
     150             :     virtual ::boost::shared_ptr<BitmapReplacement> Compress (const Bitmap& rBitmap) const;
     151             :     virtual Bitmap Decompress (const BitmapReplacement& rBitmapData) const;
     152             :     virtual bool IsLossless (void) const;
     153             : };
     154             : 
     155             : 
     156             : } } } // end of namespace ::sd::slidesorter::cache
     157             : 
     158             : #endif
     159             : 
     160             : /* vim:set shiftwidth=4 softtabstop=4 expandtab: */

Generated by: LCOV version 1.10