epoc32/include/imageframe.h
branchSymbian2
changeset 2 2fe1408b6811
child 4 837f303aceeb
equal deleted inserted replaced
1:666f914201fb 2:2fe1408b6811
       
     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".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 
       
    17 
       
    18 /**
       
    19  @file
       
    20  @publishedAll
       
    21  @released
       
    22 */
       
    23 
       
    24 #ifndef IMAGEFRAME_H
       
    25 #define IMAGEFRAME_H
       
    26 
       
    27 #include <e32std.h>
       
    28 #include <e32base.h> 
       
    29 #include <imageframeconst.h>
       
    30 
       
    31 /** 
       
    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().
       
    36 
       
    37 @see TFrameFormat
       
    38 */ 
       
    39 class TFrameFormatBase
       
    40 	{
       
    41 public:	
       
    42 	IMPORT_C TUid Type() const;
       
    43 	
       
    44 	/** 
       
    45 	Creates a duplicate instance of the frame format object on the heap.
       
    46 	
       
    47 	@return The pointer to the newly created object cast as class TFrameFormatBase. 
       
    48 	*/
       
    49 	virtual TFrameFormatBase* DuplicateL() const=0;
       
    50 	
       
    51 protected:
       
    52 	IMPORT_C explicit TFrameFormatBase(TUid aType);
       
    53 	
       
    54 private:
       
    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();
       
    60 	
       
    61 private:
       
    62 	// Format of the specific type holder
       
    63 	TUid iType; 
       
    64 		
       
    65 	// reserved for future expansion
       
    66 	TInt iReserved1;
       
    67 	TInt iReserved2;
       
    68 	TInt iReserved3;
       
    69 	};
       
    70 
       
    71 /** 
       
    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. 
       
    74 */
       
    75 class TFrameFormat: public TFrameFormatBase
       
    76 	{
       
    77 public:	
       
    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;
       
    83 
       
    84 	IMPORT_C void SetColourSpace(TUid aColourSpace);	
       
    85 	
       
    86 private: 
       
    87 	// The image frame colour space
       
    88 	TUid	iColourSpace;
       
    89 	// The frame sampling 
       
    90 	TUid 	iSampling;
       
    91 	// The image frame format code which uniquely identifies all other parameters. */  
       
    92 	TUid 	iFormatCode; 
       
    93 	};
       
    94 
       
    95 /** 
       
    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. 
       
    98 */ 
       
    99 class TFrameLayoutBase
       
   100 	{	
       
   101 public:	
       
   102 	IMPORT_C TUid Type() const;
       
   103 	
       
   104 	/** 
       
   105 	Creates a duplicate instance of the frame layout object on the heap.
       
   106 	
       
   107 	@return The pointer to the newly created object cast as class TFrameLayoutBase. 
       
   108 	*/
       
   109 	virtual TFrameLayoutBase* DuplicateL() const=0;
       
   110 	
       
   111 protected: 
       
   112 	IMPORT_C explicit TFrameLayoutBase(TUid aType);
       
   113 
       
   114 private:
       
   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();
       
   120 			
       
   121 private:
       
   122 	// Layout specific type holder
       
   123 	TUid iType; 
       
   124 		
       
   125 	// Reserved for future expansion
       
   126 	TInt iReserved1;
       
   127 	TInt iReserved2;
       
   128 	TInt iReserved3;
       
   129 	};
       
   130 
       
   131 /** 
       
   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.
       
   138 */	
       
   139 class TFrameLayout: public TFrameLayoutBase
       
   140 	{		
       
   141  		
       
   142 public:
       
   143 	IMPORT_C explicit TFrameLayout(TInt aPlanes);
       
   144 	IMPORT_C TFrameLayoutBase* DuplicateL() const;	
       
   145 	
       
   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;
       
   151 	
       
   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);
       
   156 
       
   157 private:
       
   158 	// The number of planes in this image. Value < KMaxPlanesInFrame. 
       
   159 	TInt iPlanes;				   
       
   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];
       
   168 	};
       
   169 
       
   170 /** 
       
   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. 
       
   173 */	
       
   174 class CImageFrame : public CBase 
       
   175     {
       
   176 public:  
       
   177     IMPORT_C static CImageFrame* NewL(const TDes8& aBuffer, TInt aMaxBufferSize);
       
   178  								  
       
   179     IMPORT_C static CImageFrame* NewL(const TDes8& aBuffer,
       
   180     								  TInt aMaxBufferSize, 
       
   181 				 	   				  const TSize& aFrameSize, 
       
   182 				 					  const TFrameFormatBase& aFrameFormat,
       
   183 									  const TFrameLayoutBase& aFrameLayout); 
       
   184 										  
       
   185 	IMPORT_C static CImageFrame* NewL(const RChunk* aBuffer, 
       
   186 									  TInt aMaxBufferSize,		
       
   187 						   			  TInt aDataOffset);
       
   188 
       
   189 	IMPORT_C static CImageFrame* NewL(const RChunk* aBuffer,
       
   190 									  TInt aMaxBufferSize, 
       
   191 								      TInt aDataOffset, 
       
   192 		 					 	  	  const TSize& aFrameSize,
       
   193 		 					 	  	  const TFrameFormatBase& aFrameFormat,
       
   194 		 					 	  	  const TFrameLayoutBase& aFrameLayout); 
       
   195     
       
   196 	IMPORT_C virtual const TFrameFormatBase& FrameFormat() const;	
       
   197 	IMPORT_C virtual void SetFrameFormatL(const TFrameFormatBase& aFormat);
       
   198 	
       
   199 	IMPORT_C virtual const TFrameLayoutBase& FrameLayout() const;	
       
   200 	IMPORT_C virtual void SetFrameLayoutL(const TFrameLayoutBase& aFrameLayout);
       
   201 
       
   202 	IMPORT_C virtual const TSize& FrameSizeInPixels() const;	
       
   203 	IMPORT_C virtual void SetFrameSizeInPixels(const TSize& aFrameSize);
       
   204 
       
   205 	IMPORT_C virtual TDes8& Data();
       
   206 	IMPORT_C virtual const TDesC8& Data() const;
       
   207 	
       
   208     IMPORT_C virtual TInt MaxBufferSize() const;
       
   209     IMPORT_C virtual TBool IsChunk() const;
       
   210 
       
   211 	IMPORT_C virtual RChunk& DataChunk();
       
   212 	IMPORT_C virtual TInt DataOffset() const;
       
   213     
       
   214     IMPORT_C ~CImageFrame();
       
   215 	
       
   216 protected:
       
   217 	IMPORT_C CImageFrame();
       
   218 	
       
   219     IMPORT_C void ConstructL(const TDes8& aBuffer, TInt aMaxBufferSize);
       
   220  								  
       
   221     IMPORT_C void ConstructL(const TDes8& aBuffer, 
       
   222     						 TInt aMaxBufferSize,
       
   223 				 	   		 const TSize& aFrameSize, 
       
   224 				 			 const TFrameFormatBase& aFrameFormat,
       
   225 							 const TFrameLayoutBase& aFrameLayout); 
       
   226 										  
       
   227 	IMPORT_C void ConstructL(const RChunk* aBuffer, 
       
   228 							 TInt aMaxBufferSize, 
       
   229 							 TInt aDataOffset);
       
   230 
       
   231 	IMPORT_C void ConstructL(const RChunk* aBuffer, 
       
   232 							 TInt aMaxBufferSize,
       
   233 						  	 TInt aDataOffset, 
       
   234  					 	     const TSize& aFrameSize,
       
   235  					 	  	 const TFrameFormatBase& aFrameFormat,									
       
   236  					 	  	 const TFrameLayoutBase& aFrameLayout); 
       
   237 
       
   238 private: 					 	  	 
       
   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();
       
   244 	
       
   245 private:
       
   246     class CBody; 
       
   247     CBody* iBody;
       
   248     };
       
   249 
       
   250 #endif // IMAGEFRAME_H