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 the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
5 // which accompanies this distribution, and is available
6 // at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
29 #include <imageframeconst.h>
32 The base class for TFrameFormat. Users implement specific frame formats by deriving from this class.
33 Symbian provides a particular implementation in the TFrameFormat class.
34 Each class derived from this class should be identified by a unique UID value, denoting its type.
35 All subclasses should provide implementations of DuplicateL().
39 class TFrameFormatBase
42 IMPORT_C TUid Type() const;
45 Creates a duplicate instance of the frame format object on the heap.
47 @return The pointer to the newly created object cast as class TFrameFormatBase.
49 virtual TFrameFormatBase* DuplicateL() const=0;
52 IMPORT_C explicit TFrameFormatBase(TUid aType);
55 // reserved for future expansion
56 IMPORT_C virtual void Reserved1();
57 IMPORT_C virtual void Reserved2();
58 IMPORT_C virtual void Reserved3();
59 IMPORT_C virtual void Reserved4();
62 // Format of the specific type holder
65 // reserved for future expansion
72 This class is a specific implementation of TFrameFormatBase. An object of this class provides
73 colour space and sampling information based on a specific image format code.
75 class TFrameFormat: public TFrameFormatBase
78 IMPORT_C explicit TFrameFormat(TUid aFormatCode);
79 IMPORT_C TFrameFormatBase* DuplicateL() const;
80 IMPORT_C TUid ColourSpace() const;
81 IMPORT_C TUid Sampling() const;
82 IMPORT_C TUid FormatCode() const;
84 IMPORT_C void SetColourSpace(TUid aColourSpace);
87 // The image frame colour space
91 // The image frame format code which uniquely identifies all other parameters. */
96 Base class for TFrameLayout. Individual subclasses are identified by their specific UID value.
97 These classes are used to describe the memory layout of a specific Image Frame.
99 class TFrameLayoutBase
102 IMPORT_C TUid Type() const;
105 Creates a duplicate instance of the frame layout object on the heap.
107 @return The pointer to the newly created object cast as class TFrameLayoutBase.
109 virtual TFrameLayoutBase* DuplicateL() const=0;
112 IMPORT_C explicit TFrameLayoutBase(TUid aType);
115 // reserved for future expansion
116 IMPORT_C virtual void Reserved1();
117 IMPORT_C virtual void Reserved2();
118 IMPORT_C virtual void Reserved3();
119 IMPORT_C virtual void Reserved4();
122 // Layout specific type holder
125 // Reserved for future expansion
132 Class TFrameLayout is a concrete implementation of TFrameLayoutBase class.
133 It serves as a container for parameters that describe the memory organisation of
134 the data encapsulated by a specific CImageFrame object.
135 Image data is stored in planes. Each plane is characterised by
136 the byte offset from the start of the image frame memory, and its maximum size,
137 current length and scanlength.
139 class TFrameLayout: public TFrameLayoutBase
143 IMPORT_C explicit TFrameLayout(TInt aPlanes);
144 IMPORT_C TFrameLayoutBase* DuplicateL() const;
146 IMPORT_C TInt Planes() const;
147 IMPORT_C TInt Start(TInt aIndex) const;
148 IMPORT_C TInt Length(TInt aIndex) const;
149 IMPORT_C TInt CurrentLength(TInt aIndex) const;
150 IMPORT_C TInt ScanLength(TInt aIndex) const;
152 IMPORT_C void SetStart(TInt aIndex, TInt aStart);
153 IMPORT_C void SetLength(TInt aIndex, TInt aLength );
154 IMPORT_C void SetCurrentLength(TInt aIndex, TInt aCurrentLength);
155 IMPORT_C void SetScanLength(TInt aIndex, TInt aScanLength);
158 // The number of planes in this image. Value < KMaxPlanesInFrame.
160 // The offset of each plane from the start of the memory referenced by this image frame.
161 TInt iStart[KMaxPlanesInFrame];
162 // The length of each image plane in bytes.
163 TInt iLength[KMaxPlanesInFrame];
164 // The length of the data stored in each image plane in bytes.
165 TInt iCurrentLength[KMaxPlanesInFrame];
166 // The width of the stride for each plane.
167 TInt iScanLength[KMaxPlanesInFrame];
171 CImageFrame class exposes an API for accessing binary image data in a uniform way.
172 It is implemented as a wrapper around TDes8 or RChunk objects.
174 class CImageFrame : public CBase
177 IMPORT_C static CImageFrame* NewL(const TDes8& aBuffer, TInt aMaxBufferSize);
179 IMPORT_C static CImageFrame* NewL(const TDes8& aBuffer,
181 const TSize& aFrameSize,
182 const TFrameFormatBase& aFrameFormat,
183 const TFrameLayoutBase& aFrameLayout);
185 IMPORT_C static CImageFrame* NewL(const RChunk* aBuffer,
189 IMPORT_C static CImageFrame* NewL(const RChunk* aBuffer,
192 const TSize& aFrameSize,
193 const TFrameFormatBase& aFrameFormat,
194 const TFrameLayoutBase& aFrameLayout);
196 IMPORT_C virtual const TFrameFormatBase& FrameFormat() const;
197 IMPORT_C virtual void SetFrameFormatL(const TFrameFormatBase& aFormat);
199 IMPORT_C virtual const TFrameLayoutBase& FrameLayout() const;
200 IMPORT_C virtual void SetFrameLayoutL(const TFrameLayoutBase& aFrameLayout);
202 IMPORT_C virtual const TSize& FrameSizeInPixels() const;
203 IMPORT_C virtual void SetFrameSizeInPixels(const TSize& aFrameSize);
205 IMPORT_C virtual TDes8& Data();
206 IMPORT_C virtual const TDesC8& Data() const;
208 IMPORT_C virtual TInt MaxBufferSize() const;
209 IMPORT_C virtual TBool IsChunk() const;
211 IMPORT_C virtual RChunk& DataChunk();
212 IMPORT_C virtual TInt DataOffset() const;
214 IMPORT_C ~CImageFrame();
217 IMPORT_C CImageFrame();
219 IMPORT_C void ConstructL(const TDes8& aBuffer, TInt aMaxBufferSize);
221 IMPORT_C void ConstructL(const TDes8& aBuffer,
223 const TSize& aFrameSize,
224 const TFrameFormatBase& aFrameFormat,
225 const TFrameLayoutBase& aFrameLayout);
227 IMPORT_C void ConstructL(const RChunk* aBuffer,
231 IMPORT_C void ConstructL(const RChunk* aBuffer,
234 const TSize& aFrameSize,
235 const TFrameFormatBase& aFrameFormat,
236 const TFrameLayoutBase& aFrameLayout);
239 // for future development
240 IMPORT_C virtual void Reserved1();
241 IMPORT_C virtual void Reserved2();
242 IMPORT_C virtual void Reserved3();
243 IMPORT_C virtual void Reserved4();
250 #endif // IMAGEFRAME_H