imaging/imagingfws/inc_pub/icl/ImageData.h
changeset 0 5752a19fdefe
equal deleted inserted replaced
-1:000000000000 0:5752a19fdefe
       
     1 // Copyright (c) 2001-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 __ImageData_h__
       
    17 #define __ImageData_h__
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <badesca.h>
       
    21 #include <gdi.h>
       
    22 #include <mm/mmcaf.h>
       
    23 
       
    24 class CFrameImageData;
       
    25 
       
    26 /**
       
    27 @publishedAll
       
    28 @released
       
    29 
       
    30 The abstract base class for all format-specific frame data variants.
       
    31 */
       
    32 class TFrameDataBlock
       
    33 	{
       
    34 public:
       
    35 	IMPORT_C TUid DataType() const;
       
    36 
       
    37 protected:
       
    38 	IMPORT_C TFrameDataBlock(TUid aDataType);
       
    39 	/**
       
    40 	Provides a copy of an object that manages a list of frame and image block data,
       
    41 	but not a bitwise copy. It provides a new reference to the object.
       
    42 	@param aFrameImageData An object that manages a list of frame and image block data
       
    43 	*/
       
    44 	virtual TFrameDataBlock* DuplicateL(CFrameImageData& aFrameImageData) const = 0;
       
    45 
       
    46 private:
       
    47 	TUid iDataType;
       
    48 	TInt iReserved1;
       
    49 	TInt iReserved2;
       
    50 	TInt iReserved3;
       
    51 
       
    52 friend class CFrameImageData;
       
    53 friend class RTImageDataTest;
       
    54 	};
       
    55 
       
    56 /**
       
    57 @publishedAll
       
    58 @released
       
    59 
       
    60 The abstract base class for all format-specific image data variants.
       
    61 */
       
    62 class TImageDataBlock
       
    63 	{
       
    64 public:
       
    65 	IMPORT_C TUid DataType() const;
       
    66 
       
    67 protected:
       
    68 	IMPORT_C TImageDataBlock(TUid aDataType);
       
    69 
       
    70 private:
       
    71 	virtual TImageDataBlock* DuplicateL(CFrameImageData& aFrameImageData) const = 0;
       
    72 
       
    73 private:
       
    74 	TUid iDataType;
       
    75 	TInt iReserved1;
       
    76 	TInt iReserved2;
       
    77 	TInt iReserved3;
       
    78 
       
    79 friend class CFrameImageData;
       
    80 friend class RTImageDataTest;
       
    81 	};
       
    82 
       
    83 
       
    84 class CImageDataArray;
       
    85 
       
    86 /**
       
    87 @publishedAll
       
    88 @released
       
    89 
       
    90 Class to manage lists of frame and image block data.
       
    91 */
       
    92 class CFrameImageData : public CBase
       
    93 	{
       
    94 public:
       
    95 	IMPORT_C static CFrameImageData* NewL();
       
    96 	IMPORT_C static CFrameImageData* NewL(CImageDataArray& aImageData, TBool aImageDataOwner = EFalse);
       
    97 	IMPORT_C CFrameImageData* AllocL() const;
       
    98 	IMPORT_C ~CFrameImageData();
       
    99 
       
   100 	// Access fns.
       
   101 	// Append/insert/delete
       
   102 	IMPORT_C TInt InsertImageData(const TImageDataBlock* aEntry, TInt aPos);
       
   103 	IMPORT_C TInt AppendImageData(const TImageDataBlock* aEntry);
       
   104 	IMPORT_C void RemoveImageData(TInt aIndex);
       
   105 
       
   106 	IMPORT_C TInt InsertFrameData(const TFrameDataBlock* aEntry, TInt aPos);
       
   107 	IMPORT_C TInt AppendFrameData(const TFrameDataBlock* aEntry);
       
   108 	IMPORT_C void RemoveFrameData(TInt aIndex);
       
   109 
       
   110 	// Get local image data.
       
   111 	IMPORT_C const TImageDataBlock* GetImageData(TInt aIndex) const;
       
   112 	IMPORT_C TImageDataBlock* GetImageData(TInt aIndex);
       
   113 
       
   114 	IMPORT_C const TFrameDataBlock* GetFrameData(TInt aIndex) const;
       
   115 	IMPORT_C TFrameDataBlock* GetFrameData(TInt aIndex);
       
   116 
       
   117 	// Get num entries.
       
   118 	IMPORT_C TInt ImageDataCount() const;
       
   119 	IMPORT_C TInt FrameDataCount() const;
       
   120 
       
   121 	// Append image buffers.
       
   122 	IMPORT_C TInt AppendImageBuffer(const HBufC8* aImageBuffer);
       
   123 
       
   124 private:
       
   125 	CFrameImageData(CImageDataArray& aImageData, TBool aImageDataOwner = EFalse);
       
   126 	IMPORT_C virtual void Reserved_1();
       
   127 	IMPORT_C virtual void Reserved_2();
       
   128 	IMPORT_C virtual void Reserved_3();
       
   129 	IMPORT_C virtual void Reserved_4();
       
   130 
       
   131 private:
       
   132 	// Image data for the frame. (Single frame formats)
       
   133 	// Image data that is the same for all frames. (Multi frame formats)
       
   134 	CImageDataArray& iImageData;
       
   135 	TBool iImageDataOwner;
       
   136 	
       
   137 	// Image data that is for this frame only. (Multi frame formats only)
       
   138 	RPointerArray<TFrameDataBlock> iFrameData;
       
   139 
       
   140 	TAny* iReserved;
       
   141 	};
       
   142 
       
   143 /**
       
   144 @publishedAll
       
   145 @released
       
   146 
       
   147 Class used to maintain frame information stored in
       
   148 codec specific resource files.
       
   149 */
       
   150 class CFrameInfoStrings : public CBase
       
   151 	{
       
   152 public:
       
   153 	IMPORT_C static CFrameInfoStrings* NewL();
       
   154 	IMPORT_C static CFrameInfoStrings* NewLC();
       
   155 	IMPORT_C ~CFrameInfoStrings();
       
   156 
       
   157 	IMPORT_C const TPtrC String(TInt aIndex) const;
       
   158 	IMPORT_C TInt Count() const;
       
   159 
       
   160 	IMPORT_C const TPtrC Decoder() const;
       
   161 	IMPORT_C void SetDecoderL(const TDesC& aString);
       
   162 	IMPORT_C const TPtrC Format() const;
       
   163 	IMPORT_C void SetFormatL(const TDesC& aString);
       
   164 	IMPORT_C const TPtrC Dimensions() const;
       
   165 	IMPORT_C void SetDimensionsL(const TDesC& aString);
       
   166 	IMPORT_C const TPtrC Depth() const;
       
   167 	IMPORT_C void SetDepthL(const TDesC& aString);
       
   168 	IMPORT_C const TPtrC Details() const;
       
   169 	IMPORT_C void SetDetailsL(const TDesC& aString);
       
   170 
       
   171 private:
       
   172 	CFrameInfoStrings();
       
   173 	void ConstructL();
       
   174 
       
   175 	void SetStringL(TInt aIndex, const TDesC& aString);
       
   176 
       
   177 private:
       
   178 
       
   179 	enum TFrameInfoStringIndex
       
   180 		{
       
   181 		EDecoder	= 0,
       
   182 		EFormat		= 1,
       
   183 		EDimensions = 2,
       
   184 		EDepth		= 3,
       
   185 		EDetails	= 4
       
   186 		};
       
   187 
       
   188 	CDesCArray* iFrameInfoStrings;
       
   189 	};
       
   190 
       
   191 /**
       
   192 @publishedAll
       
   193 @released
       
   194 
       
   195 General frame info provided by all plugins.
       
   196 */
       
   197 class TFrameInfo
       
   198 	{
       
   199 public:
       
   200 	/**
       
   201 	Flags that define the attributes of a frame. These can be combined using an OR operation.
       
   202 	*/
       
   203 	enum TFrameInfoFlags
       
   204 		{
       
   205 		/** Indicates whether or not the frame is colour.
       
   206 		*/
       
   207 		EColor					= 0x00000001,
       
   208 
       
   209 		/** Indicates if any part of the frame is transparent.
       
   210 		*/
       
   211 		ETransparencyPossible	= 0x00000002,
       
   212 
       
   213 		/** Indicates whether or not the frame can be scaled.
       
   214 		*/
       
   215 		EFullyScaleable			= 0x00000004,
       
   216 
       
   217 		/** Indicates whether or not the frame's aspect ratio must be maintained during scaling. If not
       
   218 		set, the frame can be stretched.
       
   219 		*/
       
   220 		EConstantAspectRatio	= 0x00000008,
       
   221 
       
   222 		/** Indicates if the frame can be decoded and drawn dithered. If this is not set, the bitmap
       
   223 		must use the recommended display mode. 
       
   224 		*/
       
   225 		ECanDither				= 0x00000010,
       
   226 
       
   227 		/** Indicates if the frame contains alpha-blending information. This setting is only valid if
       
   228 		ETransparencyPossible is set.
       
   229 		*/
       
   230 		EAlphaChannel			= 0x00000020,
       
   231 
       
   232 		/** Mutually exclusive image disposal method 1, no disposal specified. Image is not disposed
       
   233 		of and graphic is left in place.
       
   234 		*/
       
   235 		ELeaveInPlace			= 0x00000040,
       
   236 
       
   237 		/** Mutually exclusive image disposal method 2, restore to background colour. The area used
       
   238 		by the graphic must be restored to the background colour.
       
   239 		*/
       
   240 		ERestoreToBackground	= 0x00000080,
       
   241 
       
   242 		/** Mutually exclusive image disposal method 3, restore to previous. The decoder is required
       
   243 		to restore the area overwritten by the graphic with what was there prior to rendering the
       
   244 		graphic.
       
   245 		*/
       
   246 		ERestoreToPrevious		= 0x00000100,
       
   247 
       
   248 		/** If this flag is set and an image convert operation returns KErrUnderFlow, the partially
       
   249 		decoded bitmap is not suitable for display.
       
   250 		*/
       
   251 		EPartialDecodeInvalid   = 0x00000200,
       
   252 
       
   253 		/** This flag is used by Mng decoder to indicate that there are more frames to decode
       
   254 		*/
       
   255 		EMngMoreFramesToDecode   = 0x00000400,
       
   256 		
       
   257 		/** This flag is used to indicate that the code sets iFrameSizeInPixels
       
   258 		*/
       
   259 		EUsesFrameSizeInPixels = 0x00000800
       
   260 		};
       
   261 
       
   262 	/**
       
   263 	Indicates the current status of frame processing.
       
   264 	*/
       
   265 	enum TFrameInfoState
       
   266 		{
       
   267 		/** The frame information has not been initialised.
       
   268 		*/
       
   269 		EFrameInfoUninitialised,
       
   270 
       
   271 		/** The frame header is being processed.
       
   272 		*/
       
   273 		EFrameInfoProcessingFrameHeader,
       
   274 
       
   275 		/** The frame is being processed.
       
   276 		*/
       
   277 		EFrameInfoProcessingFrame,
       
   278 
       
   279 		/** The frame has been processed.
       
   280 		*/
       
   281 		EFrameInfoProcessingComplete
       
   282 		};
       
   283 public:
       
   284 	IMPORT_C TFrameInfoState CurrentFrameState() const;
       
   285 	IMPORT_C void SetCurrentFrameState(TFrameInfoState aFrameInfoState);
       
   286 	IMPORT_C TInt CurrentDataOffset() const;
       
   287 	IMPORT_C void SetCurrentDataOffset(TInt aOffset);
       
   288 	IMPORT_C TInt FrameDataOffset() const;
       
   289 	IMPORT_C void SetFrameDataOffset(TInt aOffset);
       
   290 public:
       
   291 	/**
       
   292 	The coordinates of the frame within the screen in pixels.
       
   293 	*/
       
   294 	TRect iFrameCoordsInPixels;
       
   295 
       
   296 	/**
       
   297 	The size of the frame in twips.
       
   298 	*/
       
   299 	TSize iFrameSizeInTwips;
       
   300 
       
   301 	/**
       
   302 	The number of bits per pixel for the frame.
       
   303 	*/
       
   304 	TInt iBitsPerPixel;
       
   305 
       
   306 	/**
       
   307 	The delay in microseconds before displaying the next frame.
       
   308 	*/
       
   309 	TTimeIntervalMicroSeconds iDelay;
       
   310 
       
   311 	/**
       
   312 	Frame information flags. A combination of the values contained in the TFrameInfoFlags enum.
       
   313 	*/
       
   314 	TUint32 iFlags;
       
   315 
       
   316 	/**
       
   317 	The size of the frame. A frame can occupy a rectangle within the overall image. In this case, 
       
   318 	the frame size is less than the overall image size.
       
   319 	For a GIF image, the following applies:
       
   320 	For the first frame of the image, iOverallSizeInPixels will be the greater of the logical screen size 
       
   321 	and the size of the first frame. The logical screen size is defined in the logical screen descriptor 
       
   322 	block of the GIF image. If the GIF is animated it will contain a set of frames. The first frame will 
       
   323 	be full size but subsequent frames are sub-frames and iOverallSizeInPixels may differ for each sub-frame.
       
   324 	*/
       
   325 	TSize iOverallSizeInPixels;
       
   326 
       
   327 	/**
       
   328 	The display mode for the frame.
       
   329 	*/
       
   330 	TDisplayMode iFrameDisplayMode;
       
   331 
       
   332 	/**
       
   333 	The background color for the frame.
       
   334 	*/
       
   335 	TRgb iBackgroundColor;
       
   336 
       
   337 private:	
       
   338 	TInt iFrameDataOffset;
       
   339 	TInt iCurrentDataOffset;
       
   340 	TFrameInfoState iCurrentFrameState;
       
   341 	
       
   342 public:
       
   343 	/**
       
   344 	The size of frame in pixels
       
   345 	*/
       
   346 	TSize iFrameSizeInPixels;
       
   347 
       
   348 private:
       
   349 	TInt iReserved_1;
       
   350 
       
   351 friend class CImageDecoderPriv;
       
   352 	};
       
   353 
       
   354 #endif //__ImageData_h__