epoc32/include/icl/imagecodec.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 // Copyright (c) 2002-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 #ifndef __IMAGECODEC_H__
    17 #define __IMAGECODEC_H__
    18 
    19 #include <e32std.h>
    20 #include <fbs.h>
    21 
    22 #ifndef SYMBIAN_ENABLE_SPLIT_HEADERS
    23 #include <icl/imagecodecdef.h>
    24 #endif
    25 
    26 // Pre-definitions needed to make sure everything always defined in the right order
    27 class TFrameInfo;
    28 class TImageDataBlock;
    29 class CFrameImageData;
    30 
    31 class CImageDecoder;
    32 class CImageEncoder;
    33 class CImageProcessor; 
    34 class CImageProcessorReadCodecBody;
    35 class CImageMaskProcessorReadCodecBody;
    36 
    37 /**
    38 @publishedAll
    39 @released
    40 
    41 Indicates what processing has so far been completed on the frame.
    42 */
    43 enum TFrameState
    44 	{
    45 	/** Processing incomplete.
    46 	*/
    47 	EFrameIncomplete,
    48 	/** Processing complete.
    49 	*/
    50 	EFrameComplete,
    51 	/** Unexpected end of frame data.
    52 	*/
    53 	EUnexpectedEndOfData,
    54 	/** Same as EFrameIncomplete but also requests a call to CImageReadCodec::GetNewDataPosition().
    55 	*/
    56 	EFrameIncompleteRepositionRequest,
    57 	/** Processing of streaming block is complete.
    58 	*/
    59 	EBlockComplete
    60 	};
    61 
    62 /**
    63 @publishedAll
    64 @released
    65 
    66 Utility class to allow forward iteration through the data contained in
    67 an 8 bit descriptor.
    68 
    69 @see TPtr8
    70 @see TPtrC8
    71 @see TDes8
    72 @see TDesC8
    73 */
    74 class TBufPtr8 : public TPtr8
    75 	{
    76 public:
    77 	/**
    78 	Default constructor.
    79 	*/
    80 	TBufPtr8()
    81 		: TPtr8(0, 0, 0) {};
    82 	inline void Set(const TDes8& aDes);
    83 	inline void SetLengthOnly(const TDes8& aDes);
    84 	inline void Set(const TPtrC8& aDes);
    85 	inline void Shift(TInt aOffset);
    86 	};
    87 
    88 /**
    89 Produces a shallow copy of the argument descriptor.
    90 
    91 @param  aDes
    92         A reference to the descriptor containing the relevant data.
    93 */
    94 inline void TBufPtr8::Set(const TDes8& aDes)
    95 	{
    96 	TPtr8::Set(CONST_CAST(TUint8*,aDes.Ptr()), aDes.Length(), aDes.MaxLength());
    97 	}
    98 
    99 /**
   100 Produces a shallow copy of the argument descriptor, but also restricts
   101 pointer access to the current actual size of the argument descriptor.
   102 
   103 @param  aDes
   104         A reference to the descriptor containing the relevant data.
   105 */
   106 inline void TBufPtr8::SetLengthOnly(const TDes8& aDes)
   107 	{
   108 	TPtr8::Set(CONST_CAST(TUint8*,aDes.Ptr()), aDes.Length(), aDes.Length());
   109 	}
   110 /**
   111 Produces a shallow copy of the argument descriptor, but restricts
   112 pointer access to the size of the const argument descriptor.
   113 
   114 @param  aDes
   115         A reference to the descriptor containing the relevant data.
   116 */
   117 inline void TBufPtr8::Set(const TPtrC8& aDes)
   118 	{
   119 	TPtr8::Set(CONST_CAST(TUint8*,aDes.Ptr()), aDes.Length(), aDes.Length());
   120 	}
   121 /**
   122 Seeks the current data pointer aOffset bytes from the current position.
   123 
   124 @param  aOffset
   125         The number of bytes by which to seek.
   126 */
   127 inline void TBufPtr8::Shift(TInt aOffset)
   128 	{
   129 	SetLength(Length() - aOffset); iMaxLength -= aOffset; iPtr += aOffset;
   130 	}
   131 
   132 /**
   133 @publishedAll
   134 @released
   135 
   136 Provides read related processing functions for bitmaps.
   137 
   138 Note: For use by plugin writers only.
   139 */
   140 class CImageReadCodec : public CBase
   141 	{
   142 public:
   143 	IMPORT_C ~CImageReadCodec();
   144 
   145 	/**
   146 	Performs initial processing of image data and mask bitmaps.
   147 
   148 	This function processes the image frame using data supplied in
   149 	aFrameInfo, aFrameImageData and using the flag aDisableErrorDiffusion. Not all codecs
   150 	are expected to make use of all fields.
   151 
   152 	This is a virtual function that each derived class must implement.
   153 
   154 	@param	aFrameInfo
   155 	        A reference to a TFrameInfo object.
   156 	@param	aFrameImageData
   157 	        A reference to a CFrameImageData object.
   158 	@param	aDisableErrorDiffusion
   159 	        A flag indicating whether error diffusion should be disabled.
   160 	@param	aDestination
   161 	        The destination bitmap.
   162 	@param	aDestinationMask
   163 	        The destination mask bitmap.
   164 	*/
   165 	virtual void InitFrameL(TFrameInfo& aFrameInfo, CFrameImageData& aFrameImageData, TBool aDisableErrorDiffusion, CFbsBitmap& aDestination, CFbsBitmap* aDestinationMask) = 0;
   166 
   167 	IMPORT_C virtual void InitFrameHeader(TFrameInfo& aFrameInfo, CFrameImageData& aFrameData);
   168 	IMPORT_C virtual TFrameState ProcessFrameHeaderL(TBufPtr8& aData);
   169 	IMPORT_C virtual void Complete(); // Called on frame completion and on underflow
   170 	IMPORT_C virtual void GetNewDataPosition(TInt& aPosition, TInt& aLength); // Returns a new position for the data stream, (also length of data required)
   171 
   172 	/**
   173 	Processes the frame data contained in aSrc.
   174 
   175 	This is a pure virtual function that each derived class must implement.
   176 
   177 	@param  aSrc
   178 	        A reference to the buffer containing the frame data.
   179 
   180 	@return	The current frame state after processing.
   181 	*/
   182 	virtual TFrameState ProcessFrameL(TBufPtr8& aSrc) = 0;
   183 	void SetCurrentFrame(TInt aFrameNumber);
   184 	
   185 	IMPORT_C virtual TInt ReductionFactor(const TSize& aOriginalSize, const TSize& aReducedSize) const;
   186 	IMPORT_C virtual TInt ReducedSize(const TSize& aOriginalSize,TInt aReductionFactor, TSize& aReducedSize) const;
   187 	
   188 protected:
   189 	IMPORT_C CImageReadCodec();
   190 	IMPORT_C void ConstructL();
   191 
   192 	IMPORT_C void ClearBitmapL(CFbsBitmap& aBitmap, TRgb aColor);
   193 	IMPORT_C TInt CurrentFrame() const;
   194 
   195 private:
   196 	// Future proofing
   197 	IMPORT_C virtual void ReservedVirtual1();
   198 	IMPORT_C virtual void ReservedVirtual2();
   199 	IMPORT_C virtual void ReservedVirtual3();
   200 	IMPORT_C virtual void ReservedVirtual4();
   201 
   202 private:
   203 	TInt iCurrentFrame; //make handle to body if additional properties are needed
   204 	};
   205 
   206 /**
   207 @publishedAll
   208 @released 
   209 
   210 Provides functions to determine or set features of the codec's CImageProcessor.
   211 
   212 Note: 
   213 For use by plugin writers only.
   214 */
   215 class CImageProcessorReadCodec : public CImageReadCodec
   216 	{
   217 public:
   218 	IMPORT_C ~CImageProcessorReadCodec();
   219 protected:
   220 	IMPORT_C CImageProcessorReadCodec();
   221 	IMPORT_C void ConstructL();
   222 
   223 	IMPORT_C CImageProcessor* ImageProcessor() const;
   224 	IMPORT_C void SetImageProcessor(CImageProcessor* aImageProc);
   225 
   226 	IMPORT_C const TPoint& Pos() const;
   227 	IMPORT_C TPoint& Pos();
   228 	IMPORT_C void SetPos(const TPoint& aPos);
   229 private:
   230 	CImageProcessorReadCodecBody* iBody;
   231 	};
   232 
   233 /**
   234 @publishedAll
   235 @released
   236 
   237 Provides functions to determine or set features of the codec's CImageProcessor for a bitmap mask.
   238 
   239 Note: For use by plugin writers only.
   240 */
   241 class CImageMaskProcessorReadCodec : public CImageProcessorReadCodec
   242 	{
   243 public:
   244 	IMPORT_C ~CImageMaskProcessorReadCodec();
   245 protected:
   246 	IMPORT_C CImageMaskProcessorReadCodec();
   247 	IMPORT_C void ConstructL();
   248 
   249 	IMPORT_C CImageProcessor* MaskProcessor() const;
   250 	IMPORT_C void SetMaskProcessor(CImageProcessor* aMaskProc);
   251 
   252 private:
   253 	CImageMaskProcessorReadCodecBody* iBody;
   254 	};
   255 
   256 
   257 /**
   258 @publishedAll
   259 @released
   260 
   261 Interface to be used by read codec implementations in conjunction with framework extension.
   262 */
   263 class MReadCodecExtension
   264 	{
   265 public:
   266 	/**
   267 	Obtains the scaling coefficient 
   268 	@param 	aOriginalSize	A reference to the original size of an image.
   269 	@param 	aDesiredSize	A reference to the desired size of an image.
   270 	@return	The scaling coefficient, for example:
   271 			Original size = 1 or -1,
   272 			Half original size = -2,
   273 			Quarter original size = -3 etc.
   274 	*/
   275 	virtual TInt ScalingCoefficient(const TSize& aOriginalSize, const TSize& aDesiredSize) const = 0;
   276 	
   277 	/**
   278 	Obtains the reduced size of the decoded bitmap based on the input parameters
   279 	and updates aReducedSize with this value.
   280 
   281 	@param  aOriginalSize		A reference to the original size of an image.
   282 	@param  aScalingCoeff		The scaling coefficient to be applied.
   283 	@param  aReducedSize		A reference to the new size of an image.
   284 	@return KErrNone			If the function call was successful.
   285 	@return 					A range of system wide error values.
   286 	*/
   287 	virtual TInt GetReducedSize(const TSize& aOriginalSize, TInt aScalingCoeff, TSize& aReducedSize) const = 0;	
   288 	};
   289 
   290 /**
   291 @publishedAll
   292 @released
   293 
   294 Provides functions to determine or set features of the codec's CImageProcessor plus
   295 provide extra functionality for Framework Extensions.
   296 
   297 Note: 
   298 For use by plugin writers only.
   299 */
   300 class CImageProcessorReadCodecExtension : public CImageProcessorReadCodec,
   301 										  public MReadCodecExtension											
   302 	{
   303 public:
   304 	IMPORT_C ~CImageProcessorReadCodecExtension();
   305 protected:
   306 	IMPORT_C CImageProcessorReadCodecExtension();
   307 	IMPORT_C void ConstructL();
   308 	
   309 	// From MReadCodecExtension
   310 	IMPORT_C TInt ScalingCoefficient(const TSize& aOriginalSize, const TSize& aDesiredSize) const;
   311 	IMPORT_C TInt GetReducedSize(const TSize& aOriginalSize, TInt aScalingCoeff, TSize& aReducedSize) const;
   312 	};
   313 
   314 /**
   315 @publishedAll
   316 @released
   317 
   318 
   319 Provides functions to determine or set features of the codec's CImageProcessor plus
   320 provide extra functionality for Framework Extensions.
   321 
   322 Note: 
   323 For use by plugin writers only.
   324 */
   325 class CImageMaskProcessorReadCodecExtension : public CImageMaskProcessorReadCodec,
   326 										  	  public MReadCodecExtension											
   327 	{
   328 public:
   329 	IMPORT_C ~CImageMaskProcessorReadCodecExtension();
   330 protected:
   331 	IMPORT_C CImageMaskProcessorReadCodecExtension();
   332 	IMPORT_C void ConstructL();
   333 	
   334 	// From MReadCodecExtension
   335 	IMPORT_C TInt ScalingCoefficient(const TSize& aOriginalSize, const TSize& aDesiredSize) const;
   336 	IMPORT_C TInt GetReducedSize(const TSize& aOriginalSize, TInt aScalingCoeff, TSize& aReducedSize) const;
   337 
   338 	};
   339 
   340 /**
   341 @publishedAll
   342 @released
   343 
   344 Provides read related processing functions for bitmaps.
   345 
   346 Note:
   347 For use by plugin writers only.
   348 */
   349 class CImageWriteCodec : public CBase
   350 	{
   351 public:
   352 	IMPORT_C ~CImageWriteCodec();
   353 	IMPORT_C virtual void InitFrameL(TBufPtr8& aDst, const CFbsBitmap& aSource);
   354 
   355 	/**
   356 	Processes the frame data contained in aDst.
   357 
   358 	The internally held buffer must have been previously set, either by InitFrameL() or by a 
   359 	SetSource().
   360 
   361 	This is a pure virtual function that each derived class must implement.
   362 
   363 	@param  aDst
   364 	        A reference to the buffer containing the frame data.
   365 
   366 	@return The current frame state after processing.
   367 	*/
   368 	virtual TFrameState ProcessFrameL(TBufPtr8& aDst) = 0;
   369 
   370 	IMPORT_C const CFbsBitmap* Source() const;
   371 	IMPORT_C void SetSource(const CFbsBitmap* aSource);
   372 protected:
   373 	IMPORT_C void ConstructL();
   374 	IMPORT_C CImageWriteCodec();
   375 private:
   376 	// Future proofing
   377 	IMPORT_C virtual void ReservedVirtual1();
   378 	IMPORT_C virtual void ReservedVirtual2();
   379 	IMPORT_C virtual void ReservedVirtual3();
   380 	IMPORT_C virtual void ReservedVirtual4();
   381 private:
   382 	const CFbsBitmap* iSource; // linked object
   383 	};
   384 
   385 /**
   386 @internalComponent
   387 
   388 Max size of strings in extra resource files
   389 */
   390 const TInt KCodecResourceStringMax=128;
   391 
   392 #endif // __IMAGECODEC_H__