sl@0
|
1 |
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
|
sl@0
|
2 |
// All rights reserved.
|
sl@0
|
3 |
// This component and the accompanying materials are made available
|
sl@0
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
sl@0
|
5 |
// which accompanies this distribution, and is available
|
sl@0
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
sl@0
|
7 |
//
|
sl@0
|
8 |
// Initial Contributors:
|
sl@0
|
9 |
// Nokia Corporation - initial contribution.
|
sl@0
|
10 |
//
|
sl@0
|
11 |
// Contributors:
|
sl@0
|
12 |
//
|
sl@0
|
13 |
// Description:
|
sl@0
|
14 |
//
|
sl@0
|
15 |
|
sl@0
|
16 |
#ifndef __BITMAPCOMPR_H__
|
sl@0
|
17 |
#define __BITMAPCOMPR_H__
|
sl@0
|
18 |
|
sl@0
|
19 |
//Forward declaration
|
sl@0
|
20 |
class TLineScanningPosition;
|
sl@0
|
21 |
//Global function used by 12, 16, 24 bpp scan line decompression methods
|
sl@0
|
22 |
void AdjustLineScanningPosition(TLineScanningPosition& aLineScanPos,
|
sl@0
|
23 |
const TUint32* aBase,
|
sl@0
|
24 |
TInt aBitmapWidth,
|
sl@0
|
25 |
TInt aStartPos,
|
sl@0
|
26 |
TInt aCompressedDataBytes);
|
sl@0
|
27 |
|
sl@0
|
28 |
/**
|
sl@0
|
29 |
Possible values for the template argument of TScanLineDecompressor class.
|
sl@0
|
30 |
@internalComponent
|
sl@0
|
31 |
*/
|
sl@0
|
32 |
typedef enum
|
sl@0
|
33 |
{
|
sl@0
|
34 |
E2bpp = 2,
|
sl@0
|
35 |
E3bpp = 3,
|
sl@0
|
36 |
E4bpp = 4
|
sl@0
|
37 |
} TScanLineDecompressorType;
|
sl@0
|
38 |
|
sl@0
|
39 |
/**
|
sl@0
|
40 |
This functor class is used for bitmap scanline decompression.
|
sl@0
|
41 |
Possible values for the template argument of TScanLineDecompressor class are enumerated
|
sl@0
|
42 |
in TScanLineDecompressorType enum.
|
sl@0
|
43 |
Note: "BPP" means "bytes per pixel for source buffer".
|
sl@0
|
44 |
Note: "BPP_DEST" means "bytes per pixel for destination buffer".
|
sl@0
|
45 |
Note: Template class design was preffered to base-derived class design (with virtual
|
sl@0
|
46 |
CopyPixel() method), because performance is more important than code size for bitmap
|
sl@0
|
47 |
scanline decompression.
|
sl@0
|
48 |
@internalComponent
|
sl@0
|
49 |
*/
|
sl@0
|
50 |
template <TInt BPP, TInt BPP_DEST>
|
sl@0
|
51 |
class TScanLineDecompressor
|
sl@0
|
52 |
{
|
sl@0
|
53 |
public:
|
sl@0
|
54 |
TScanLineDecompressor(const TUint32* aBase,
|
sl@0
|
55 |
TInt aComprDataBytes,
|
sl@0
|
56 |
TBool aCanAdjustLineScanPos);
|
sl@0
|
57 |
void operator()(TUint8* aDestBuffer, const TPoint& aPixel,
|
sl@0
|
58 |
TLineScanningPosition& aLineScanPos, TInt aByteWidth, TInt aDestByteWidth, TInt aLength) const;
|
sl@0
|
59 |
|
sl@0
|
60 |
private:
|
sl@0
|
61 |
TInt CalcStartPos(const TPoint& aPixel, TInt aByteWidth) const;
|
sl@0
|
62 |
TInt CalcDestStartPos(const TPoint& aPixel, TInt aByteWidth) const;
|
sl@0
|
63 |
TInt CalcEndPos(TInt aLength, const TPoint& aPixel, TInt aByteWidth) const;
|
sl@0
|
64 |
TUint8* CalcDestPtr(const TUint8* aDestBuffer, const TPoint& aPixel) const;
|
sl@0
|
65 |
TUint8* CalcDestPtrLimit(const TUint8* aDestPtr, const TPoint& aPixel, TInt aByteWidth,
|
sl@0
|
66 |
TInt aLength, TInt aStartPos) const;
|
sl@0
|
67 |
TInt CalcAvailDestSpace(const TUint8* aDestPtr, const TUint8* aDestPtrLimit) const;
|
sl@0
|
68 |
TUint8* AdjustLineScanningPosition(TLineScanningPosition& aLineScanPos, TInt aByteWidth,
|
sl@0
|
69 |
TInt aStartPos) const;
|
sl@0
|
70 |
TUint8* CopyPixel(TUint8* aDestPtr, const TUint8* aSrcPtr, TInt aCount) const;
|
sl@0
|
71 |
TUint8* CopyBlockPixel(TUint8* aDestPtr, const TUint8* aSrcPtr, TInt aCount) const;
|
sl@0
|
72 |
|
sl@0
|
73 |
TScanLineDecompressor(const TScanLineDecompressor&);//prevent default copy constructor
|
sl@0
|
74 |
TScanLineDecompressor& operator=(const TScanLineDecompressor&);//prevent default "=" operator
|
sl@0
|
75 |
|
sl@0
|
76 |
private:
|
sl@0
|
77 |
const TUint32* iBase;
|
sl@0
|
78 |
const TInt iComprDataBytes;
|
sl@0
|
79 |
const TBool iCanAdjustLineScanPos;
|
sl@0
|
80 |
|
sl@0
|
81 |
};
|
sl@0
|
82 |
|
sl@0
|
83 |
#include "BitmapCompr.inl"
|
sl@0
|
84 |
|
sl@0
|
85 |
#endif//__BITMAPCOMPR_H__
|
sl@0
|
86 |
|