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".
8 // Initial Contributors:
9 // Nokia Corporation - initial contribution.
27 #include <imageframeconst.h>
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().
37 class TFrameFormatBase
40 IMPORT_C TUid Type() const;
43 Creates a duplicate instance of the frame format object on the heap.
45 @return The pointer to the newly created object cast as class TFrameFormatBase.
47 virtual TFrameFormatBase* DuplicateL() const=0;
50 IMPORT_C explicit TFrameFormatBase(TUid aType);
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();
60 // Format of the specific type holder
63 // reserved for future expansion
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.
73 class TFrameFormat: public TFrameFormatBase
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;
82 IMPORT_C void SetColourSpace(TUid aColourSpace);
85 // The image frame colour space
89 // The image frame format code which uniquely identifies all other parameters. */
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.
97 class TFrameLayoutBase
100 IMPORT_C TUid Type() const;
103 Creates a duplicate instance of the frame layout object on the heap.
105 @return The pointer to the newly created object cast as class TFrameLayoutBase.
107 virtual TFrameLayoutBase* DuplicateL() const=0;
110 IMPORT_C explicit TFrameLayoutBase(TUid aType);
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();
120 // Layout specific type holder
123 // Reserved for future expansion
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.
137 class TFrameLayout: public TFrameLayoutBase
141 IMPORT_C explicit TFrameLayout(TInt aPlanes);
142 IMPORT_C TFrameLayoutBase* DuplicateL() const;
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;
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);
156 // The number of planes in this image. Value < KMaxPlanesInFrame.
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];
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.
172 class CImageFrame : public CBase
175 IMPORT_C static CImageFrame* NewL(const TDes8& aBuffer, TInt aMaxBufferSize);
177 IMPORT_C static CImageFrame* NewL(const TDes8& aBuffer,
179 const TSize& aFrameSize,
180 const TFrameFormatBase& aFrameFormat,
181 const TFrameLayoutBase& aFrameLayout);
183 IMPORT_C static CImageFrame* NewL(const RChunk* aBuffer,
187 IMPORT_C static CImageFrame* NewL(const RChunk* aBuffer,
190 const TSize& aFrameSize,
191 const TFrameFormatBase& aFrameFormat,
192 const TFrameLayoutBase& aFrameLayout);
194 IMPORT_C virtual const TFrameFormatBase& FrameFormat() const;
195 IMPORT_C virtual void SetFrameFormatL(const TFrameFormatBase& aFormat);
197 IMPORT_C virtual const TFrameLayoutBase& FrameLayout() const;
198 IMPORT_C virtual void SetFrameLayoutL(const TFrameLayoutBase& aFrameLayout);
200 IMPORT_C virtual const TSize& FrameSizeInPixels() const;
201 IMPORT_C virtual void SetFrameSizeInPixels(const TSize& aFrameSize);
203 IMPORT_C virtual TDes8& Data();
204 IMPORT_C virtual const TDesC8& Data() const;
206 IMPORT_C virtual TInt MaxBufferSize() const;
207 IMPORT_C virtual TBool IsChunk() const;
209 IMPORT_C virtual RChunk& DataChunk();
210 IMPORT_C virtual TInt DataOffset() const;
212 IMPORT_C ~CImageFrame();
215 IMPORT_C CImageFrame();
217 IMPORT_C void ConstructL(const TDes8& aBuffer, TInt aMaxBufferSize);
219 IMPORT_C void ConstructL(const TDes8& aBuffer,
221 const TSize& aFrameSize,
222 const TFrameFormatBase& aFrameFormat,
223 const TFrameLayoutBase& aFrameLayout);
225 IMPORT_C void ConstructL(const RChunk* aBuffer,
229 IMPORT_C void ConstructL(const RChunk* aBuffer,
232 const TSize& aFrameSize,
233 const TFrameFormatBase& aFrameFormat,
234 const TFrameLayoutBase& aFrameLayout);
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();
248 #endif // IMAGEFRAME_H