epoc32/include/imageframe.h
branchSymbian2
changeset 2 2fe1408b6811
child 4 837f303aceeb
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/epoc32/include/imageframe.h	Tue Mar 16 16:12:26 2010 +0000
     1.3 @@ -0,0 +1,250 @@
     1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// 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
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +//
    1.18 +
    1.19 +
    1.20 +
    1.21 +/**
    1.22 + @file
    1.23 + @publishedAll
    1.24 + @released
    1.25 +*/
    1.26 +
    1.27 +#ifndef IMAGEFRAME_H
    1.28 +#define IMAGEFRAME_H
    1.29 +
    1.30 +#include <e32std.h>
    1.31 +#include <e32base.h> 
    1.32 +#include <imageframeconst.h>
    1.33 +
    1.34 +/** 
    1.35 +The base class for TFrameFormat. Users implement specific frame formats by deriving from this class. 
    1.36 +Symbian provides a particular implementation in the TFrameFormat class.
    1.37 +Each class derived from this class should be identified by a unique UID value, denoting its type.
    1.38 +All subclasses should provide implementations of DuplicateL().
    1.39 +
    1.40 +@see TFrameFormat
    1.41 +*/ 
    1.42 +class TFrameFormatBase
    1.43 +	{
    1.44 +public:	
    1.45 +	IMPORT_C TUid Type() const;
    1.46 +	
    1.47 +	/** 
    1.48 +	Creates a duplicate instance of the frame format object on the heap.
    1.49 +	
    1.50 +	@return The pointer to the newly created object cast as class TFrameFormatBase. 
    1.51 +	*/
    1.52 +	virtual TFrameFormatBase* DuplicateL() const=0;
    1.53 +	
    1.54 +protected:
    1.55 +	IMPORT_C explicit TFrameFormatBase(TUid aType);
    1.56 +	
    1.57 +private:
    1.58 +	// reserved for future expansion
    1.59 +	IMPORT_C virtual void Reserved1();
    1.60 +	IMPORT_C virtual void Reserved2();
    1.61 +	IMPORT_C virtual void Reserved3();
    1.62 +	IMPORT_C virtual void Reserved4();
    1.63 +	
    1.64 +private:
    1.65 +	// Format of the specific type holder
    1.66 +	TUid iType; 
    1.67 +		
    1.68 +	// reserved for future expansion
    1.69 +	TInt iReserved1;
    1.70 +	TInt iReserved2;
    1.71 +	TInt iReserved3;
    1.72 +	};
    1.73 +
    1.74 +/** 
    1.75 +This class is a specific implementation of TFrameFormatBase. An object of this class provides 
    1.76 +colour space and sampling information based on a specific image format code. 
    1.77 +*/
    1.78 +class TFrameFormat: public TFrameFormatBase
    1.79 +	{
    1.80 +public:	
    1.81 +	IMPORT_C explicit TFrameFormat(TUid aFormatCode);
    1.82 +	IMPORT_C TFrameFormatBase* DuplicateL() const;
    1.83 +	IMPORT_C TUid ColourSpace() const;
    1.84 +	IMPORT_C TUid Sampling() const;
    1.85 +	IMPORT_C TUid FormatCode() const;
    1.86 +
    1.87 +	IMPORT_C void SetColourSpace(TUid aColourSpace);	
    1.88 +	
    1.89 +private: 
    1.90 +	// The image frame colour space
    1.91 +	TUid	iColourSpace;
    1.92 +	// The frame sampling 
    1.93 +	TUid 	iSampling;
    1.94 +	// The image frame format code which uniquely identifies all other parameters. */  
    1.95 +	TUid 	iFormatCode; 
    1.96 +	};
    1.97 +
    1.98 +/** 
    1.99 +Base class for TFrameLayout. Individual subclasses are identified by their specific UID value.
   1.100 +These classes are used to describe the memory layout of a specific Image Frame. 
   1.101 +*/ 
   1.102 +class TFrameLayoutBase
   1.103 +	{	
   1.104 +public:	
   1.105 +	IMPORT_C TUid Type() const;
   1.106 +	
   1.107 +	/** 
   1.108 +	Creates a duplicate instance of the frame layout object on the heap.
   1.109 +	
   1.110 +	@return The pointer to the newly created object cast as class TFrameLayoutBase. 
   1.111 +	*/
   1.112 +	virtual TFrameLayoutBase* DuplicateL() const=0;
   1.113 +	
   1.114 +protected: 
   1.115 +	IMPORT_C explicit TFrameLayoutBase(TUid aType);
   1.116 +
   1.117 +private:
   1.118 +	// reserved for future expansion
   1.119 +	IMPORT_C virtual void Reserved1();
   1.120 +	IMPORT_C virtual void Reserved2();
   1.121 +	IMPORT_C virtual void Reserved3();
   1.122 +	IMPORT_C virtual void Reserved4();
   1.123 +			
   1.124 +private:
   1.125 +	// Layout specific type holder
   1.126 +	TUid iType; 
   1.127 +		
   1.128 +	// Reserved for future expansion
   1.129 +	TInt iReserved1;
   1.130 +	TInt iReserved2;
   1.131 +	TInt iReserved3;
   1.132 +	};
   1.133 +
   1.134 +/** 
   1.135 +Class TFrameLayout is a concrete implementation of TFrameLayoutBase class.
   1.136 +It serves as a container for parameters that describe the memory organisation of 
   1.137 +the data encapsulated by a specific CImageFrame object.
   1.138 +Image data is stored in planes. Each plane is characterised by  
   1.139 +the byte offset from the start of the image frame memory, and its maximum size, 
   1.140 +current length and scanlength.
   1.141 +*/	
   1.142 +class TFrameLayout: public TFrameLayoutBase
   1.143 +	{		
   1.144 + 		
   1.145 +public:
   1.146 +	IMPORT_C explicit TFrameLayout(TInt aPlanes);
   1.147 +	IMPORT_C TFrameLayoutBase* DuplicateL() const;	
   1.148 +	
   1.149 +    IMPORT_C TInt Planes() const;
   1.150 +	IMPORT_C TInt Start(TInt aIndex) const;
   1.151 +	IMPORT_C TInt Length(TInt aIndex) const;
   1.152 +	IMPORT_C TInt CurrentLength(TInt aIndex) const;
   1.153 +	IMPORT_C TInt ScanLength(TInt aIndex) const;
   1.154 +	
   1.155 +	IMPORT_C void SetStart(TInt aIndex, TInt aStart);
   1.156 +	IMPORT_C void SetLength(TInt aIndex, TInt aLength );
   1.157 +	IMPORT_C void SetCurrentLength(TInt aIndex, TInt aCurrentLength);
   1.158 +	IMPORT_C void SetScanLength(TInt aIndex, TInt aScanLength);
   1.159 +
   1.160 +private:
   1.161 +	// The number of planes in this image. Value < KMaxPlanesInFrame. 
   1.162 +	TInt iPlanes;				   
   1.163 +	// The offset of each plane from the start of the memory referenced by this image frame. 
   1.164 +	TInt iStart[KMaxPlanesInFrame]; 
   1.165 +	// The length of each image plane in bytes.
   1.166 +	TInt iLength[KMaxPlanesInFrame]; 
   1.167 +	// The length of the data stored in each image plane in bytes.
   1.168 +	TInt iCurrentLength[KMaxPlanesInFrame];	
   1.169 +	// The width of the stride for each plane.
   1.170 +	TInt iScanLength[KMaxPlanesInFrame];
   1.171 +	};
   1.172 +
   1.173 +/** 
   1.174 +CImageFrame class exposes an API for accessing binary image data in a uniform way.
   1.175 +It is implemented as a wrapper around TDes8 or RChunk objects. 
   1.176 +*/	
   1.177 +class CImageFrame : public CBase 
   1.178 +    {
   1.179 +public:  
   1.180 +    IMPORT_C static CImageFrame* NewL(const TDes8& aBuffer, TInt aMaxBufferSize);
   1.181 + 								  
   1.182 +    IMPORT_C static CImageFrame* NewL(const TDes8& aBuffer,
   1.183 +    								  TInt aMaxBufferSize, 
   1.184 +				 	   				  const TSize& aFrameSize, 
   1.185 +				 					  const TFrameFormatBase& aFrameFormat,
   1.186 +									  const TFrameLayoutBase& aFrameLayout); 
   1.187 +										  
   1.188 +	IMPORT_C static CImageFrame* NewL(const RChunk* aBuffer, 
   1.189 +									  TInt aMaxBufferSize,		
   1.190 +						   			  TInt aDataOffset);
   1.191 +
   1.192 +	IMPORT_C static CImageFrame* NewL(const RChunk* aBuffer,
   1.193 +									  TInt aMaxBufferSize, 
   1.194 +								      TInt aDataOffset, 
   1.195 +		 					 	  	  const TSize& aFrameSize,
   1.196 +		 					 	  	  const TFrameFormatBase& aFrameFormat,
   1.197 +		 					 	  	  const TFrameLayoutBase& aFrameLayout); 
   1.198 +    
   1.199 +	IMPORT_C virtual const TFrameFormatBase& FrameFormat() const;	
   1.200 +	IMPORT_C virtual void SetFrameFormatL(const TFrameFormatBase& aFormat);
   1.201 +	
   1.202 +	IMPORT_C virtual const TFrameLayoutBase& FrameLayout() const;	
   1.203 +	IMPORT_C virtual void SetFrameLayoutL(const TFrameLayoutBase& aFrameLayout);
   1.204 +
   1.205 +	IMPORT_C virtual const TSize& FrameSizeInPixels() const;	
   1.206 +	IMPORT_C virtual void SetFrameSizeInPixels(const TSize& aFrameSize);
   1.207 +
   1.208 +	IMPORT_C virtual TDes8& Data();
   1.209 +	IMPORT_C virtual const TDesC8& Data() const;
   1.210 +	
   1.211 +    IMPORT_C virtual TInt MaxBufferSize() const;
   1.212 +    IMPORT_C virtual TBool IsChunk() const;
   1.213 +
   1.214 +	IMPORT_C virtual RChunk& DataChunk();
   1.215 +	IMPORT_C virtual TInt DataOffset() const;
   1.216 +    
   1.217 +    IMPORT_C ~CImageFrame();
   1.218 +	
   1.219 +protected:
   1.220 +	IMPORT_C CImageFrame();
   1.221 +	
   1.222 +    IMPORT_C void ConstructL(const TDes8& aBuffer, TInt aMaxBufferSize);
   1.223 + 								  
   1.224 +    IMPORT_C void ConstructL(const TDes8& aBuffer, 
   1.225 +    						 TInt aMaxBufferSize,
   1.226 +				 	   		 const TSize& aFrameSize, 
   1.227 +				 			 const TFrameFormatBase& aFrameFormat,
   1.228 +							 const TFrameLayoutBase& aFrameLayout); 
   1.229 +										  
   1.230 +	IMPORT_C void ConstructL(const RChunk* aBuffer, 
   1.231 +							 TInt aMaxBufferSize, 
   1.232 +							 TInt aDataOffset);
   1.233 +
   1.234 +	IMPORT_C void ConstructL(const RChunk* aBuffer, 
   1.235 +							 TInt aMaxBufferSize,
   1.236 +						  	 TInt aDataOffset, 
   1.237 + 					 	     const TSize& aFrameSize,
   1.238 + 					 	  	 const TFrameFormatBase& aFrameFormat,									
   1.239 + 					 	  	 const TFrameLayoutBase& aFrameLayout); 
   1.240 +
   1.241 +private: 					 	  	 
   1.242 +	// for future development
   1.243 +	IMPORT_C virtual void Reserved1();
   1.244 +	IMPORT_C virtual void Reserved2();
   1.245 +	IMPORT_C virtual void Reserved3();
   1.246 +	IMPORT_C virtual void Reserved4();
   1.247 +	
   1.248 +private:
   1.249 +    class CBody; 
   1.250 +    CBody* iBody;
   1.251 +    };
   1.252 +
   1.253 +#endif // IMAGEFRAME_H