Update ooo320-m1
[ooovba.git] / sd / source / ui / slidesorter / cache / SlsBitmapCompressor.hxx
blobe0c60f44c42ab68654ea16f631133df4bd4566c8
1 /*************************************************************************
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * Copyright 2008 by Sun Microsystems, Inc.
7 * OpenOffice.org - a multi-platform office productivity suite
9 * $RCSfile: SlsBitmapCompressor.hxx,v $
10 * $Revision: 1.4 $
12 * This file is part of OpenOffice.org.
14 * OpenOffice.org is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU Lesser General Public License version 3
16 * only, as published by the Free Software Foundation.
18 * OpenOffice.org is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU Lesser General Public License version 3 for more details
22 * (a copy is included in the LICENSE file that accompanied this code).
24 * You should have received a copy of the GNU Lesser General Public License
25 * version 3 along with OpenOffice.org. If not, see
26 * <http://www.openoffice.org/license.html>
27 * for a copy of the LGPLv3 License.
29 ************************************************************************/
31 #ifndef SD_SLIDESORTER_BITMAP_COMPRESSOR_HXX
32 #define SD_SLIDESORTER_BITMAP_COMPRESSOR_HXX
34 #include <sal/types.h>
35 #include <tools/gen.hxx>
36 #include <boost/shared_ptr.hpp>
38 class BitmapEx;
40 namespace sd { namespace slidesorter { namespace cache {
42 class BitmapReplacement;
45 /** This interface class provides the minimal method set for classes that
46 implement the compression and decompression of preview bitmaps.
48 class BitmapCompressor
50 public:
51 /** Compress the given bitmap into a replacement format that is specific
52 to the compressor class.
54 virtual ::boost::shared_ptr<BitmapReplacement> Compress (
55 const ::boost::shared_ptr<BitmapEx>& rpBitmap) const = 0;
57 /** Decompress the given replacement data into a preview bitmap.
58 Depending on the compression technique the returned bitmap may
59 differ from the original bitmap given to the Compress() method. It
60 may even of the wrong size or empty or the NULL pointer. It is the
61 task of the caller to create a new preview bitmap if the returned
62 one is not as desired.
64 virtual ::boost::shared_ptr<BitmapEx> Decompress (const BitmapReplacement& rBitmapData)const=0;
66 /** Return whether the compression and decompression is lossless. This
67 value is used by the caller of Decompress() to decide whether to use
68 the returned bitmap as is or if a new preview has to be created.
70 virtual bool IsLossless (void) const = 0;
75 /** Interface for preview bitmap replacements. Each bitmap
76 compressor/decompressor has to provide an implementation that is
77 suitable to store the compressed bitmaps.
79 class BitmapReplacement
81 public:
82 virtual sal_Int32 GetMemorySize (void) const { return 0; }
88 /** This is one trivial bitmap compressor. It stores bitmaps unmodified
89 instead of compressing them.
90 This compressor is lossless.
92 class NoBitmapCompression
93 : public BitmapCompressor
95 class DummyReplacement;
96 public:
97 virtual ::boost::shared_ptr<BitmapReplacement> Compress (
98 const ::boost::shared_ptr<BitmapEx>& rpBitmap) const;
99 virtual ::boost::shared_ptr<BitmapEx> Decompress (const BitmapReplacement& rBitmapData) const;
100 virtual bool IsLossless (void) const;
106 /** This is another trivial bitmap compressor. Instead of compressing a
107 bitmap, it throws the bitmap away. Its Decompress() method returns a
108 NULL pointer. The caller has to create a new preview bitmap instead.
109 This compressor clearly is not lossless.
111 class CompressionByDeletion
112 : public BitmapCompressor
114 public:
115 virtual ::boost::shared_ptr<BitmapReplacement> Compress (
116 const ::boost::shared_ptr<BitmapEx>& rpBitmap) const;
117 virtual ::boost::shared_ptr<BitmapEx> Decompress (const BitmapReplacement& rBitmapData) const;
118 virtual bool IsLossless (void) const;
124 /** Compress a preview bitmap by reducing its resolution. While the aspect
125 ratio is maintained the horizontal resolution is scaled down to 100
126 pixels.
127 This compressor is not lossless.
129 class ResolutionReduction
130 : public BitmapCompressor
132 class ResolutionReducedReplacement;
133 static const sal_Int32 mnWidth = 100;
134 public:
135 virtual ::boost::shared_ptr<BitmapReplacement> Compress (
136 const ::boost::shared_ptr<BitmapEx>& rpBitmap) const;
137 /** Scale the replacement bitmap up to the original size.
139 virtual ::boost::shared_ptr<BitmapEx> Decompress (const BitmapReplacement& rBitmapData) const;
140 virtual bool IsLossless (void) const;
146 /** Compress preview bitmaps using the PNG format.
147 This compressor is lossless.
149 class PngCompression
150 : public BitmapCompressor
152 class PngReplacement;
153 public:
154 virtual ::boost::shared_ptr<BitmapReplacement> Compress (
155 const ::boost::shared_ptr<BitmapEx>& rpBitmap) const;
156 virtual ::boost::shared_ptr<BitmapEx> Decompress (const BitmapReplacement& rBitmapData) const;
157 virtual bool IsLossless (void) const;
161 } } } // end of namespace ::sd::slidesorter::cache
163 #endif