|
1 // Copyright (c) 2005-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 /** |
|
17 @file |
|
18 @publishedAll |
|
19 @released |
|
20 */ |
|
21 |
|
22 #ifndef IMAGEFRAME_H |
|
23 #define IMAGEFRAME_H |
|
24 |
|
25 #include <e32std.h> |
|
26 #include <e32base.h> |
|
27 #include <imageframeconst.h> |
|
28 |
|
29 /** |
|
30 The base class for TFrameFormat. Users implement specific frame formats by deriving from this class. |
|
31 Symbian provides a particular implementation in the TFrameFormat class. |
|
32 Each class derived from this class should be identified by a unique UID value, denoting its type. |
|
33 All subclasses should provide implementations of DuplicateL(). |
|
34 |
|
35 @see TFrameFormat |
|
36 */ |
|
37 class TFrameFormatBase |
|
38 { |
|
39 public: |
|
40 IMPORT_C TUid Type() const; |
|
41 |
|
42 /** |
|
43 Creates a duplicate instance of the frame format object on the heap. |
|
44 |
|
45 @return The pointer to the newly created object cast as class TFrameFormatBase. |
|
46 */ |
|
47 virtual TFrameFormatBase* DuplicateL() const=0; |
|
48 |
|
49 protected: |
|
50 IMPORT_C explicit TFrameFormatBase(TUid aType); |
|
51 |
|
52 private: |
|
53 // reserved for future expansion |
|
54 IMPORT_C virtual void Reserved1(); |
|
55 IMPORT_C virtual void Reserved2(); |
|
56 IMPORT_C virtual void Reserved3(); |
|
57 IMPORT_C virtual void Reserved4(); |
|
58 |
|
59 private: |
|
60 // Format of the specific type holder |
|
61 TUid iType; |
|
62 |
|
63 // reserved for future expansion |
|
64 TInt iReserved1; |
|
65 TInt iReserved2; |
|
66 TInt iReserved3; |
|
67 }; |
|
68 |
|
69 /** |
|
70 This class is a specific implementation of TFrameFormatBase. An object of this class provides |
|
71 colour space and sampling information based on a specific image format code. |
|
72 */ |
|
73 class TFrameFormat: public TFrameFormatBase |
|
74 { |
|
75 public: |
|
76 IMPORT_C explicit TFrameFormat(TUid aFormatCode); |
|
77 IMPORT_C TFrameFormatBase* DuplicateL() const; |
|
78 IMPORT_C TUid ColourSpace() const; |
|
79 IMPORT_C TUid Sampling() const; |
|
80 IMPORT_C TUid FormatCode() const; |
|
81 |
|
82 IMPORT_C void SetColourSpace(TUid aColourSpace); |
|
83 |
|
84 private: |
|
85 // The image frame colour space |
|
86 TUid iColourSpace; |
|
87 // The frame sampling |
|
88 TUid iSampling; |
|
89 // The image frame format code which uniquely identifies all other parameters. */ |
|
90 TUid iFormatCode; |
|
91 }; |
|
92 |
|
93 /** |
|
94 Base class for TFrameLayout. Individual subclasses are identified by their specific UID value. |
|
95 These classes are used to describe the memory layout of a specific Image Frame. |
|
96 */ |
|
97 class TFrameLayoutBase |
|
98 { |
|
99 public: |
|
100 IMPORT_C TUid Type() const; |
|
101 |
|
102 /** |
|
103 Creates a duplicate instance of the frame layout object on the heap. |
|
104 |
|
105 @return The pointer to the newly created object cast as class TFrameLayoutBase. |
|
106 */ |
|
107 virtual TFrameLayoutBase* DuplicateL() const=0; |
|
108 |
|
109 protected: |
|
110 IMPORT_C explicit TFrameLayoutBase(TUid aType); |
|
111 |
|
112 private: |
|
113 // reserved for future expansion |
|
114 IMPORT_C virtual void Reserved1(); |
|
115 IMPORT_C virtual void Reserved2(); |
|
116 IMPORT_C virtual void Reserved3(); |
|
117 IMPORT_C virtual void Reserved4(); |
|
118 |
|
119 private: |
|
120 // Layout specific type holder |
|
121 TUid iType; |
|
122 |
|
123 // Reserved for future expansion |
|
124 TInt iReserved1; |
|
125 TInt iReserved2; |
|
126 TInt iReserved3; |
|
127 }; |
|
128 |
|
129 /** |
|
130 Class TFrameLayout is a concrete implementation of TFrameLayoutBase class. |
|
131 It serves as a container for parameters that describe the memory organisation of |
|
132 the data encapsulated by a specific CImageFrame object. |
|
133 Image data is stored in planes. Each plane is characterised by |
|
134 the byte offset from the start of the image frame memory, and its maximum size, |
|
135 current length and scanlength. |
|
136 */ |
|
137 class TFrameLayout: public TFrameLayoutBase |
|
138 { |
|
139 |
|
140 public: |
|
141 IMPORT_C explicit TFrameLayout(TInt aPlanes); |
|
142 IMPORT_C TFrameLayoutBase* DuplicateL() const; |
|
143 |
|
144 IMPORT_C TInt Planes() const; |
|
145 IMPORT_C TInt Start(TInt aIndex) const; |
|
146 IMPORT_C TInt Length(TInt aIndex) const; |
|
147 IMPORT_C TInt CurrentLength(TInt aIndex) const; |
|
148 IMPORT_C TInt ScanLength(TInt aIndex) const; |
|
149 |
|
150 IMPORT_C void SetStart(TInt aIndex, TInt aStart); |
|
151 IMPORT_C void SetLength(TInt aIndex, TInt aLength ); |
|
152 IMPORT_C void SetCurrentLength(TInt aIndex, TInt aCurrentLength); |
|
153 IMPORT_C void SetScanLength(TInt aIndex, TInt aScanLength); |
|
154 |
|
155 private: |
|
156 // The number of planes in this image. Value < KMaxPlanesInFrame. |
|
157 TInt iPlanes; |
|
158 // The offset of each plane from the start of the memory referenced by this image frame. |
|
159 TInt iStart[KMaxPlanesInFrame]; |
|
160 // The length of each image plane in bytes. |
|
161 TInt iLength[KMaxPlanesInFrame]; |
|
162 // The length of the data stored in each image plane in bytes. |
|
163 TInt iCurrentLength[KMaxPlanesInFrame]; |
|
164 // The width of the stride for each plane. |
|
165 TInt iScanLength[KMaxPlanesInFrame]; |
|
166 }; |
|
167 |
|
168 /** |
|
169 CImageFrame class exposes an API for accessing binary image data in a uniform way. |
|
170 It is implemented as a wrapper around TDes8 or RChunk objects. |
|
171 */ |
|
172 class CImageFrame : public CBase |
|
173 { |
|
174 public: |
|
175 IMPORT_C static CImageFrame* NewL(const TDes8& aBuffer, TInt aMaxBufferSize); |
|
176 |
|
177 IMPORT_C static CImageFrame* NewL(const TDes8& aBuffer, |
|
178 TInt aMaxBufferSize, |
|
179 const TSize& aFrameSize, |
|
180 const TFrameFormatBase& aFrameFormat, |
|
181 const TFrameLayoutBase& aFrameLayout); |
|
182 |
|
183 IMPORT_C static CImageFrame* NewL(const RChunk* aBuffer, |
|
184 TInt aMaxBufferSize, |
|
185 TInt aDataOffset); |
|
186 |
|
187 IMPORT_C static CImageFrame* NewL(const RChunk* aBuffer, |
|
188 TInt aMaxBufferSize, |
|
189 TInt aDataOffset, |
|
190 const TSize& aFrameSize, |
|
191 const TFrameFormatBase& aFrameFormat, |
|
192 const TFrameLayoutBase& aFrameLayout); |
|
193 |
|
194 IMPORT_C virtual const TFrameFormatBase& FrameFormat() const; |
|
195 IMPORT_C virtual void SetFrameFormatL(const TFrameFormatBase& aFormat); |
|
196 |
|
197 IMPORT_C virtual const TFrameLayoutBase& FrameLayout() const; |
|
198 IMPORT_C virtual void SetFrameLayoutL(const TFrameLayoutBase& aFrameLayout); |
|
199 |
|
200 IMPORT_C virtual const TSize& FrameSizeInPixels() const; |
|
201 IMPORT_C virtual void SetFrameSizeInPixels(const TSize& aFrameSize); |
|
202 |
|
203 IMPORT_C virtual TDes8& Data(); |
|
204 IMPORT_C virtual const TDesC8& Data() const; |
|
205 |
|
206 IMPORT_C virtual TInt MaxBufferSize() const; |
|
207 IMPORT_C virtual TBool IsChunk() const; |
|
208 |
|
209 IMPORT_C virtual RChunk& DataChunk(); |
|
210 IMPORT_C virtual TInt DataOffset() const; |
|
211 |
|
212 IMPORT_C ~CImageFrame(); |
|
213 |
|
214 protected: |
|
215 IMPORT_C CImageFrame(); |
|
216 |
|
217 IMPORT_C void ConstructL(const TDes8& aBuffer, TInt aMaxBufferSize); |
|
218 |
|
219 IMPORT_C void ConstructL(const TDes8& aBuffer, |
|
220 TInt aMaxBufferSize, |
|
221 const TSize& aFrameSize, |
|
222 const TFrameFormatBase& aFrameFormat, |
|
223 const TFrameLayoutBase& aFrameLayout); |
|
224 |
|
225 IMPORT_C void ConstructL(const RChunk* aBuffer, |
|
226 TInt aMaxBufferSize, |
|
227 TInt aDataOffset); |
|
228 |
|
229 IMPORT_C void ConstructL(const RChunk* aBuffer, |
|
230 TInt aMaxBufferSize, |
|
231 TInt aDataOffset, |
|
232 const TSize& aFrameSize, |
|
233 const TFrameFormatBase& aFrameFormat, |
|
234 const TFrameLayoutBase& aFrameLayout); |
|
235 |
|
236 private: |
|
237 // for future development |
|
238 IMPORT_C virtual void Reserved1(); |
|
239 IMPORT_C virtual void Reserved2(); |
|
240 IMPORT_C virtual void Reserved3(); |
|
241 IMPORT_C virtual void Reserved4(); |
|
242 |
|
243 private: |
|
244 class CBody; |
|
245 CBody* iBody; |
|
246 }; |
|
247 |
|
248 #endif // IMAGEFRAME_H |