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