|
1 // Copyright (c) 2006-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 RGBBUFFERPTR_H |
|
17 #define RGBBUFFERPTR_H |
|
18 |
|
19 #include <e32base.h> |
|
20 |
|
21 /** |
|
22 @file |
|
23 @internalComponent |
|
24 */ |
|
25 |
|
26 class CFbsBitmap; |
|
27 |
|
28 /** |
|
29 Basic support for RGB input buffer, which can lock data in-place |
|
30 or copy it to the internal buffer depending on the bitmap display mode |
|
31 and block size/position |
|
32 */ |
|
33 class CRgbBufferPtr : public CBase |
|
34 { |
|
35 private: |
|
36 typedef TUint8* TRgbBufferPtr; |
|
37 |
|
38 enum |
|
39 { |
|
40 KRgbBufferPixelSize = 3, |
|
41 }; |
|
42 |
|
43 /** |
|
44 colour component indeces when accessing EColor16M mode bitmap |
|
45 */ |
|
46 enum |
|
47 { |
|
48 KBlueCompIdx = 0, |
|
49 KGreenCompIdx = 1, |
|
50 KRedCompIdx = 2 |
|
51 }; |
|
52 public: |
|
53 typedef const TUint8* TConstRgbBufferPtr; |
|
54 |
|
55 static CRgbBufferPtr* NewL(CFbsBitmap& aBitmap, const TSize& aMCUSizeinPixels); |
|
56 |
|
57 ~CRgbBufferPtr(); |
|
58 |
|
59 TConstRgbBufferPtr LockBuffer(const TPoint& aTopLeft); |
|
60 void UnlockBuffer(); |
|
61 |
|
62 // must be used only within a line, can't span lines |
|
63 static inline TConstRgbBufferPtr ShiftPtr(TConstRgbBufferPtr aPtr, TInt aOffset); |
|
64 |
|
65 inline TInt NextLineOffset() const; |
|
66 inline TInt PtrShiftValueMCU16(TUint aNumberOfPixels) const; |
|
67 inline TInt PtrShiftValueMCU8(TUint aNumberOfPixels) const; |
|
68 |
|
69 static inline TUint8 Red(TConstRgbBufferPtr aPtr); |
|
70 static inline TUint8 Green(TConstRgbBufferPtr aPtr); |
|
71 static inline TUint8 Blue(TConstRgbBufferPtr aPtr); |
|
72 |
|
73 protected: |
|
74 static inline TRgbBufferPtr ShiftPtr(TRgbBufferPtr aPtr, TInt aOffset); |
|
75 static inline TRgbBufferPtr Coord2Ptr(TRgbBufferPtr aBase, TInt aX, TInt aY); |
|
76 static inline TInt Coord2Size(TInt aX, TInt aY); |
|
77 |
|
78 private: |
|
79 CRgbBufferPtr(CFbsBitmap& aBitmap, const TSize& aMCUSizeinPixels); |
|
80 void ConstructL(); |
|
81 |
|
82 private: |
|
83 TConstRgbBufferPtr iLockedPtr; |
|
84 TRgbBufferPtr iRgbBuffer; |
|
85 TRgbBufferPtr iOriginalRgbBuffer; |
|
86 TBool iBitmapDirectAccess; |
|
87 TInt iBitmapScanlineLength; |
|
88 |
|
89 const TSize iBitmapSize; |
|
90 const TSize iMCUSizeinPixels; |
|
91 |
|
92 TInt iNextLineOffset; |
|
93 TInt iBufferScanlineLength; |
|
94 TSize iBufferSizeInPixels; |
|
95 TPoint iBufferPos; |
|
96 |
|
97 CFbsBitmap* iBitmap; |
|
98 TUint32* iBitmapData; |
|
99 |
|
100 }; |
|
101 |
|
102 #include "rgbbufferptr.inl" |
|
103 |
|
104 #endif // ndef RGBBUFFERPTR_H |
|
105 |
|
106 |