imaging/imagingfws/src/ImageClientApi.cpp
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 #include <ecom/ecom.h>
       
    17 #include <bitdev.h>
       
    18 #include <bautils.h>
       
    19 #include <barsc.h>
       
    20 #include <caf/caf.h>
       
    21 using namespace ContentAccess;
       
    22 
       
    23 #include "ImageConversion.h"
       
    24 #include "ImageClientMain.h"
       
    25 #include "ImageResolverAPI.h"
       
    26 #include "ImageUtils.h"
       
    27 #include "ImageConvResolvrUtils.h"
       
    28 #include "ImageRelay.h"
       
    29 #include "icl/ImageConstruct.h"
       
    30 #include "icl/ImagePlugin.h"
       
    31 #include "ImageConversion.inl"
       
    32 #include "ImageCodecBody.h"
       
    33 #include "EnDecoderUtils.h"
       
    34 #include "icl/imageconversionextension.h"
       
    35 #include "fwextconstants.h"
       
    36 
       
    37 const TInt KMaxMimeLength = 256;
       
    38 const TInt KMinimumHeaderLength = 2;
       
    39 
       
    40 
       
    41 //
       
    42 // CImageTypeDescription
       
    43 //
       
    44 
       
    45 /**
       
    46 Constructs a new image type description entry.
       
    47 
       
    48 A leave occurs if there is insufficient memory available.
       
    49 
       
    50 @param  aDescription
       
    51         A description of the plugin decoder/encoder.
       
    52 @param  aImageType
       
    53         The plugin decoder/encoder type UID.
       
    54 @param  aSubType
       
    55         The plugin decoder/encoder sub-type UID.
       
    56 
       
    57 @return A pointer to the new image type description entry.
       
    58 */
       
    59 CImageTypeDescription* CImageTypeDescription::NewL(const TDesC& aDescription, const TUid aImageType, const TUid aSubType)
       
    60 	{
       
    61 	CImageTypeDescription* self = CImageTypeDescription::NewLC(aDescription, aImageType, aSubType);
       
    62 	CleanupStack::Pop();
       
    63 	return self;
       
    64 	}
       
    65 
       
    66 /**
       
    67 Constructs a new image type description entry. The new object created on the clean-up stack.
       
    68 
       
    69 A leave occurs if there is insufficient memory available.
       
    70 
       
    71 @param  aDescription
       
    72         A description of the plugin decoder/encoder.
       
    73 @param  aImageType
       
    74         The plugin decoder/encoder type UID.
       
    75 @param  aSubType
       
    76         The plugin decoder/encoder sub-type UID.
       
    77 
       
    78 @return A pointer to the new image type description entry.
       
    79 */
       
    80 CImageTypeDescription* CImageTypeDescription::NewLC(const TDesC& aDescription, const TUid aImageType, const TUid aSubType)
       
    81 	{
       
    82 	CImageTypeDescription* self = new(ELeave) CImageTypeDescription(aImageType, aSubType);
       
    83 	CleanupStack::PushL(self);
       
    84 	self->ConstructL(aDescription);
       
    85 	return self;
       
    86 	}
       
    87 
       
    88 
       
    89 /** 
       
    90 Default constructor. 
       
    91 @param aImageType 
       
    92            The plugin decoder/encoder type UID. 
       
    93 @param aSubType 
       
    94            The plugin decoder/encoder sub-type UID 
       
    95 */ 
       
    96 
       
    97 CImageTypeDescription::CImageTypeDescription(const TUid aImageType, const TUid aSubType)
       
    98 	: iImageType(aImageType), iSubType(aSubType)
       
    99 	{
       
   100 	}
       
   101 
       
   102 /** 
       
   103 Second phase constructor. 
       
   104 @param aDescription 
       
   105            A description of the plugin decoder/encoder. 
       
   106 */ 
       
   107 
       
   108 void CImageTypeDescription::ConstructL(const TDesC& aDescription)
       
   109 	{
       
   110 	iDescription = aDescription.AllocL();
       
   111 	}
       
   112 
       
   113 /**
       
   114 Destructor.
       
   115 */
       
   116 EXPORT_C CImageTypeDescription::~CImageTypeDescription()
       
   117 	{
       
   118 	delete iDescription;
       
   119 	}
       
   120 
       
   121 /**
       
   122 Returns the image description info.
       
   123 
       
   124 @return  A reference to the descriptor containing the description.
       
   125 */
       
   126 EXPORT_C const TDesC& CImageTypeDescription::Description() const
       
   127 	{
       
   128 	return *iDescription;
       
   129 	}
       
   130 
       
   131 /**
       
   132 Returns the image type info.
       
   133 
       
   134 @return The image type info as a TUid object.
       
   135 */
       
   136 EXPORT_C TUid CImageTypeDescription::ImageType() const
       
   137 	{
       
   138 	return iImageType;
       
   139 	}
       
   140 
       
   141 /**
       
   142 Returns the image sub-type information.
       
   143 
       
   144 @return The image sub-type information as a TUid object.
       
   145 */
       
   146 EXPORT_C TUid CImageTypeDescription::SubType() const
       
   147 	{
       
   148 	return iSubType;
       
   149 	}
       
   150 
       
   151 //
       
   152 // CFileExtensionMIMEType
       
   153 //
       
   154 
       
   155 /**
       
   156 Constructs a new file extension/MIME type entry.
       
   157 
       
   158 A leave occurs if there is insufficient memory available.
       
   159 
       
   160 @param  aExtn
       
   161         The file extension.
       
   162 @param  aMIMEType
       
   163         The associated MIME type.
       
   164 @param  aDisplayName The display name of the implementation 
       
   165 @param  aImageType The plugin decoder/encoder type UID. 
       
   166 @param  aImageSubType The plugin decoder/encoder sub-type UID. 
       
   167 @param  aImplementationUid The unique ID of the implementation. 
       
   168 @return A pointer to the new file extension/MIME type entry.
       
   169 */
       
   170 CFileExtensionMIMEType* CFileExtensionMIMEType::NewL(const TDesC8& aExtn, const TDesC8& aMIMEType, const TDesC& aDisplayName, TUid aImageType, TUid aImageSubType, TUid aImplementationUid)
       
   171 	{
       
   172 	CFileExtensionMIMEType* self = CFileExtensionMIMEType::NewLC(aExtn, aMIMEType, aDisplayName, aImageType, aImageSubType, aImplementationUid);
       
   173 	CleanupStack::Pop();
       
   174 	return self;
       
   175 	}
       
   176 
       
   177 /**
       
   178 Constructs a new file extension/MIME type entry. The new object is left on the clean-up stack.
       
   179 
       
   180 A leave occurs if there is insufficient memory available.
       
   181 
       
   182 @param  aExtn
       
   183         The file extension.
       
   184 @param  aMIMEType 
       
   185         The associated MIME type.
       
   186 @param  aDisplayName The display name of the implementation 
       
   187 @param  aImageType The plugin decoder/encoder type UID. 
       
   188 @param  aImageSubType The plugin decoder/encoder sub-type UID. 
       
   189 @param  aImplementationUid The unique ID of the implementation. 
       
   190 @return A pointer to the new file extension/MIME type entry.
       
   191 */
       
   192 EXPORT_C CFileExtensionMIMEType* CFileExtensionMIMEType::NewLC(const TDesC8& aExtn, const TDesC8& aMIMEType, const TDesC& aDisplayName, TUid aImageType, TUid aImageSubType, TUid aImplementationUid)
       
   193 	{
       
   194 	CFileExtensionMIMEType* self = new(ELeave) CFileExtensionMIMEType;
       
   195 	CleanupStack::PushL(self);
       
   196 	self->ConstructL(aExtn, aMIMEType, aDisplayName, aImageType, aImageSubType, aImplementationUid);
       
   197 	return self;
       
   198 	}
       
   199 /**
       
   200 Default constructor. 
       
   201 */
       
   202 CFileExtensionMIMEType::CFileExtensionMIMEType()
       
   203 	{
       
   204 	}
       
   205 
       
   206 /**
       
   207 Second phase constructor. 
       
   208 @param aExtn The file extension 
       
   209 @param aMIMEType The associated MIME type. 
       
   210 @param aDisplayName The display name of the implementation 
       
   211 @param aImageType The plugin decoder/encoder type UID. 
       
   212 @param aImageSubType The plugin decoder/encoder sub-type UID. 
       
   213 @param aImplementationUid The unique ID of the implementation. 
       
   214 */
       
   215 void CFileExtensionMIMEType::ConstructL(const TDesC8& aExtn, const TDesC8& aMIMEType, const TDesC& aDisplayName, TUid aImageType, TUid aImageSubType, TUid aImplementationUid)
       
   216 	{
       
   217 	iFileExtension = HBufC::NewL(aExtn.Length());
       
   218 	iFileExtension->Des().Copy(aExtn); // Create a 16 bit copy of the 8 bit original
       
   219 	ASSERT(iFileExtension->Length() == aExtn.Length());
       
   220 	iMIMEType = aMIMEType.AllocL();
       
   221 	ASSERT(iMIMEType->Length() == aMIMEType.Length());
       
   222 	iDisplayName = aDisplayName.AllocL();
       
   223 	iImageTypeUid = aImageType;
       
   224 	iImageSubTypeUid = aImageSubType;
       
   225 	iImplementationUid = aImplementationUid;
       
   226 	}
       
   227 
       
   228 /**
       
   229 Destructor.
       
   230 
       
   231 Frees all resources owned by the object prior to its destruction.
       
   232 */
       
   233 EXPORT_C CFileExtensionMIMEType::~CFileExtensionMIMEType()
       
   234 	{
       
   235 	delete iFileExtension;
       
   236 	delete iMIMEType;
       
   237 	delete iDisplayName;
       
   238 	}
       
   239 
       
   240 /**
       
   241 Returns the image file extension info.
       
   242 
       
   243 @return A reference to the descriptor containing the file extension.
       
   244 */
       
   245 EXPORT_C const TDesC& CFileExtensionMIMEType::FileExtension() const
       
   246 	{
       
   247 	return *iFileExtension;
       
   248 	}
       
   249 
       
   250 /**
       
   251 Returns the image MIME type info.
       
   252 
       
   253 @return A reference to the descriptor containing the MIME type.
       
   254 */
       
   255 EXPORT_C const TDesC8& CFileExtensionMIMEType::MIMEType() const
       
   256 	{
       
   257 	return *iMIMEType;
       
   258 	}
       
   259 
       
   260 /**
       
   261 Returns the human-readable plugin description.
       
   262 
       
   263 @return A reference to the display descriptor.
       
   264 */
       
   265 EXPORT_C const TDesC& CFileExtensionMIMEType::DisplayName() const
       
   266 	{
       
   267 	return *iDisplayName;
       
   268 	}
       
   269 
       
   270 /**
       
   271 Returns the image type associated with the plugin.
       
   272 
       
   273 @return The image type associated with the plugin
       
   274 */
       
   275 EXPORT_C TUid CFileExtensionMIMEType::ImageType() const
       
   276 	{
       
   277 	return iImageTypeUid;
       
   278 	}
       
   279 
       
   280 /**
       
   281 Returns the image sub-type associated with the plugin.
       
   282 
       
   283 @return The image sub-type associated with the plugin.
       
   284 */
       
   285 EXPORT_C TUid CFileExtensionMIMEType::ImageSubType() const
       
   286 	{
       
   287 	return iImageSubTypeUid;
       
   288 	}
       
   289 
       
   290 /**
       
   291 Returns the implementation UID of the plugin.
       
   292 
       
   293 @return	The implementation UID of the plugin.
       
   294 */
       
   295 EXPORT_C TUid CFileExtensionMIMEType::ImplementationUid() const
       
   296 	{
       
   297 	return iImplementationUid;
       
   298 	}
       
   299 
       
   300 //
       
   301 // CImplementationInformationType
       
   302 //
       
   303 
       
   304 /**
       
   305 Constructs a new implementation information object.
       
   306 
       
   307 @return A pointer to the new implementation information object.
       
   308 */
       
   309 
       
   310 CImplementationInformationType* CImplementationInformationType::NewL()
       
   311 	{
       
   312 	CImplementationInformationType* self = CImplementationInformationType::NewLC();
       
   313 	CleanupStack::Pop();
       
   314 	return self;
       
   315 	}
       
   316 
       
   317 // CImplementationInformationType transfer ownership of iDisplyName, iDataType and iOpaqueData
       
   318 
       
   319 /**
       
   320 Sets the contents of the CImplementationInformationType object.
       
   321 
       
   322 Use this variant of SetDataL() if the plugin is installed on a drive other than the default, which is zero.
       
   323 
       
   324 @param  aImplementationUid
       
   325         The unique ID of the implementation.
       
   326 @param  aVersion
       
   327         The version number of the implementation.
       
   328 @param  aDisplayName
       
   329         The display name of the implementation.
       
   330 @param  aDataType
       
   331         The data type supported by the implementation.
       
   332 @param  aOpaqueData
       
   333         Additional data for this implementation. This data is not used by the ECom framework.
       
   334 @param  aDrive
       
   335         The drive on which the plugin is installed.
       
   336 */
       
   337 void CImplementationInformationType::SetDataL(TUid aImplementationUid, TInt aVersion, const TDesC& aDisplayName, const TDesC8& aDataType, const TDesC8& aOpaqueData, TDriveUnit aDrive)
       
   338 	{
       
   339 	iImplementationUid = aImplementationUid;
       
   340 	iVersion = aVersion;
       
   341 
       
   342 	delete iDisplayName; iDisplayName = NULL;
       
   343 	iDisplayName = aDisplayName.AllocL();
       
   344 
       
   345 	delete iDataType; iDataType = NULL;
       
   346 	iDataType = aDataType.AllocL();
       
   347 
       
   348 	delete iOpaqueData; iOpaqueData = NULL;
       
   349 	iOpaqueData = aOpaqueData.AllocL();
       
   350 
       
   351 	iDrive = aDrive;
       
   352 	}
       
   353 
       
   354 /**
       
   355 Default constructor.
       
   356 
       
   357 This member is internal and not intended for use.
       
   358 */
       
   359 CImplementationInformationType::CImplementationInformationType()
       
   360 	{
       
   361 	}
       
   362 
       
   363 /**
       
   364 Constructs a new implementation information object. The new object is left on the clean-up stack.
       
   365 
       
   366 @return A pointer to the new implementation information object.
       
   367 */
       
   368 CImplementationInformationType* CImplementationInformationType::NewLC()
       
   369 	{
       
   370 	CImplementationInformationType* self = new(ELeave) CImplementationInformationType;
       
   371 	CleanupStack::PushL(self);
       
   372 	return self;
       
   373 	}
       
   374 
       
   375 /**
       
   376 Destructor.
       
   377 
       
   378 Frees all resources owned by the object prior to its destruction.
       
   379 */
       
   380 EXPORT_C CImplementationInformationType::~CImplementationInformationType()
       
   381 	{
       
   382 	delete iDisplayName;
       
   383 	delete iDataType;
       
   384 	delete iOpaqueData;
       
   385 	}
       
   386 
       
   387 
       
   388 /**
       
   389 Returns the implementation UID.
       
   390 
       
   391 @return The implementation UID as a TUid object.
       
   392 */
       
   393 EXPORT_C TUid CImplementationInformationType::ImplementationUid() const
       
   394 	{
       
   395 	return iImplementationUid;
       
   396 	}
       
   397 
       
   398 /**
       
   399 Returns the version number of the implementation.
       
   400 
       
   401 @return The version number of the implementation.
       
   402 */
       
   403 EXPORT_C TInt CImplementationInformationType::Version() const
       
   404 	{
       
   405 	return iVersion;
       
   406 	}
       
   407 
       
   408 /**
       
   409 Returns the display name of the implementation.
       
   410 
       
   411 @return A reference to the display name of the implementation.
       
   412 */
       
   413 EXPORT_C const TDesC& CImplementationInformationType::DisplayName() const
       
   414 	{
       
   415 	return *iDisplayName;
       
   416 	}
       
   417 
       
   418 /**
       
   419 Returns the data type supported by the implementation.
       
   420 
       
   421 @return A reference to the descriptor containing the data type.
       
   422 */
       
   423 EXPORT_C const TDesC8& CImplementationInformationType::DataType() const
       
   424 	{
       
   425 	return *iDataType;
       
   426 	}
       
   427 
       
   428 /**
       
   429 Returns the opaque binary data for the implementation.
       
   430 
       
   431 @return A reference to the descriptor containing the data.
       
   432 */
       
   433 EXPORT_C const TDesC8& CImplementationInformationType::OpaqueData() const
       
   434 	{
       
   435 	return *iOpaqueData;
       
   436 	}
       
   437 
       
   438 /**
       
   439 Returns the drive location information for the implementation.
       
   440 
       
   441 @return The drive location information as a TDriveUnit object.
       
   442 */
       
   443 EXPORT_C TDriveUnit CImplementationInformationType::Drive()
       
   444 	{
       
   445 	return iDrive;
       
   446 	}
       
   447 
       
   448 /**
       
   449 Function to sort an array of CFileExtensionMIMEType in ascending
       
   450 order of file extesion and MIME type.
       
   451 
       
   452 @param  aItem1
       
   453         The first element.
       
   454 @param  aItem2
       
   455         The second element.
       
   456 
       
   457 @return	An indication of the element swapping order.
       
   458 */
       
   459 TInt ImageEnDecoderUtils::SortAsending(const CFileExtensionMIMEType& aItem1, const CFileExtensionMIMEType& aItem2)
       
   460 	{
       
   461 	TInt result = aItem1.FileExtension().Compare(aItem2.FileExtension());
       
   462 	if(result==0)
       
   463 		result = aItem1.MIMEType().Compare(aItem2.MIMEType());
       
   464 	return result;
       
   465 	}
       
   466 
       
   467 // Used by the 4 decoder and encoder functions that return arrays of Uids and plugin descriptions
       
   468 void ImageEnDecoderUtils::DoGetImageTypesL(TUid aInterfaceUid, RImageTypeDescriptionArray& aImageTypeArray, TUid aBaseType)
       
   469 	{
       
   470 	RImplInfoPtrArray pluginArray; // Array to return matching plugins in
       
   471 	CleanupResetAndDestroyPushL(pluginArray);
       
   472 
       
   473 	CCustomMatchData* customMatchData = CCustomMatchData::NewLC();
       
   474 	TEComResolverParams resolverParams; // Parameters on which to match
       
   475 
       
   476 	customMatchData->SetMatchType(EListImageTypes);
       
   477 	customMatchData->SetBaseType(aBaseType);
       
   478 	customMatchData->SetSubType(KNullUid);
       
   479 	customMatchData->SetImplementationType(KNullUid);
       
   480 
       
   481 	HBufC8* package  = customMatchData->NewPackLC();
       
   482 	TPtr8 packageDes = package->Des();
       
   483 	resolverParams.SetDataType(packageDes);
       
   484 
       
   485 	REComSession::ListImplementationsL(aInterfaceUid, resolverParams, KImageConvertResolverUid, pluginArray);
       
   486 	if (pluginArray.Count() == 0)
       
   487 		User::Leave(KErrNotFound);
       
   488 
       
   489 	CleanupStack::PopAndDestroy(2); // package, customMatchData
       
   490 
       
   491 	// Transfer data to our array
       
   492 	for (TInt index = 0; index < pluginArray.Count(); index++)
       
   493 		{
       
   494 		COpaqueDataParse* parser = NULL;
       
   495 		TRAPD(error, parser = COpaqueDataParse::NewL(pluginArray[index]->OpaqueData()));
       
   496 		if (error!=KErrNone)
       
   497 			{
       
   498 			if (error==KErrNotSupported)
       
   499 				{
       
   500 				// means that the resource entry was not valid
       
   501 				continue;
       
   502 				}
       
   503 			else
       
   504 				User::Leave(error);
       
   505 			}
       
   506 
       
   507 		CleanupStack::PushL(parser);
       
   508 		CImageTypeDescription* imageTypeDescription = CImageTypeDescription::NewLC(pluginArray[index]->DisplayName(), parser->ImageTypeUid(), parser->ImageSubTypeUid());
       
   509 
       
   510 		TBool mustAppend = ETrue;
       
   511 		for(TInt i=0; i< aImageTypeArray.Count(); i++)
       
   512 			{
       
   513 			if(	aImageTypeArray[i]->ImageType().iUid == imageTypeDescription->ImageType().iUid &&
       
   514 				aImageTypeArray[i]->SubType().iUid == imageTypeDescription->SubType().iUid &&
       
   515 				(aImageTypeArray[i]->Description().Compare(imageTypeDescription->Description())) == 0)
       
   516 				{
       
   517 				// If here - image type implementation with same description is already in array.
       
   518 				mustAppend = EFalse;
       
   519 				CleanupStack::PopAndDestroy(imageTypeDescription); 
       
   520 				break;
       
   521 				}
       
   522 			}
       
   523 		if(mustAppend)
       
   524 			{
       
   525 			//A new image type implementation, add it to array.
       
   526 			User::LeaveIfError(aImageTypeArray.Append(imageTypeDescription));		
       
   527 			CleanupStack::Pop(imageTypeDescription); 
       
   528 			}
       
   529 		CleanupStack::PopAndDestroy(parser);
       
   530 		}
       
   531 	CleanupStack::PopAndDestroy(&pluginArray); 
       
   532 	}
       
   533 
       
   534 // Used by both the decoder and encoder functions that return arrays of file extensions and MIME types.
       
   535 // This function creates an array of each valid file extension along with the associated "primary"
       
   536 // (ie. first) MIME type plus the "secondary" MIME type(s).
       
   537 void ImageEnDecoderUtils::DoGetFileTypesL(TUid aInterfaceUid, RFileExtensionMIMETypeArray& aFileTypeArray)
       
   538 	{
       
   539 	RImplInfoPtrArray pluginArray; // Array to return matching plugins in
       
   540 	CleanupResetAndDestroyPushL(pluginArray);
       
   541 
       
   542 	CCustomMatchData* customMatchData = CCustomMatchData::NewLC();
       
   543 	TEComResolverParams resolverParams; // Parameters on which to match
       
   544 
       
   545 	customMatchData->SetMatchType(EListFileTypes);
       
   546 
       
   547 	HBufC8* package = customMatchData->NewPackLC();
       
   548 	TPtr8 packageDes = package->Des();
       
   549 	resolverParams.SetDataType(packageDes);
       
   550 
       
   551 	REComSession::ListImplementationsL(aInterfaceUid, resolverParams, KImageConvertResolverUid, pluginArray);
       
   552 	if (pluginArray.Count() == 0)
       
   553 		{
       
   554 		User::Leave(KErrNotFound);
       
   555 		}
       
   556 
       
   557 	CleanupStack::PopAndDestroy(2); // package, customMatchData
       
   558 
       
   559 	// Transfer data to our array
       
   560 	for (TInt index = 0; index < pluginArray.Count(); index++)
       
   561 		{
       
   562 		CImplementationInformation* implInfo = pluginArray[index];
       
   563 		COpaqueDataParse* parser = NULL;
       
   564 		TRAPD(error, parser = COpaqueDataParse::NewL(implInfo->OpaqueData()));
       
   565 		if (error != KErrNone)
       
   566 			{
       
   567 			if (error==KErrNotSupported)
       
   568 				{
       
   569 				// means that the resource entry was not valid
       
   570 				continue;
       
   571 				}
       
   572 			else
       
   573 				{
       
   574 				User::Leave(error);
       
   575 				}				
       
   576 			}
       
   577 
       
   578 		CleanupStack::PushL(parser);
       
   579   		if (parser->OnlyUidsAvail() || parser->IsSubCodec()) // ignore simple descriptions
       
   580 			{
       
   581 			CleanupStack::PopAndDestroy(); // parser
       
   582 			continue;
       
   583 			}
       
   584 		parser->EnsureMIMETypesReadL();
       
   585 
       
   586 		// Return all the MIME types specified in the resource file, not just the primary
       
   587 		// one by filling the file type array with elements created multiplicatively
       
   588 		// for each extension and each MIME type.
       
   589 
       
   590 		// use a blank MIME type if none provided by the plugin
       
   591 		const TBool blankMIMEType = (parser->MIMETypesCount() == 0);
       
   592 		const TInt numMIMETypes = blankMIMEType ? 1 : parser->MIMETypesCount();
       
   593 
       
   594 		//use a blank extension if not provided by plugin
       
   595 		const TBool blankExtn = (parser->ExtnsCount() == 0);
       
   596 		const TInt numExtns = blankExtn ? 1 : parser->ExtnsCount();
       
   597 
       
   598 		TLinearOrder<CFileExtensionMIMEType> sortFunction(SortAsending);
       
   599 		for (TInt index2 = 0; index2 < numExtns; index2++)
       
   600 			{
       
   601 			const TDesC8& extn = blankExtn ? KNullDesC8() : parser->Extn(index2);
       
   602 			for (TInt index3 = 0; index3 < numMIMETypes; index3++)
       
   603 				{
       
   604 				const TDesC8& MIMEType = blankMIMEType ? KNullDesC8() : parser->MIMEType(index3);
       
   605 				CFileExtensionMIMEType* fileExtensionMIMEType = CFileExtensionMIMEType::NewLC(  extn, MIMEType,
       
   606 																								implInfo->DisplayName(),
       
   607 																								parser->ImageTypeUid(),
       
   608 																								parser->ImageSubTypeUid(),
       
   609 																								implInfo->ImplementationUid());
       
   610 				//InsertInOrder will return KErrAlreadyExists if an entry already exists that
       
   611 				//has the same MIME type and file extension.  Thus, aFileTypeArray may not
       
   612 				//contain all implementation UIDs that are present. 
       
   613 				//We assume the resolver CImageConversionResolver::ListAllL() return highest version number first
       
   614 				//if calls succeed ownership is transferred
       
   615 				TInt error = aFileTypeArray.InsertInOrder(fileExtensionMIMEType, sortFunction);
       
   616 				if (error != KErrNone)
       
   617 					{
       
   618 					CleanupStack::PopAndDestroy(fileExtensionMIMEType);
       
   619 					if (error != KErrAlreadyExists)
       
   620 						{
       
   621 						User::Leave(error);
       
   622 						}
       
   623 					}
       
   624 				else
       
   625 					{
       
   626 					CleanupStack::Pop(fileExtensionMIMEType);				
       
   627 					}
       
   628 				}
       
   629 			}
       
   630 		CleanupStack::PopAndDestroy(parser);
       
   631 		}
       
   632 	CleanupStack::PopAndDestroy(&pluginArray); 
       
   633 	}
       
   634 
       
   635 // Used by the decoder and encoder functions to obtain the implementation information a specific codec
       
   636 void ImageEnDecoderUtils::DoGetImplementationInformationL(const TUid aInterfaceUid, CImplementationInformationType& aImplementationInformation, const TUid aImplementationUid)
       
   637 	{
       
   638 	RImplInfoPtrArray pluginArray; // Array to return matching plugins in
       
   639 	CleanupResetAndDestroyPushL(pluginArray);
       
   640 
       
   641 	CCustomMatchData* customMatchData = CCustomMatchData::NewLC();
       
   642 	TEComResolverParams resolverParams; // Parameters on which to match
       
   643 
       
   644 	customMatchData->SetMatchType(EMatchUids);
       
   645 	customMatchData->SetImplementationType(aImplementationUid);
       
   646 
       
   647 	HBufC8* package  = customMatchData->NewPackLC();
       
   648 	TPtr8 packageDes = package->Des();
       
   649 	resolverParams.SetDataType(packageDes);
       
   650 
       
   651 	REComSession::ListImplementationsL(aInterfaceUid, resolverParams, KImageConvertResolverUid, pluginArray);
       
   652 	if (pluginArray.Count() == 0)
       
   653 		User::Leave(KErrNotFound);
       
   654 
       
   655 	CleanupStack::PopAndDestroy(2); // package, customMatchData
       
   656 	
       
   657 	// Transfer data (if more than one is found take first)
       
   658 	CImplementationInformation* impInfo = pluginArray[0];
       
   659 	aImplementationInformation.SetDataL(impInfo->ImplementationUid(),
       
   660 										impInfo->Version(),
       
   661 										impInfo->DisplayName(),
       
   662 										impInfo->DataType(),
       
   663 										impInfo->OpaqueData(),
       
   664 										impInfo->Drive()
       
   665 										);
       
   666 
       
   667 	CleanupStack::PopAndDestroy(); // pluginArray
       
   668 	}
       
   669 
       
   670 // Used by the decoder and encoder functions to obtain the implementation properties of a specific codec
       
   671 // Since this function can be called by both CImageEncoder and CImageDecoder functions we must
       
   672 // use the generic TUint data type for the aOptions parameter rather than TOptions.
       
   673 void ImageEnDecoderUtils::DoGetPluginPropertiesL(const TUid aInterfaceUid, const TUid aImplementationUid, RUidDataArray& aPropertiesArray, const TUint aOptions)
       
   674 	{
       
   675 	RImplInfoPtrArray pluginArray; // Array to return matching plugins in
       
   676 	CleanupResetAndDestroyPushL(pluginArray);
       
   677 
       
   678 	CCustomMatchData* customMatchData = CCustomMatchData::NewLC();
       
   679 	TEComResolverParams resolverParams; // Parameters on which to match
       
   680 
       
   681 	customMatchData->SetMatchType(EMatchUids);
       
   682 	customMatchData->SetImplementationType(aImplementationUid);
       
   683 	customMatchData->SetOptions(CImageDecoder::TOptions(aOptions));
       
   684 	customMatchData->SetExtensionOptions(aOptions);
       
   685 
       
   686 	HBufC8* package  = customMatchData->NewPackLC();
       
   687 	TPtr8 packageDes = package->Des();
       
   688 	resolverParams.SetDataType(packageDes);
       
   689 
       
   690 	REComSession::ListImplementationsL(aInterfaceUid, resolverParams, KImageConvertResolverUid, pluginArray);
       
   691 	if (pluginArray.Count() == 0)
       
   692 		{
       
   693 		User::Leave(KErrNotFound);
       
   694 		}
       
   695 	
       
   696 	CleanupStack::PopAndDestroy(2); // package, customMatchData
       
   697 	
       
   698 	// Transfer data to our array
       
   699 	COpaqueDataParse* parser = NULL;
       
   700 	TRAPD(error, parser = COpaqueDataParse::NewL((pluginArray[0])->OpaqueData()));
       
   701 	if (error != KErrNone)
       
   702 		{
       
   703 		User::Leave(error);
       
   704 		}
       
   705 
       
   706 	CleanupStack::PushL(parser);
       
   707 	parser->EnsureBinaryPropertiesReadL();
       
   708 	parser->GetBinaryPropertiesArrayL(aPropertiesArray);
       
   709 	
       
   710 	CleanupStack::PopAndDestroy(2); // parser, &pluginArray
       
   711 	}
       
   712 
       
   713 // Used by the decoder and encoder functions to obtain the implementations (array of uids) that have the required properties and UIDs
       
   714 void ImageEnDecoderUtils::DoGetInterfaceImplementationsL(const TUid aInterfaceUid, const RUidDataArray& aRequiredUids, RUidDataArray& aImplArray)
       
   715 	{
       
   716 	RImplInfoPtrArray pluginArray; // Array to return matching plugins in
       
   717 	CleanupResetAndDestroyPushL(pluginArray);
       
   718 
       
   719 	CCustomMatchData* customMatchData = CCustomMatchData::NewLC();
       
   720 	TEComResolverParams resolverParams; // Parameters on which to match
       
   721 
       
   722 	customMatchData->SetMatchType(EMatchReqUids);
       
   723 	customMatchData->SetMatchReqUidsL(aRequiredUids);
       
   724 
       
   725 	HBufC8* package  = customMatchData->NewPackLC();
       
   726 	TPtr8 packageDes = package->Des();
       
   727 	resolverParams.SetDataType(packageDes);
       
   728 
       
   729 	REComSession::ListImplementationsL(aInterfaceUid, resolverParams, KImageConvertResolverUid, pluginArray);
       
   730 	if (pluginArray.Count() == 0)
       
   731 		{
       
   732 		User::Leave(KErrNotFound);
       
   733 		}
       
   734 	
       
   735 	CleanupStack::PopAndDestroy(2); // package, customMatchData
       
   736 	
       
   737 	// Transfer data to our array
       
   738 	aImplArray.Reset();
       
   739 	for (TInt index = 0; index < pluginArray.Count(); index++)
       
   740 		{
       
   741 		User::LeaveIfError(aImplArray.Append((pluginArray[index])->ImplementationUid()));
       
   742 		}
       
   743 	
       
   744 	CleanupStack::PopAndDestroy(&pluginArray);
       
   745 	}
       
   746 
       
   747 /**
       
   748 Static factory function for creating instances of CFrameImageData.
       
   749 The managed list of image data is created/destroyed internally.
       
   750 
       
   751 @return A pointer to a fully constructed CFrameImageData.
       
   752 */
       
   753 EXPORT_C CFrameImageData* CFrameImageData::NewL()
       
   754 	{
       
   755 	CImageDataArray* newImageData = new(ELeave) CImageDataArray;
       
   756 	CleanupStack::PushL(newImageData);
       
   757 
       
   758 	CFrameImageData* newFrameImageData = new(ELeave) CFrameImageData(*newImageData, ETrue);
       
   759 	CleanupStack::Pop(); // newImageData
       
   760 
       
   761 	return newFrameImageData;
       
   762 	}
       
   763 
       
   764 /**
       
   765 Static factory function for creating instances of CFrameImageData.
       
   766 
       
   767 The managed list of image data is created internally. If a data owner is specified then the responsibility
       
   768 for destroying the managed list is that of the owner. If no owner is specified the managed list is
       
   769 destroyed internally.
       
   770 
       
   771 @param  aImageData
       
   772         A reference to an externally created CImageDataArray.
       
   773 @param  aImageDataOwner
       
   774         If set to true, responsibility for deleting CImageDataArray
       
   775         is passed to the CFrameImageData object.
       
   776 
       
   777 @return A pointer to a fully constructed CFrameImageData.
       
   778 */
       
   779 EXPORT_C CFrameImageData* CFrameImageData::NewL(CImageDataArray& aImageData, TBool aImageDataOwner)
       
   780 	{
       
   781 	CFrameImageData* newFrameImageData = new(ELeave) CFrameImageData(aImageData, aImageDataOwner);
       
   782 	return newFrameImageData;
       
   783 	}
       
   784 
       
   785 CFrameImageData::CFrameImageData(CImageDataArray& aImageData, TBool aImageDataOwner)
       
   786 	: iImageData(aImageData),
       
   787 	iImageDataOwner(aImageDataOwner)
       
   788 	{
       
   789 	}
       
   790 
       
   791 /**
       
   792 Destructor for this class.
       
   793 
       
   794 If ownership of the image data was transfered, it is now destroyed.
       
   795 */
       
   796 EXPORT_C CFrameImageData::~CFrameImageData()
       
   797 	{
       
   798 	if (iImageDataOwner)
       
   799 		delete &iImageData;
       
   800 
       
   801 	iFrameData.ResetAndDestroy();
       
   802 	}
       
   803 
       
   804 /**
       
   805 Intended for future proofing - will panic if called.
       
   806 
       
   807 @panic  ImageConversion 30
       
   808 */
       
   809 EXPORT_C void CFrameImageData::Reserved_1()
       
   810 	{
       
   811 	Panic(EReservedCall);
       
   812 	}
       
   813 
       
   814 /**
       
   815 Intended for future proofing - will panic if called.
       
   816 
       
   817 @panic  ImageConversion 30
       
   818 */
       
   819 EXPORT_C void CFrameImageData::Reserved_2()
       
   820 	{
       
   821 	Panic(EReservedCall);
       
   822 	}
       
   823 
       
   824 /**
       
   825 Intended for future proofing - will panic if called.
       
   826 
       
   827 @panic  ImageConversion 30
       
   828 */
       
   829 EXPORT_C void CFrameImageData::Reserved_3()
       
   830 	{
       
   831 	Panic(EReservedCall);
       
   832 	}
       
   833 
       
   834 /**
       
   835 Intended for future proofing - will panic if called.
       
   836 
       
   837 @panic  ImageConversion 30
       
   838 */
       
   839 EXPORT_C void CFrameImageData::Reserved_4()
       
   840 	{
       
   841 	Panic(EReservedCall);
       
   842 	}
       
   843 
       
   844 /**
       
   845 @see     CFrameImageData::ImageDataCount().
       
   846 
       
   847 Inserts a pointer to an image data block into the internally held list in front
       
   848 of the item at position aPos.
       
   849 
       
   850 @param  aEntry
       
   851         The image data block pointer to be inserted.
       
   852 @param  aPos
       
   853         The position at which to insert the pointer into the internal list.
       
   854         Must not be less than 0 or greater than the value returned by
       
   855         CFrameImageData::ImageDataCount().
       
   856 
       
   857 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
       
   858         another of the system-wide error codes.
       
   859 */
       
   860 EXPORT_C TInt CFrameImageData::InsertImageData(const TImageDataBlock* aEntry, TInt aPos)
       
   861 	{
       
   862 	ASSERT(aEntry != NULL);
       
   863 	return iImageData.InsertImageData(aEntry, aPos);
       
   864 	}
       
   865 
       
   866 /**
       
   867 Adds a pointer to an image data block to the end of the internally held list.
       
   868 
       
   869 @param  aEntry
       
   870         The image data block pointer to be inserted.
       
   871 
       
   872 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
       
   873         another of the system-wide error codes.
       
   874 */
       
   875 EXPORT_C TInt CFrameImageData::AppendImageData(const TImageDataBlock* aEntry)
       
   876 	{
       
   877 	ASSERT(aEntry != NULL);
       
   878 	return iImageData.AppendImageData(aEntry);
       
   879 	}
       
   880 
       
   881 /**
       
   882 Removes a pointer to an image data block at position aIndex from the
       
   883 internally held list.
       
   884 
       
   885 @param  aIndex
       
   886         The index into the list. Must not be less than 0 or greater
       
   887         than the value returned by CFrameImageData::ImageDataCount().
       
   888 
       
   889 @see    CFrameImageData::ImageDataCount().
       
   890 */
       
   891 EXPORT_C void CFrameImageData::RemoveImageData(TInt aIndex)
       
   892 	{
       
   893 	iImageData.RemoveImageData(aIndex);
       
   894 	}
       
   895 
       
   896 /**
       
   897 Inserts a pointer to a frame data block into the internally held list in front
       
   898 of the item at position aPos.
       
   899 
       
   900 @param  aEntry
       
   901         The frame data block pointer to be inserted.
       
   902 @param  aPos
       
   903         The position at which to insert the pointer into the internal list. Must not be
       
   904 		less than 0 or greater than the value returned by CFrameImageData::FrameDataCount().
       
   905 
       
   906 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
       
   907         another of the system-wide error codes.
       
   908 
       
   909 @see    CFrameImageData::FrameDataCount()
       
   910 */
       
   911 EXPORT_C TInt CFrameImageData::InsertFrameData(const TFrameDataBlock* aEntry, TInt aPos)
       
   912 	{
       
   913 	ASSERT(aEntry != NULL);
       
   914 	return iFrameData.Insert(aEntry, aPos);
       
   915 	}
       
   916 
       
   917 /**
       
   918 Adds a pointer to a frame data block to the end of the internally held list.
       
   919 
       
   920 @param  aEntry
       
   921         The frame data block pointer to be inserted.
       
   922 
       
   923 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
       
   924         another of the system-wide error codes.
       
   925 */
       
   926 EXPORT_C TInt CFrameImageData::AppendFrameData(const TFrameDataBlock* aEntry)
       
   927 	{
       
   928 	ASSERT(aEntry != NULL);
       
   929 	return iFrameData.Append(aEntry);
       
   930 	}
       
   931 
       
   932 /**
       
   933 Removes a pointer to a frame data block at position aIndex from the
       
   934 internally held list.
       
   935 
       
   936 @param  aIndex
       
   937         Position of the pointer to delete. Must not be less than 0 or greater
       
   938         than the value returned by CFrameImageData::ImageDataCount().
       
   939 
       
   940 @see    CFrameImageData::FrameDataCount().
       
   941 */
       
   942 EXPORT_C void CFrameImageData::RemoveFrameData(TInt aIndex)
       
   943 	{
       
   944 	iFrameData.Remove(aIndex);
       
   945 	}
       
   946 
       
   947 /**
       
   948 Creates a full copy of the objects data.
       
   949 Ownership is transferred to the caller.
       
   950 
       
   951 @return  A pointer to the new copy of the frame data.
       
   952 */
       
   953 EXPORT_C CFrameImageData* CFrameImageData::AllocL() const
       
   954 	{
       
   955 	// Make copies of the TImageDataBlock arrays.
       
   956 	CImageDataArray* newImageData = new (ELeave) CImageDataArray;
       
   957 	CleanupStack::PushL(newImageData);
       
   958 
       
   959 	CFrameImageData* newFrameData = new (ELeave) CFrameImageData(*newImageData, ETrue);
       
   960 	CleanupStack::Pop(newImageData);
       
   961 	CleanupStack::PushL(newFrameData);
       
   962 
       
   963 	// Copy the contents.
       
   964 	TInt index;
       
   965 	TInt count = ImageDataCount();
       
   966 	for (index = 0 ; index<count ; index++)
       
   967 		{
       
   968 		const TImageDataBlock* imageData = GetImageData(index);
       
   969 		TImageDataBlock* tmpImageData = imageData->DuplicateL(*newFrameData);
       
   970 		CleanupDeletePushL(tmpImageData);
       
   971 
       
   972 		User::LeaveIfError(newFrameData->AppendImageData(tmpImageData));
       
   973 		CleanupStack::Pop(); // tmpImageData
       
   974 		}
       
   975 
       
   976 	count = FrameDataCount();
       
   977 	for (index = 0 ; index<count ; index++)
       
   978 		{
       
   979 		const TFrameDataBlock* frameData = GetFrameData(index);
       
   980 		TFrameDataBlock* tmpFrameData = frameData->DuplicateL(*newFrameData);
       
   981 		CleanupDeletePushL(tmpFrameData);
       
   982 
       
   983 		User::LeaveIfError(newFrameData->AppendFrameData(tmpFrameData));
       
   984 		CleanupStack::Pop(); // tmpFrameData
       
   985 		}
       
   986 
       
   987 	CleanupStack::Pop(newFrameData); // newFrameData
       
   988 	return newFrameData;
       
   989 	}
       
   990 
       
   991 /**
       
   992 Returns the image data block at the given position from the
       
   993 internally held list.
       
   994 
       
   995 @param  aIndex
       
   996         The position of the image data block to retrieve. Must be in the range 0 to ImageDataCount().
       
   997 
       
   998 @return A pointer to the image data block.
       
   999 */
       
  1000 EXPORT_C const TImageDataBlock* CFrameImageData::GetImageData(TInt aIndex) const
       
  1001 	{
       
  1002 	return iImageData.GetImageData(aIndex);
       
  1003 	}
       
  1004 
       
  1005 /**
       
  1006 Returns the image data block at the given position from the
       
  1007 internally held list.
       
  1008 
       
  1009 @param  aIndex
       
  1010         The position of the image data block to retrieve. Must be in the range 0 to ImageDataCount().
       
  1011 
       
  1012 @return A pointer to the image data block.
       
  1013 */
       
  1014 EXPORT_C TImageDataBlock* CFrameImageData::GetImageData(TInt aIndex)
       
  1015 	{
       
  1016 	return iImageData.GetImageData(aIndex);
       
  1017 	}
       
  1018 
       
  1019 /**
       
  1020 Const version.
       
  1021 
       
  1022 Returns the frame data block at the given position from the
       
  1023 internally held list.
       
  1024 
       
  1025 @param  aIndex
       
  1026         The position of the frame data block to retrieve. Must be in the range 0 to FrameDataCount().
       
  1027 
       
  1028 @return A pointer to the image data block.
       
  1029 */
       
  1030 EXPORT_C const TFrameDataBlock* CFrameImageData::GetFrameData(TInt aIndex) const
       
  1031 	{
       
  1032 	return iFrameData[aIndex];
       
  1033 	}
       
  1034 
       
  1035 /**
       
  1036 Non const version.
       
  1037 
       
  1038 Returns the frame data block at the given position from the
       
  1039 internally held list.
       
  1040 
       
  1041 @param  aIndex
       
  1042         The position of the frame data block to retrieve. Must be in the range 0 to FrameDataCount().
       
  1043 
       
  1044 @return A pointer to the image data block.
       
  1045 */
       
  1046 EXPORT_C TFrameDataBlock* CFrameImageData::GetFrameData(TInt aIndex)
       
  1047 	{
       
  1048 	return iFrameData[aIndex];
       
  1049 	}
       
  1050 
       
  1051 /**
       
  1052 Returns the number of image data blocks in the internally held list.
       
  1053 
       
  1054 @return The number of image data blocks.
       
  1055 */
       
  1056 EXPORT_C TInt CFrameImageData::ImageDataCount() const
       
  1057 	{
       
  1058 	return iImageData.ImageDataCount();
       
  1059 	}
       
  1060 
       
  1061 /**
       
  1062 Returns the number of frame data blocks in the internally held list.
       
  1063 
       
  1064 @return The number of image data blocks.
       
  1065 */
       
  1066 EXPORT_C TInt CFrameImageData::FrameDataCount() const
       
  1067 	{
       
  1068 	return iFrameData.Count();
       
  1069 	}
       
  1070 
       
  1071 /**
       
  1072 Stores the supplied image data in a newly allocated entry in the image buffer array.
       
  1073 
       
  1074 @param  aImageBuffer
       
  1075         The HBufC8 pointer to take ownership of.
       
  1076 
       
  1077 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
       
  1078         another of the system-wide error codes.
       
  1079 */
       
  1080 EXPORT_C TInt CFrameImageData::AppendImageBuffer(const HBufC8* aImageBuffer)
       
  1081 	{
       
  1082 	return iImageData.AppendImageBuffer(aImageBuffer);
       
  1083 	}
       
  1084 
       
  1085 // Codec virtual fns.
       
  1086 
       
  1087 // CImageReadCodec
       
  1088 
       
  1089 /**
       
  1090 Default constructor.
       
  1091 */
       
  1092 EXPORT_C CImageReadCodec::CImageReadCodec()
       
  1093 	{
       
  1094 	}
       
  1095 
       
  1096 /**
       
  1097 Second phase constructor.
       
  1098 */
       
  1099 EXPORT_C void CImageReadCodec::ConstructL()
       
  1100 	{
       
  1101 	// NO-OP - reserved in case we need to do Cheshire Cat at a later state. Should always be called.
       
  1102 	}
       
  1103 
       
  1104 /**
       
  1105 Destructor.
       
  1106 */
       
  1107 EXPORT_C CImageReadCodec::~CImageReadCodec()
       
  1108 	{
       
  1109 	}
       
  1110 
       
  1111 /**
       
  1112 Used to initialise the frame header data structures. 
       
  1113 
       
  1114 The default version of this function does nothing. It should be implemented by
       
  1115 the codec to at least update the appropriate processing state of the current
       
  1116 frame using its TFrameInfo structure.
       
  1117 
       
  1118 @param  aFrameInfo
       
  1119         A reference to a TFrameInfo object which will contain the current frame's header info
       
  1120 @param  aFrameData
       
  1121         A reference to a TFrameInfo object which will contain the current frame's header data
       
  1122 */
       
  1123 EXPORT_C void CImageReadCodec::InitFrameHeader(TFrameInfo& /*aFrameInfo*/, CFrameImageData& /*aFrameData*/)
       
  1124 	{
       
  1125 	}
       
  1126 
       
  1127 /**
       
  1128 Processes the header for one frame.
       
  1129 
       
  1130 The default version of this function and simply returns EFrameComplete.  It
       
  1131 should be implemented by the codec to at least update the appropriate
       
  1132 processing state of the current frame using its TFrameInfo structure.
       
  1133 
       
  1134 @param  aData
       
  1135         A reference to a TBufPtr8 that contains the frame data.
       
  1136 @return The completion status of this frame's processing
       
  1137 */
       
  1138 EXPORT_C TFrameState CImageReadCodec::ProcessFrameHeaderL(TBufPtr8& /*aData*/)
       
  1139 	{
       
  1140 	return EFrameComplete;
       
  1141 	}
       
  1142 
       
  1143 /**
       
  1144 Processes/displays converted image data.
       
  1145 
       
  1146 This function is called on frame completion and on underflow. The default version of this function
       
  1147 does nothing. It should be implemented by the codec if required. 
       
  1148 
       
  1149 If it is called on underflow for example, it can enable display of a partially decoded image. In such
       
  1150 cases this function could display all the image data up to the point of the underflow.
       
  1151 */
       
  1152 EXPORT_C void CImageReadCodec::Complete()
       
  1153 	{
       
  1154 	}
       
  1155 
       
  1156 /**
       
  1157 Returns a new position and number of bytes to read for the data stream.
       
  1158 
       
  1159 The default version of this function does nothing.
       
  1160 It should be implemented by the codec, if required.
       
  1161 
       
  1162 @param  aPosition
       
  1163         A reference to the returned new position.
       
  1164 @param  aLength
       
  1165         A reference to the number of bytes to read.
       
  1166 */
       
  1167 EXPORT_C void CImageReadCodec::GetNewDataPosition(TInt& /*aPosition*/, TInt& /*aLength*/)
       
  1168 	{
       
  1169 	}
       
  1170 
       
  1171 /**
       
  1172 @internalComponent
       
  1173 
       
  1174 Sets the current frame number.
       
  1175 Called by the framework before InitFrameHeader() and InitFrameL()
       
  1176 
       
  1177 @param  aFrameNumber
       
  1178         The current frame number
       
  1179 */
       
  1180 void CImageReadCodec::SetCurrentFrame(TInt aFrameNumber)
       
  1181 	{
       
  1182 	iCurrentFrame = aFrameNumber;
       
  1183 	}
       
  1184 
       
  1185 /**
       
  1186 Return the current frame number
       
  1187 
       
  1188 @return	The current frame number
       
  1189 */
       
  1190 EXPORT_C TInt CImageReadCodec::CurrentFrame() const
       
  1191 	{
       
  1192 	return iCurrentFrame;
       
  1193 	}
       
  1194 
       
  1195 /**
       
  1196 Calculates reduction factor based on the input parameters.
       
  1197 The default Implementation is given here. It should be implemented by the Codecs, If required.
       
  1198 
       
  1199 @param  aOriginalSize
       
  1200         A reference to the original size of an image.
       
  1201 @param  aReducedSize
       
  1202         A reference to the new size of an image.
       
  1203 @return The reduction factor.
       
  1204 */
       
  1205 
       
  1206 EXPORT_C TInt CImageReadCodec::ReductionFactor(const TSize& aOriginalSize,const TSize& aReducedSize) const
       
  1207    {
       
  1208    if( (aReducedSize.iWidth<=0) || (aReducedSize.iHeight<=0))
       
  1209       {
       
  1210       return 0;
       
  1211       }
       
  1212    TInt reductionFactor = 0;
       
  1213    TInt roundup=0;
       
  1214    while( ((aOriginalSize.iWidth+roundup)>>reductionFactor) > aReducedSize.iWidth || 
       
  1215          ((aOriginalSize.iHeight+roundup)>>reductionFactor) > aReducedSize.iHeight)
       
  1216       {
       
  1217       reductionFactor++;
       
  1218       roundup=(1<<reductionFactor)-1;
       
  1219       }
       
  1220    return reductionFactor;
       
  1221    }
       
  1222 
       
  1223 /**
       
  1224 Calculates reduced size of the decoded bitmap based on the input parameters and updates aReducedSize with this value.
       
  1225 The default Implementation is given here. It should be implemented by the Codecs, If required.
       
  1226 
       
  1227 @param  aOriginalSize
       
  1228         A reference to the original size of an image.
       
  1229 @param  aReducedFactor
       
  1230         The reduction factor to be applied
       
  1231 @param  aReducedSize
       
  1232         A reference to the new size of an image.
       
  1233 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
       
  1234         KErrArgument
       
  1235 */
       
  1236 
       
  1237 EXPORT_C TInt CImageReadCodec::ReducedSize(const TSize& aOriginalSize,TInt aReductionFactor, TSize& aReducedSize) const
       
  1238    {
       
  1239    aReducedSize = aOriginalSize;
       
  1240    if (aReductionFactor<0)
       
  1241    	   {
       
  1242    	   return KErrArgument;
       
  1243    	   }
       
  1244    TInt roundup = aReductionFactor>0? (1<<aReductionFactor)-1: 0;
       
  1245    aReducedSize.SetSize(((aOriginalSize.iWidth+roundup)>>aReductionFactor),
       
  1246                ((aOriginalSize.iHeight+roundup)>>aReductionFactor) );
       
  1247    return KErrNone;            
       
  1248    }
       
  1249 
       
  1250 /**
       
  1251 Intended for future proofing - will panic if called
       
  1252 
       
  1253 @panic  ImageConversion 30
       
  1254 */
       
  1255 EXPORT_C void CImageReadCodec::ReservedVirtual1()
       
  1256 	{
       
  1257 	Panic(EReservedCall);
       
  1258 	}
       
  1259 
       
  1260 /**
       
  1261 Intended for future proofing - will panic if called
       
  1262 
       
  1263 @panic  ImageConversion 30
       
  1264 */
       
  1265 EXPORT_C void CImageReadCodec::ReservedVirtual2()
       
  1266 	{
       
  1267 	Panic(EReservedCall);
       
  1268 	}
       
  1269 
       
  1270 /**
       
  1271 Intended for future proofing - will panic if called
       
  1272 
       
  1273 @panic  ImageConversion 30
       
  1274 */
       
  1275 EXPORT_C void CImageReadCodec::ReservedVirtual3()
       
  1276 	{
       
  1277 	Panic(EReservedCall);
       
  1278 	}
       
  1279 
       
  1280 /**
       
  1281 Intended for future proofing - will panic if called
       
  1282 
       
  1283 @panic  ImageConversion 30
       
  1284 */
       
  1285 EXPORT_C void CImageReadCodec::ReservedVirtual4()
       
  1286 	{
       
  1287 	Panic(EReservedCall);
       
  1288 	}
       
  1289 
       
  1290 // CImageProcessorReadCodec
       
  1291 
       
  1292 /**
       
  1293 Default constructor.
       
  1294 */
       
  1295 EXPORT_C CImageProcessorReadCodec::CImageProcessorReadCodec()
       
  1296 	{
       
  1297 	}
       
  1298 
       
  1299 /**
       
  1300 Second phase constructor.
       
  1301 */
       
  1302 EXPORT_C void CImageProcessorReadCodec::ConstructL()
       
  1303 	{
       
  1304 	CImageReadCodec::ConstructL();
       
  1305 
       
  1306 	iBody = CImageProcessorReadCodecBody::NewL();
       
  1307 	}
       
  1308 
       
  1309 /**
       
  1310 Destructor.
       
  1311 */
       
  1312 EXPORT_C CImageProcessorReadCodec::~CImageProcessorReadCodec()
       
  1313 	{
       
  1314 	delete iBody;
       
  1315 	}
       
  1316 
       
  1317 /**
       
  1318 Returns a pointer to the codec's CImageProcessor.
       
  1319 
       
  1320 @return	A pointer to the codec's CImageProcessor derived object.
       
  1321 */
       
  1322 EXPORT_C CImageProcessor* CImageProcessorReadCodec::ImageProcessor() const
       
  1323 	{
       
  1324 	return iBody->ImageProcessor();
       
  1325 	}
       
  1326 
       
  1327 /**
       
  1328 Sets the codec's CImageProcessor.
       
  1329 
       
  1330 Ownership is transferred.
       
  1331 
       
  1332 @param  aImageProc
       
  1333         A pointer to a full constructed CImageProcessor derived object.
       
  1334 */
       
  1335 EXPORT_C void CImageProcessorReadCodec::SetImageProcessor(CImageProcessor *aImageProc)
       
  1336 	{
       
  1337 	iBody->SetImageProcessor(aImageProc);
       
  1338 	}
       
  1339 
       
  1340 /**
       
  1341 Returns the current position within the bitmap (const version).
       
  1342 
       
  1343 @return	A reference to a TPoint object specifying the location.
       
  1344 */
       
  1345 EXPORT_C const TPoint& CImageProcessorReadCodec::Pos() const
       
  1346 	{
       
  1347 	return iBody->Pos();
       
  1348 	}
       
  1349 
       
  1350 /**
       
  1351 Returns the current position within the bitmap (non const version).
       
  1352 
       
  1353 @return	A reference to a TPoint object specifying the location.
       
  1354 */
       
  1355 EXPORT_C TPoint& CImageProcessorReadCodec::Pos()
       
  1356 	{
       
  1357 	return iBody->Pos();
       
  1358 	}
       
  1359 
       
  1360 /**
       
  1361 Sets the current position within the bitmap.
       
  1362 
       
  1363 @param  aPos
       
  1364         A reference to a TPoint object specifying the location.
       
  1365 */
       
  1366 EXPORT_C void CImageProcessorReadCodec::SetPos(const TPoint& aPos)
       
  1367 	{
       
  1368 	iBody->SetPos(aPos);
       
  1369 	}
       
  1370 
       
  1371 // CImageMaskProcessorReadCodec
       
  1372 
       
  1373 /**
       
  1374 Default constructor.
       
  1375 */
       
  1376 EXPORT_C CImageMaskProcessorReadCodec::CImageMaskProcessorReadCodec()
       
  1377 	{
       
  1378 	}
       
  1379 
       
  1380 /**
       
  1381 Second phase constructor.
       
  1382 */
       
  1383 EXPORT_C void CImageMaskProcessorReadCodec::ConstructL()
       
  1384 	{
       
  1385 	CImageProcessorReadCodec::ConstructL();
       
  1386 
       
  1387 	iBody = CImageMaskProcessorReadCodecBody::NewL();
       
  1388 	}
       
  1389 
       
  1390 /**
       
  1391 Destructor.
       
  1392 */
       
  1393 EXPORT_C CImageMaskProcessorReadCodec::~CImageMaskProcessorReadCodec()
       
  1394 	{
       
  1395 	delete iBody;
       
  1396 	}
       
  1397 
       
  1398 /**
       
  1399 Returns a pointer to the codec's CImageProcessor used when decoding
       
  1400 the image mask.
       
  1401 
       
  1402 @return	A pointer to the codec's CImageProcessor derived object.
       
  1403 */
       
  1404 EXPORT_C CImageProcessor* CImageMaskProcessorReadCodec::MaskProcessor() const
       
  1405 	{
       
  1406 	return iBody->MaskProcessor();
       
  1407 	}
       
  1408 
       
  1409 /**
       
  1410 Replaces a codec's existing CImageProcessor with a new fully constructed instance of the same
       
  1411 object. 
       
  1412 
       
  1413 Ownership of the new instance is transferred.
       
  1414 
       
  1415 @param  aMaskProc
       
  1416         A pointer to a full constructed CImageProcessor derived object.
       
  1417 */
       
  1418 EXPORT_C void CImageMaskProcessorReadCodec::SetMaskProcessor(CImageProcessor *aMaskProc)
       
  1419 	{
       
  1420 	iBody->SetMaskProcessor(aMaskProc);
       
  1421 	}
       
  1422 
       
  1423 /**
       
  1424 Constructor for this class.
       
  1425 */
       
  1426 EXPORT_C CImageProcessorReadCodecExtension::CImageProcessorReadCodecExtension()
       
  1427 	{
       
  1428 	}
       
  1429 
       
  1430 EXPORT_C void CImageProcessorReadCodecExtension::ConstructL()
       
  1431 	{
       
  1432 	CImageProcessorReadCodec::ConstructL();
       
  1433 	}
       
  1434 
       
  1435 /**
       
  1436 Destructor for this class.
       
  1437 */
       
  1438 EXPORT_C CImageProcessorReadCodecExtension::~CImageProcessorReadCodecExtension()
       
  1439 	{
       
  1440 	}
       
  1441 
       
  1442 EXPORT_C TInt CImageProcessorReadCodecExtension::ScalingCoefficient(const TSize& aOriginalSize, const TSize& aDesiredSize) const
       
  1443 	{
       
  1444 	TInt reductionFactor = ReductionFactor(aOriginalSize, aDesiredSize);
       
  1445 	return -(reductionFactor+1);
       
  1446 	}
       
  1447 
       
  1448 EXPORT_C TInt CImageProcessorReadCodecExtension::GetReducedSize(const TSize& aOriginalSize, TInt aScalingCoeff, TSize& aReducedSize) const
       
  1449 	{
       
  1450 	return ReducedSize(aOriginalSize, -(aScalingCoeff+1), aReducedSize);
       
  1451 	}
       
  1452 
       
  1453 EXPORT_C CImageMaskProcessorReadCodecExtension::CImageMaskProcessorReadCodecExtension()
       
  1454 	{
       
  1455 	}
       
  1456 
       
  1457 EXPORT_C void CImageMaskProcessorReadCodecExtension::ConstructL()
       
  1458 	{
       
  1459 	CImageMaskProcessorReadCodec::ConstructL();
       
  1460 	}
       
  1461 
       
  1462 EXPORT_C CImageMaskProcessorReadCodecExtension::~CImageMaskProcessorReadCodecExtension()
       
  1463 	{
       
  1464 	}
       
  1465 
       
  1466 EXPORT_C TInt CImageMaskProcessorReadCodecExtension::ScalingCoefficient(const TSize& aOriginalSize, const TSize& aDesiredSize) const
       
  1467 	{
       
  1468 	TInt reductionFactor = ReductionFactor(aOriginalSize, aDesiredSize);
       
  1469 	return -(reductionFactor+1);
       
  1470 	}
       
  1471 
       
  1472 EXPORT_C TInt CImageMaskProcessorReadCodecExtension::GetReducedSize(const TSize& aOriginalSize, TInt aScalingCoeff, TSize& aReducedSize) const
       
  1473 	{
       
  1474 	return ReducedSize(aOriginalSize, -(aScalingCoeff+1), aReducedSize);
       
  1475 	}
       
  1476 
       
  1477 // CImageWriteCodec
       
  1478 
       
  1479 /**
       
  1480 Default constructor.
       
  1481 */
       
  1482 EXPORT_C CImageWriteCodec::CImageWriteCodec()
       
  1483 	{
       
  1484 	}
       
  1485 
       
  1486 /**
       
  1487 Second phase constructor.
       
  1488 */
       
  1489 EXPORT_C void CImageWriteCodec::ConstructL()
       
  1490 	{
       
  1491 	// NO-OP - reserved in case we need to do Cheshire Cat at a later state. Should always be called.
       
  1492 	}
       
  1493 
       
  1494 /**
       
  1495 Destructor.
       
  1496 */
       
  1497 EXPORT_C CImageWriteCodec::~CImageWriteCodec()
       
  1498 	{
       
  1499 	}
       
  1500 
       
  1501 /**
       
  1502 Performs initial processing of image data from an internally held buffer.
       
  1503 
       
  1504 Used to initialise the frame header. The default version of this function does nothing.
       
  1505 It should be implemented by the codec, if required.
       
  1506 
       
  1507 @param  aDst
       
  1508         The destination buffer.
       
  1509 @param  aSource
       
  1510         The source internally held buffer.
       
  1511 */
       
  1512 EXPORT_C void CImageWriteCodec::InitFrameL(TBufPtr8& /*aDst*/, const CFbsBitmap& /*aSource*/)
       
  1513 	{
       
  1514 	}
       
  1515 
       
  1516 /**
       
  1517 Returns the codec's source bitmap.
       
  1518 
       
  1519 @return	A pointer to the codec's source bitmap.
       
  1520 */
       
  1521 EXPORT_C const CFbsBitmap* CImageWriteCodec::Source() const
       
  1522 	{
       
  1523 	return iSource;
       
  1524 	}
       
  1525 
       
  1526 /**
       
  1527 Sets the codec's source bitmap.
       
  1528 
       
  1529 Use this function if you need to process more than one internally held buffer. This 
       
  1530 will be necessary if, for example, you need to add a bitmap mask to the destination buffer. 
       
  1531 
       
  1532 @param  aSource
       
  1533         A pointer to the codec's source bitmap.
       
  1534 */
       
  1535 EXPORT_C void CImageWriteCodec::SetSource(const CFbsBitmap* aSource)
       
  1536 	{
       
  1537 	iSource = aSource;
       
  1538 	}
       
  1539 
       
  1540 
       
  1541 /**
       
  1542 Intended for future proofing - will panic if called
       
  1543 
       
  1544 @panic  ImageConversion 30
       
  1545 */
       
  1546 EXPORT_C void CImageWriteCodec::ReservedVirtual1()
       
  1547 	{
       
  1548 	Panic(EReservedCall);
       
  1549 	}
       
  1550 
       
  1551 /**
       
  1552 Intended for future proofing - will panic if called
       
  1553 
       
  1554 @panic  ImageConversion 30
       
  1555 */
       
  1556 EXPORT_C void CImageWriteCodec::ReservedVirtual2()
       
  1557 	{
       
  1558 	Panic(EReservedCall);
       
  1559 	}
       
  1560 
       
  1561 /**
       
  1562 Intended for future proofing - will panic if called
       
  1563 
       
  1564 @panic  ImageConversion 30
       
  1565 */
       
  1566 EXPORT_C void CImageWriteCodec::ReservedVirtual3()
       
  1567 	{
       
  1568 	Panic(EReservedCall);
       
  1569 	}
       
  1570 
       
  1571 /**
       
  1572 Intended for future proofing - will panic if called
       
  1573 
       
  1574 @panic  ImageConversion 30
       
  1575 */
       
  1576 EXPORT_C void CImageWriteCodec::ReservedVirtual4()
       
  1577 	{
       
  1578 	Panic(EReservedCall);
       
  1579 	}
       
  1580 
       
  1581 // CFrameInfoStrings fns.
       
  1582 
       
  1583 CFrameInfoStrings::CFrameInfoStrings()
       
  1584 	{
       
  1585 	}
       
  1586 
       
  1587 /**
       
  1588 Static factory function for creating instances of CFrameInfoStrings.
       
  1589 Leaves the newly allocated object on the cleanup stack.
       
  1590 
       
  1591 @return A pointer to a fully constructed CFrameInfoStrings.
       
  1592 */
       
  1593 EXPORT_C CFrameInfoStrings* CFrameInfoStrings::NewLC()
       
  1594 	{
       
  1595 	CFrameInfoStrings* result = new (ELeave) CFrameInfoStrings;
       
  1596 	CleanupStack::PushL(result);
       
  1597 	result->ConstructL();
       
  1598 	return result;
       
  1599 	}
       
  1600 
       
  1601 /**
       
  1602 Static factory function for creating instances of CFrameInfoStrings.
       
  1603 
       
  1604 @return A pointer to a fully constructed CFrameInfoStrings.
       
  1605 */
       
  1606 EXPORT_C CFrameInfoStrings* CFrameInfoStrings::NewL()
       
  1607 	{
       
  1608 	CFrameInfoStrings* result = NewLC();
       
  1609 	CleanupStack::Pop(result);
       
  1610 	return result;
       
  1611 	}
       
  1612 
       
  1613 /**
       
  1614 Destructor.
       
  1615 
       
  1616 Frees all resources owned by the object prior to its destruction.
       
  1617 */
       
  1618 EXPORT_C CFrameInfoStrings::~CFrameInfoStrings()
       
  1619 	{
       
  1620 	delete iFrameInfoStrings;
       
  1621 	}
       
  1622 
       
  1623 void CFrameInfoStrings::ConstructL()
       
  1624 	{
       
  1625 	iFrameInfoStrings = new (ELeave) CDesC16ArrayFlat(6);
       
  1626 	}
       
  1627 
       
  1628 void CFrameInfoStrings::SetStringL(TInt aIndex, const TDesC& aString)
       
  1629 	{
       
  1630 	// ensure we have enough to just append to - as standard case
       
  1631 	const TInt minRequired = aIndex;
       
  1632 	while (iFrameInfoStrings->Count() < minRequired)
       
  1633 		iFrameInfoStrings->AppendL(KNullDesC);
       
  1634 
       
  1635 	if (iFrameInfoStrings->Count()==minRequired)
       
  1636 		iFrameInfoStrings->AppendL(aString);
       
  1637 	else
       
  1638 		{
       
  1639 		// delete the original and insert
       
  1640 		iFrameInfoStrings->Delete(aIndex);
       
  1641 		iFrameInfoStrings->InsertL(aIndex, aString);
       
  1642 		}
       
  1643 
       
  1644 	ASSERT(String(aIndex)==aString);
       
  1645 	}
       
  1646 
       
  1647 /**
       
  1648 Returns the string at position aIndex in the string table.
       
  1649 The index runs from 0 to CFrameInfoStrings::Count() - 1.
       
  1650 
       
  1651 @param  aIndex
       
  1652         The position of the string to retrieve.
       
  1653 
       
  1654 @return	A pointer to the string at the given index.
       
  1655 */
       
  1656 EXPORT_C const TPtrC CFrameInfoStrings::String(TInt aIndex) const
       
  1657 	{
       
  1658 	ASSERT(aIndex < iFrameInfoStrings->Count());
       
  1659 	return (*iFrameInfoStrings)[aIndex];
       
  1660 	}
       
  1661 
       
  1662 /**
       
  1663 Returns the number of strings in the string table.
       
  1664 
       
  1665 @return	Returns the number of entries in the string table.
       
  1666 */
       
  1667 EXPORT_C TInt CFrameInfoStrings::Count() const
       
  1668 	{
       
  1669 	return iFrameInfoStrings->Count();
       
  1670 	}
       
  1671 
       
  1672 /**
       
  1673 Returns a pointer to the 'decoder' entry string from this object.
       
  1674 
       
  1675 @return	A read-only pointer to the returned string.
       
  1676 */
       
  1677 EXPORT_C const TPtrC CFrameInfoStrings::Decoder() const
       
  1678 	{
       
  1679 	return String(EDecoder);
       
  1680 	}
       
  1681 
       
  1682 /**
       
  1683 Adds the supplied string to this object as the 'decoder' entry.
       
  1684 
       
  1685 @param  aString
       
  1686         A descriptor containing the string to add.
       
  1687 */
       
  1688 EXPORT_C void CFrameInfoStrings::SetDecoderL(const TDesC& aString)
       
  1689 	{
       
  1690 	SetStringL(EDecoder, aString);
       
  1691 	}
       
  1692 
       
  1693 /**
       
  1694 Retruns a pointer to the 'format' entry string from this object.
       
  1695 
       
  1696 @return	A pointer to the returned read-only string.
       
  1697 */
       
  1698 EXPORT_C const TPtrC CFrameInfoStrings::Format() const
       
  1699 	{
       
  1700 	return String(EFormat);
       
  1701 	}
       
  1702 
       
  1703 /**
       
  1704 Adds the supplied string to this object as the 'format' entry.
       
  1705 
       
  1706 @param  aString
       
  1707         A descriptor containing the string to add.
       
  1708 */
       
  1709 EXPORT_C void CFrameInfoStrings::SetFormatL(const TDesC& aString)
       
  1710 	{
       
  1711 	SetStringL(EFormat, aString);
       
  1712 	}
       
  1713 
       
  1714 /**
       
  1715 Returns a pointer to the 'dimensions' entry string from this object.
       
  1716 
       
  1717 @return	A pointer to the returned read-only string.
       
  1718 */
       
  1719 EXPORT_C const TPtrC CFrameInfoStrings::Dimensions() const
       
  1720 	{
       
  1721 	return String(EDimensions);
       
  1722 	}
       
  1723 
       
  1724 /**
       
  1725 Adds the supplied string to this object as the 'dimensions' entry.
       
  1726 
       
  1727 @param  aString
       
  1728         A descriptor containing the string to add.
       
  1729 */
       
  1730 EXPORT_C void CFrameInfoStrings::SetDimensionsL(const TDesC& aString)
       
  1731 	{
       
  1732 	SetStringL(EDimensions, aString);
       
  1733 	}
       
  1734 
       
  1735 /**
       
  1736 Returns a pointer to the 'depth' entry string from this object.
       
  1737 
       
  1738 @return	A pointer to the returned read-only string.
       
  1739 */
       
  1740 EXPORT_C const TPtrC CFrameInfoStrings::Depth() const
       
  1741 	{
       
  1742 	return String(EDepth);
       
  1743 	}
       
  1744 
       
  1745 /**
       
  1746 Adds the supplied string to this object as the 'depth' entry.
       
  1747 
       
  1748 @param  aString
       
  1749         A descriptor containing the string to add.
       
  1750 */
       
  1751 EXPORT_C void CFrameInfoStrings::SetDepthL(const TDesC& aString)
       
  1752 	{
       
  1753 	SetStringL(EDepth, aString);
       
  1754 	}
       
  1755 
       
  1756 /**
       
  1757 Returns a pointer to the 'details' entry string from this object.
       
  1758 
       
  1759 @return	A pointer to the returned read-only string.
       
  1760 */
       
  1761 EXPORT_C const TPtrC CFrameInfoStrings::Details() const
       
  1762 	{ 
       
  1763 	return String(EDetails);
       
  1764 	}
       
  1765 
       
  1766 /**
       
  1767 Adds the supplied string to this object as the 'details' entry.
       
  1768 
       
  1769 @param  aString
       
  1770         A descriptor containing the string to add.
       
  1771 */
       
  1772 EXPORT_C void CFrameInfoStrings::SetDetailsL(const TDesC& aString)
       
  1773 	{
       
  1774 	SetStringL(EDetails, aString);
       
  1775 	}
       
  1776 
       
  1777 /**
       
  1778 Get a list of the basic image types that can be decoded, based on the
       
  1779 currently available decoder plugins.
       
  1780 
       
  1781 @param  aImageTypeArray
       
  1782         An empty array, into which this function will put a list of
       
  1783         entries. Each entry will consist of the "display string" from
       
  1784         the registry entry for a plugin that has been found and that is
       
  1785         a decoder for a basic image type, accompanied by the Uids for
       
  1786         that image type. Since we asked for basic types the second Uid,
       
  1787         for the image sub-type, will always be zero.
       
  1788 
       
  1789         Ownership of the array is passed to the caller so, before the
       
  1790         array goes out of scope in the client, the caller must call
       
  1791         ResetAndDestroy() on it to free the entries.
       
  1792 */
       
  1793 EXPORT_C void CImageDecoder::GetImageTypesL(RImageTypeDescriptionArray& aImageTypeArray)
       
  1794 	{
       
  1795 	ImageEnDecoderUtils::DoGetImageTypesL(KImageDecoderInterfaceUid, aImageTypeArray);
       
  1796 	}
       
  1797 
       
  1798 /**
       
  1799 For a given basic image type, get a list of the sub image types that can
       
  1800 be decoded, based on the currently available decoder plugins.
       
  1801 
       
  1802 @param  aImageType
       
  1803         The basic image type for which you want a list of sub-types.
       
  1804 @param  aSubTypeArray
       
  1805         An empty array, into which this function will put a list of
       
  1806         entries. Each entry will consist of the "display string" from
       
  1807         the registry entry for a plugin that has been found and that is
       
  1808         a decoder for a sub-type of the given basic image type,
       
  1809         accompanied by the Uids for the sub type. The first Uid, for
       
  1810         the basic type, will always correspond to aImageType.
       
  1811 
       
  1812         Ownership of the array is passed to the caller so, before the
       
  1813         array goes out of scope in the client, the caller must call
       
  1814         ResetAndDestroy() on it to free the entries.
       
  1815 */
       
  1816 EXPORT_C void CImageDecoder::GetImageSubTypesL(const TUid aImageType, RImageTypeDescriptionArray& aSubTypeArray)
       
  1817 	{
       
  1818 	ImageEnDecoderUtils::DoGetImageTypesL(KImageDecoderInterfaceUid, aSubTypeArray, aImageType);
       
  1819 	}
       
  1820 
       
  1821 /**
       
  1822 Get a list of the file extensions that can be decoded and their corresponding
       
  1823 MIME types, based on the currently available decoder plugins.
       
  1824 
       
  1825 @param  aFileTypeArray
       
  1826         An empty array, into which this function will put a list of
       
  1827         entries. Each entry will consist of a file extension string for
       
  1828         which a decoder plugin has been found, accompanied by the
       
  1829         primary MIME type and then any secondary MIME types
       
  1830         (if present).
       
  1831         
       
  1832         Ownership of the array is passed to the caller so, before the
       
  1833         array goes out of scope in the client, the caller must call
       
  1834         ResetAndDestroy() on it to free the entries.
       
  1835 */
       
  1836 EXPORT_C void CImageDecoder::GetFileTypesL(RFileExtensionMIMETypeArray& aFileTypeArray)
       
  1837 	{
       
  1838 	ImageEnDecoderUtils::DoGetFileTypesL(KImageDecoderInterfaceUid, aFileTypeArray);
       
  1839 	}
       
  1840 
       
  1841 /**
       
  1842 Get the primary MIME type of the decoder that will be used to
       
  1843 decode a file.
       
  1844 Some file types (like OTA or WBPM), which do not have unique 
       
  1845 pattern in their header may not be recognised, in case when 
       
  1846 the source file name doesn't have extension or, extension is 
       
  1847 not common to that file type. Such files are not supported by this API.
       
  1848 
       
  1849 @param  aFs
       
  1850         A reference to a file server session to use.
       
  1851 @param  aFileName
       
  1852         The name of the file for which a MIME type has to be determined
       
  1853 @param	aMimeType
       
  1854         An empty descriptor in which the MIME type assosiated with the file
       
  1855         will be returned. Ownership is passed to the caller.
       
  1856 */
       
  1857 EXPORT_C void CImageDecoder::GetMimeTypeFileL(RFs& /*aFs*/, const TDesC& aFileName, TDes8& aMimeType)
       
  1858 	{
       
  1859 	CContent* content = CContent::NewLC(aFileName, EContentShareReadWrite);
       
  1860 	CData* data = content->OpenContentL(EPeek);
       
  1861 	
       
  1862 	CleanupStack::PushL(data);
       
  1863 	TBool mimeTypeKnown = data->GetMimeTypeL(aMimeType);
       
  1864 
       
  1865 	if (!mimeTypeKnown)
       
  1866 		{
       
  1867 		TBuf8<KImageHeaderSize> imageHeader;
       
  1868 		User::LeaveIfError(data->Read(imageHeader, KImageHeaderSize));
       
  1869 
       
  1870 		if (imageHeader.Length() < KImageHeaderSize) // There is not enough data in the file
       
  1871 			{ // Get out - clean up and leave
       
  1872 			User::Leave(KErrUnderflow);
       
  1873 			}
       
  1874 
       
  1875 		DoGetMimeTypeL(aFileName, imageHeader, aMimeType);
       
  1876 		}
       
  1877 	CleanupStack::PopAndDestroy(2, content); // content, data
       
  1878 	}
       
  1879 
       
  1880 /**
       
  1881 Get the primary MIME type of the decoder that will be used to
       
  1882 decode a descriptor.
       
  1883 Some file types (like OTA or WBPM), which do not have unique 
       
  1884 pattern in their header may not be recognised.
       
  1885 Such files are not supported by this API
       
  1886 
       
  1887 @param  aImageData
       
  1888         A descriptor containing the image data for which a MIME
       
  1889         type has to be determined.
       
  1890 @param  aMimeType
       
  1891         An empty descriptor in which the MIME type assosiated with the file
       
  1892         will be returned. Ownership is passed to the caller.
       
  1893 */
       
  1894 EXPORT_C void CImageDecoder::GetMimeTypeDataL(const TDesC8& aImageData, TDes8& aMimeType)
       
  1895 	{
       
  1896 	TBuf8<KImageHeaderSize> imageHeader;
       
  1897 
       
  1898 	if (aImageData.Length() < KImageHeaderSize) // There is not enough data in this source
       
  1899 		{ // Get out - clean up and leave
       
  1900 		User::Leave(KErrUnderflow);
       
  1901 		}
       
  1902 
       
  1903 	imageHeader = aImageData.Left(KImageHeaderSize);
       
  1904 
       
  1905 	DoGetMimeTypeL(KNullDesC, imageHeader, aMimeType);
       
  1906 	}
       
  1907 
       
  1908 /**
       
  1909 Gets the implementation information for a specific decoder plugin
       
  1910 
       
  1911 Ownership of the implementation information is passed to the caller.
       
  1912 
       
  1913 @param	aImplementationUid
       
  1914         The decoder implementation UID for which to retrieve implementation information
       
  1915 @return	A pointer to the implementation information.
       
  1916 */
       
  1917 EXPORT_C CImplementationInformationType* CImageDecoder::GetImplementationInformationL(TUid aImplementationUid)
       
  1918 	{
       
  1919 	CImplementationInformationType* implementationInformation;
       
  1920 	implementationInformation = CImplementationInformationType::NewLC();
       
  1921 	ImageEnDecoderUtils::DoGetImplementationInformationL(KImageDecoderInterfaceUid, *implementationInformation, aImplementationUid);
       
  1922 	CleanupStack::Pop(implementationInformation);
       
  1923 	return implementationInformation;
       
  1924 	}
       
  1925 
       
  1926 /**
       
  1927 Gets a list of the properties of a specific decoder plugin.
       
  1928 
       
  1929 @publishedAll
       
  1930 @released
       
  1931 @param	aImplementationUid
       
  1932         The decoder implementation UID for which the plugin properties need to be retrieved.
       
  1933 @param	aPropertiesArray
       
  1934 		The array of plugin properties owned by the specified decoder.
       
  1935 		The caller has the ownership of the array.
       
  1936 */
       
  1937 EXPORT_C void CImageDecoder::GetPluginPropertiesL(const TUid aImplementationUid, RUidDataArray& aPropertiesArray)
       
  1938 	{
       
  1939 	ImageEnDecoderUtils::DoGetPluginPropertiesL(KImageDecoderInterfaceUid, aImplementationUid, aPropertiesArray);
       
  1940 	}
       
  1941 
       
  1942 /**
       
  1943 @publishedAll
       
  1944 @released
       
  1945 
       
  1946 Gets a list of decoder implementations UIDs which have a set of specific capabilities defined by UIDs.
       
  1947 
       
  1948 @param	aRequiredUids
       
  1949         The array containing the required UIDs (properties, image type, image sub-type or class UIDs).
       
  1950 @param	aImplArray
       
  1951 		The array containing the implementation UIDs of the available decoder plugins with the required UIDs.
       
  1952 		The caller has the ownership of the array.
       
  1953 */
       
  1954 EXPORT_C void CImageDecoder::GetInterfaceImplementationsL(const RUidDataArray& aRequiredUids, RUidDataArray& aImplArray)
       
  1955 	{
       
  1956 	ImageEnDecoderUtils::DoGetInterfaceImplementationsL(KImageDecoderInterfaceUid, aRequiredUids, aImplArray);
       
  1957 	}
       
  1958 
       
  1959 /**
       
  1960 @publishedAll
       
  1961 @released
       
  1962 
       
  1963 Gets a list of decoder implementations UIDs which have a set of specific capabilities defined by UIDs.
       
  1964 
       
  1965 @param	aRequiredUids
       
  1966         The array containing the required UIDs (properties, image type, image sub-type or class UIDs).
       
  1967 @param	aLength
       
  1968 		The length of aRequiredUids (number of required UIDs).
       
  1969 @param	aImplArray
       
  1970 		The array containing the implementation UIDs of the available decoder plugins with the required UIDs.
       
  1971 		The caller has the ownership of the array.
       
  1972 */	
       
  1973 EXPORT_C void CImageDecoder::GetInterfaceImplementationsL(const TUid* aRequiredUids, const TInt aLength, RUidDataArray& aImplArray)
       
  1974 	{
       
  1975 	RUidDataArray requiredUids;
       
  1976 	CleanupClosePushL(requiredUids);
       
  1977 	for(TInt index = 0 ; index < aLength ; index++)
       
  1978 		{
       
  1979 		User::LeaveIfError(requiredUids.Append(aRequiredUids[index]));
       
  1980 		}
       
  1981 	ImageEnDecoderUtils::DoGetInterfaceImplementationsL(KImageDecoderInterfaceUid, requiredUids, aImplArray);	
       
  1982 	CleanupStack::PopAndDestroy(1); //requiredUids
       
  1983 	}
       
  1984 	
       
  1985 /**
       
  1986 Create a list of decoders that support the specified MIME type.
       
  1987 
       
  1988 @param  aDecoderList
       
  1989         A list of decoders that support the given MIME type.
       
  1990 @param  aMIMEType
       
  1991         The MIME type to decode.
       
  1992 @param	aOptions
       
  1993 		Extension options which must be supported by the plugin.
       
  1994 */
       
  1995 void CImageDecoder::MimeTypeGetDecoderListL(RImplInfoPtrArray& aDecoderList, const TDesC8& aMIMEType, const TOptions aOptions)
       
  1996 	{
       
  1997 	if (aMIMEType.Length() == 0)
       
  1998 		{ // Get out, empty MIME type string
       
  1999 		User::Leave(KErrArgument);
       
  2000 		}
       
  2001 
       
  2002 	CCustomMatchData* customMatchData = CCustomMatchData::NewLC();
       
  2003 	customMatchData->SetMatchType(EMatchMIMEType);
       
  2004 	customMatchData->SetMatchStringL(aMIMEType);
       
  2005 	customMatchData->SetOptions(aOptions);
       
  2006 	customMatchData->SetExtensionOptions(aOptions);
       
  2007 
       
  2008 	HBufC8* package  = customMatchData->NewPackLC();
       
  2009 	TPtr8 packageDes = package->Des();
       
  2010 
       
  2011 	TEComResolverParams resolverParams; // Parameters on which to match
       
  2012 	resolverParams.SetDataType(packageDes);
       
  2013 
       
  2014 	REComSession::ListImplementationsL(KImageDecoderInterfaceUid, resolverParams, KImageConvertResolverUid, aDecoderList);
       
  2015 
       
  2016 	CleanupStack::PopAndDestroy(2); // package, customMatchData
       
  2017 	}
       
  2018 
       
  2019 
       
  2020 /**
       
  2021 Create a list of decoders that support the specified image type.
       
  2022 
       
  2023 @param  aDecoderList
       
  2024         A list of decoders that support the specified image type.
       
  2025 @param  aImageHeader
       
  2026         The header of the image file.
       
  2027 @param  aImageType
       
  2028         The image base type.
       
  2029 @param  aImageSubType
       
  2030         The image sub type.
       
  2031 @param  aDecoderUid
       
  2032         The implementation UID for a specific codec or a decoder/encoder class UID.
       
  2033 @param	aOptions
       
  2034 		Extension options which must be supported by the plugin.
       
  2035 @see	KUidICLJpegEXIFInterface
       
  2036 @see	KUidICLJpegImageFrameInterface
       
  2037 */
       
  2038 void CImageDecoder::ImageTypeGetDecoderListL(RImplInfoPtrArray& aDecoderList, const TDesC8& aImageHeader, const TUid aImageType, const TUid aImageSubType, const TUid aDecoderUid, const TOptions aOptions)
       
  2039 	{
       
  2040 	if (aDecoderUid != KNullUid)
       
  2041 		{
       
  2042 		RImplInfoPtrArray list;
       
  2043 		CleanupResetAndDestroyPushL(list);
       
  2044 		
       
  2045 		REComSession::ListImplementationsL(KImageDecoderInterfaceUid, list);
       
  2046 		
       
  2047 		for (TInt i = 0; i < list.Count(); i++)
       
  2048 			{
       
  2049 			if (list[i]->ImplementationUid() == aDecoderUid)
       
  2050 				{
       
  2051 				User::LeaveIfError(aDecoderList.Append(list[i]));
       
  2052 				}
       
  2053 			else
       
  2054 				{
       
  2055 				delete list[i];
       
  2056 				}
       
  2057 			list[i] = NULL;
       
  2058 			}
       
  2059 		
       
  2060 		CleanupStack::PopAndDestroy(&list);
       
  2061 		if (aDecoderList.Count() > 0)
       
  2062 			{
       
  2063 			return;
       
  2064 			}
       
  2065 		}
       
  2066 		
       
  2067 	TBuf8<KImageHeaderSize> imageHeader;
       
  2068 
       
  2069 	CCustomMatchData* customMatchData = CCustomMatchData::NewLC();
       
  2070 
       
  2071 	if ((aImageType != KNullUid) || (aDecoderUid != KNullUid))
       
  2072 		{ // We have a specific image type we are trying to convert
       
  2073 		customMatchData->SetMatchType(EMatchUids);
       
  2074 		customMatchData->SetBaseType(aImageType);
       
  2075 		customMatchData->SetSubType(aImageSubType);
       
  2076 		customMatchData->SetImplementationType(aDecoderUid);
       
  2077 		}
       
  2078 	else
       
  2079 		{
       
  2080 		if (aImageHeader.Length() < KMinimumHeaderLength) // There is not enough data in the header
       
  2081 			{ // Get out - clean up and leave
       
  2082 			User::Leave(KErrUnderflow);
       
  2083 			}
       
  2084 		imageHeader = aImageHeader.Left(KImageHeaderSize);
       
  2085 		customMatchData->SetMatchType(EMatchString);
       
  2086 		customMatchData->SetMatchStringL(imageHeader);
       
  2087 		}
       
  2088 
       
  2089 	customMatchData->SetOptions(aOptions);
       
  2090 	customMatchData->SetExtensionOptions(aOptions);
       
  2091 	HBufC8* package  = customMatchData->NewPackLC();
       
  2092 	TPtr8 packageDes = package->Des();
       
  2093 
       
  2094 	TEComResolverParams resolverParams; // Parameters on which to match
       
  2095 	resolverParams.SetDataType(packageDes);
       
  2096 
       
  2097 	#if defined(__ICL_PROFILING)
       
  2098 	// intended for use with TProfImage only
       
  2099 	RDebug::ProfileStart(2);
       
  2100 	TRAPD(err,REComSession::ListImplementationsL(KImageDecoderInterfaceUid, resolverParams, KImageConvertResolverUid, aDecoderList));
       
  2101 	RDebug::ProfileEnd(2);
       
  2102 	User::LeaveIfError(err);
       
  2103 	#else
       
  2104 	REComSession::ListImplementationsL(KImageDecoderInterfaceUid, resolverParams, KImageConvertResolverUid, aDecoderList);
       
  2105 	#endif  // defined(__ICL_PROFILING)
       
  2106 
       
  2107 	CleanupStack::PopAndDestroy(2); // package, customMatchData
       
  2108 	}
       
  2109 
       
  2110 /**
       
  2111 @internalComponent
       
  2112 
       
  2113 Creates a list of decoders that support the specified file extension.
       
  2114 
       
  2115 @param  aDecoderList
       
  2116         A list of decoders that support the given file extension.
       
  2117 @param  aFileName
       
  2118         The file name from which the file extension will be taken.
       
  2119 @param	aOptions
       
  2120 		Extension options which must be supported by the plugin.
       
  2121 */
       
  2122 void CImageDecoder::SuffixTypeGetDecoderListL(RImplInfoPtrArray& aDecoderList, const TDesC& aFileName, const TOptions aOptions)
       
  2123 	{
       
  2124 	TParse fileName;
       
  2125 	fileName.Set(aFileName,NULL,NULL);
       
  2126 
       
  2127 	//No file extension
       
  2128 	if (!fileName.ExtPresent())
       
  2129 		User::Leave(KErrNotFound);
       
  2130 
       
  2131 	//Get the suffix
       
  2132 	TPtrC suffix(fileName.Ext());
       
  2133 
       
  2134 	CCustomMatchData* customMatchData = CCustomMatchData::NewLC();
       
  2135 	customMatchData->SetMatchType(EMatchFileSuffix);
       
  2136 	customMatchData->SetFileSuffixL(suffix);
       
  2137 	customMatchData->SetOptions(aOptions);
       
  2138 	customMatchData->SetExtensionOptions(aOptions);
       
  2139 
       
  2140 	HBufC8* package  = customMatchData->NewPackLC();
       
  2141 	TPtr8 packageDes = package->Des();
       
  2142 
       
  2143 	TEComResolverParams resolverParams; // Parameters on which to match
       
  2144 	resolverParams.SetDataType(packageDes);
       
  2145 
       
  2146 	REComSession::ListImplementationsL(KImageDecoderInterfaceUid, resolverParams, KImageConvertResolverUid, aDecoderList);
       
  2147 
       
  2148 	CleanupStack::PopAndDestroy(2,customMatchData); // package, customMatchData
       
  2149 	}
       
  2150 
       
  2151 /**
       
  2152 @internalTechnology
       
  2153 
       
  2154 Scans a sorted list of decoders for the first one that can decode the image.
       
  2155 
       
  2156 @param  aDecoderList
       
  2157         A list of decoders that support the image format.
       
  2158 @param  aFs
       
  2159         A file server session for the decoder to use.
       
  2160 @param  aSourceFilename
       
  2161         The filename of the file to decode.
       
  2162 @param  aOptions
       
  2163         The options to use during decoding.
       
  2164 
       
  2165 @return A pointer to the decoder.
       
  2166 */
       
  2167 
       
  2168 CImageDecoder* CImageDecoder::FileFindDecoderNewL(const RImplInfoPtrArray& aDecoderList, RFs& aFs, const TDesC& aSourceFilename, const TOptions aOptions, const TDesC& aUniqueId)
       
  2169 	{
       
  2170 	TInt noOfDecoders = aDecoderList.Count();
       
  2171 
       
  2172 	if (noOfDecoders == 0)
       
  2173 		{
       
  2174 		User::Leave(KErrNotFound);
       
  2175 		}
       
  2176 
       
  2177 	CImageDecoder* decoder = NULL;
       
  2178 	TInt decoderNo = 0;
       
  2179 	TInt error = KErrNone;
       
  2180 
       
  2181 	do
       
  2182 		{
       
  2183 		const CImplementationInformation& decoderInfo = *(aDecoderList[decoderNo++]);
       
  2184 
       
  2185 		TRAP(error,decoder=FileDecoderNewL(decoderInfo, aFs, aSourceFilename, aOptions, aUniqueId));
       
  2186 
       
  2187 		if (error != KErrCorrupt && error != KErrNotSupported && error != KErrNotFound)
       
  2188 			break;
       
  2189 		}
       
  2190 	while(decoderNo < noOfDecoders);
       
  2191 
       
  2192 	if(error!=KErrNone)
       
  2193 		{
       
  2194 		ASSERT(decoder==NULL);
       
  2195 		if (error == KErrCorrupt || error == KErrNotSupported)
       
  2196 			error = KErrNotFound;
       
  2197 		User::Leave(error);
       
  2198 		}
       
  2199 
       
  2200 	return decoder;
       
  2201 	}
       
  2202 	
       
  2203 /**
       
  2204 @internalTechnology
       
  2205 
       
  2206 Create a construct that can create a decoder and call
       
  2207 functions to initialise the decoder with the image data.
       
  2208 
       
  2209 @param  aDecoderInfo
       
  2210         Implementation information for the decoder to be created.
       
  2211 @param  aFs
       
  2212         A file server session for the decoder to use.
       
  2213 @param  aSourceFilename
       
  2214         The filename of the file to decode.
       
  2215 @param  aOptions
       
  2216         Options the decoder must use.
       
  2217 
       
  2218 @return	A pointer to the decoder.
       
  2219 */
       
  2220 
       
  2221 CImageDecoder* CImageDecoder::FileDecoderNewL(const CImplementationInformation& aDecoderInfo, RFs& aFs, const TDesC& aSourceFilename, const TOptions aOptions, const TDesC& aUniqueId)
       
  2222 	{
       
  2223 	CImageDecodeConstruct* construct = NULL;
       
  2224 	construct = NewDecodeConstructL(aDecoderInfo, aOptions);
       
  2225 	ASSERT(construct!= NULL);
       
  2226 
       
  2227 	CImageDecoder* decoder = NewL(construct, aOptions); // note NewL takes ownership of construct - don't push on stack
       
  2228 	ASSERT(decoder!=NULL);
       
  2229 	CleanupStack::PushL(decoder);
       
  2230 
       
  2231 	decoder->iRelay->SetUniqueIdL(aUniqueId);
       
  2232 
       
  2233 	decoder->iRelay->SetFileL(aFs, aSourceFilename, aOptions);
       
  2234 	decoder->iRelay->HandleNewlyOpenedImageL();
       
  2235 
       
  2236 	CleanupStack::Pop(decoder);
       
  2237 	return decoder;
       
  2238 	}
       
  2239 
       
  2240 /**
       
  2241 @internalTechnology
       
  2242 @released
       
  2243 Scan a sorted list of decoders for the first one that can decode the image.
       
  2244 
       
  2245 @param  aDecoderList
       
  2246         A list of decoders that support the image format.
       
  2247 @param  aFs
       
  2248         A file server session for the decoder to use.
       
  2249 @param  aSourceData
       
  2250         The data to decode.
       
  2251 @param  aOptions
       
  2252         Options to use during decoding.
       
  2253 
       
  2254 @return A pointer to the decoder.
       
  2255  */
       
  2256 CImageDecoder* CImageDecoder::DataFindDecoderNewL(const RImplInfoPtrArray& aDecoderList, RFs& aFs, const TDesC8& aSourceData, const TOptions aOptions)
       
  2257 	{
       
  2258 	TInt noOfDecoders = aDecoderList.Count();
       
  2259 
       
  2260 	if(noOfDecoders == 0)
       
  2261 		User::Leave(KErrNotFound);
       
  2262 
       
  2263 	CImageDecoder* decoder = NULL;
       
  2264 	TInt decoderNo = 0;
       
  2265 	TInt error = KErrNone;
       
  2266 	do
       
  2267 		{
       
  2268 		const CImplementationInformation& decoderInfo = *(aDecoderList[decoderNo++]);
       
  2269 		TRAP(error,decoder=DataDecoderNewL(decoderInfo, aFs, aSourceData, aOptions));
       
  2270 		if (error != KErrCorrupt && error != KErrNotSupported && error != KErrNotFound)
       
  2271 			break;
       
  2272 		}
       
  2273 	while(decoderNo < noOfDecoders);
       
  2274 
       
  2275 	if(error!=KErrNone)
       
  2276 		{
       
  2277 		ASSERT(decoder==NULL);
       
  2278 		if (error == KErrCorrupt || error == KErrNotSupported)
       
  2279 			error = KErrNotFound;
       
  2280 		User::Leave(error);
       
  2281 		}
       
  2282 
       
  2283 	return decoder;
       
  2284 	}
       
  2285 
       
  2286 /**
       
  2287 @internalTechnology
       
  2288 @released
       
  2289 Create a construct that can create a decoder and call
       
  2290 functions to initialise the decoder with the image data.
       
  2291 
       
  2292 @param  aDecoderInfo
       
  2293         Implementation information for the decoder to be created.
       
  2294 @param  aFs
       
  2295         A file server session for the decoder to use.
       
  2296 @param  aSourceData
       
  2297         The data to decode.
       
  2298 @param  aOptions
       
  2299         Options the decoder must use.
       
  2300 
       
  2301 @return	A pointer to the decoder.
       
  2302 */
       
  2303 CImageDecoder* CImageDecoder::DataDecoderNewL(const CImplementationInformation& aDecoderInfo, RFs& aFs, const TDesC8& aSourceData, const TOptions aOptions)
       
  2304 	{
       
  2305 	CImageDecodeConstruct* construct = NULL;
       
  2306 	construct = NewDecodeConstructL(aDecoderInfo, aOptions);
       
  2307 	ASSERT(construct!= NULL);
       
  2308 
       
  2309 	CImageDecoder* decoder = NewL(construct, aOptions); // note NewL takes ownership of construct - don't push on stack
       
  2310 	ASSERT(decoder!=NULL);
       
  2311 	CleanupStack::PushL(decoder);
       
  2312 
       
  2313 	decoder->iRelay->SetDataL(aFs, aSourceData, aOptions);
       
  2314 	decoder->iRelay->HandleNewlyOpenedImageL();
       
  2315 
       
  2316 	CleanupStack::Pop(decoder);
       
  2317 	return decoder;
       
  2318 	}
       
  2319 
       
  2320 /**
       
  2321 @internalTechnology
       
  2322 
       
  2323 Create a construct object for the specified decoder.
       
  2324 
       
  2325 @param  aDecoderInfo
       
  2326         Implementation information for the decoder to be created.
       
  2327 @param	aOptions
       
  2328 		Extension options which must be supported by the plugin.
       
  2329 @return	A construct object that can create the decoder.
       
  2330 */
       
  2331 CImageDecodeConstruct* CImageDecoder::NewDecodeConstructL(const CImplementationInformation& aDecoderInfo, const TOptions aOptions)
       
  2332 	{
       
  2333 	CCustomMatchData* customMatchData = CCustomMatchData::NewLC();
       
  2334 	COpaqueDataParse* parse = COpaqueDataParse::NewLC(aDecoderInfo.OpaqueData());
       
  2335 
       
  2336 	customMatchData->SetMatchType(EMatchUids);
       
  2337 	customMatchData->SetBaseType(parse->ImageTypeUid());
       
  2338 	customMatchData->SetSubType(parse->ImageSubTypeUid());
       
  2339 	customMatchData->SetImplementationType(aDecoderInfo.ImplementationUid());
       
  2340 
       
  2341 	CleanupStack::PopAndDestroy(parse);
       
  2342 
       
  2343 	customMatchData->SetOptions(aOptions);
       
  2344 	customMatchData->SetExtensionOptions(aOptions);
       
  2345 	HBufC8* package = customMatchData->NewPackLC();
       
  2346 	TPtr8 packageDes = package->Des();
       
  2347 
       
  2348 	TEComResolverParams resolverParams;
       
  2349 	resolverParams.SetDataType(packageDes);
       
  2350 
       
  2351 	CImageDecodeConstruct* construct = NULL;
       
  2352 #if defined(__ICL_PROFILING)
       
  2353 	// intended for use with TProfImage only
       
  2354 	RDebug::ProfileStart(3);
       
  2355 	TRAPD(err, construct = STATIC_CAST(CImageDecodeConstruct*,
       
  2356 			REComSession::CreateImplementationL(KImageDecoderInterfaceUid,
       
  2357 			_FOFF(CImageDecodeConstruct, iDtorIDKey),
       
  2358 			resolverParams,
       
  2359 			KImageConvertResolverUid)));
       
  2360 	RDebug::ProfileEnd(3);
       
  2361 	User::LeaveIfError(err);
       
  2362 #else
       
  2363 	construct = STATIC_CAST(CImageDecodeConstruct*,
       
  2364 			REComSession::CreateImplementationL(KImageDecoderInterfaceUid,
       
  2365 			_FOFF(CImageDecodeConstruct, iDtorIDKey),
       
  2366 			resolverParams,
       
  2367 			KImageConvertResolverUid));
       
  2368 #endif  // defined(__ICL_PROFILING)
       
  2369 
       
  2370 	ASSERT(construct!=NULL);
       
  2371 
       
  2372 	CleanupStack::PopAndDestroy(2, customMatchData); //package, customMatchData
       
  2373 
       
  2374 	return construct;
       
  2375 	}
       
  2376 
       
  2377 /**
       
  2378 @internalTechnology
       
  2379 
       
  2380 Get the MIME type for a given match string.
       
  2381 
       
  2382 @param  aFileName
       
  2383         The file name of the image file.
       
  2384 @param  aMatchString
       
  2385         An image header of an image file.
       
  2386 @param  aMimeType
       
  2387         The primary MIME type returned.
       
  2388 */
       
  2389 void CImageDecoder::DoGetMimeTypeL(const TDesC& aFileName, const TDesC8& aMatchString, TDes8& aMimeType)
       
  2390 	{
       
  2391 	// Get a list of decoders that will decode the image.
       
  2392 	RImplInfoPtrArray decoderList;
       
  2393 	CleanupResetAndDestroyPushL(decoderList);
       
  2394 	CImageDecoder::ImageTypeGetDecoderListL(decoderList, aMatchString, KNullUid, KNullUid, KNullUid);
       
  2395 
       
  2396 	// Try to match by file extension.
       
  2397 	// aFileName will be KNullDesC when called from GetMimeTypeDataL()
       
  2398 	if(aFileName!=KNullDesC && decoderList.Count() == 0)
       
  2399 		CImageDecoder::SuffixTypeGetDecoderListL(decoderList, aFileName);
       
  2400 
       
  2401 	if(decoderList.Count() == 0)
       
  2402 		User::Leave(KErrNotFound);
       
  2403 
       
  2404     TInt decoderNo = 0;
       
  2405 
       
  2406 #if defined (__GET_MIME_TYPE_THOROUGH)
       
  2407 	RFs fs;
       
  2408 	CleanupClosePushL(fs);
       
  2409     User::LeaveIfError(fs.Connect());
       
  2410 	TInt noOfDecoders = decoderList.Count();
       
  2411 
       
  2412     CImageDecoder* decoder = NULL;
       
  2413     TInt error = KErrNotFound;
       
  2414 	while(decoderNo < noOfDecoders)
       
  2415 		{
       
  2416 		const CImplementationInformation& decoderInfo = *(decoderList[decoderNo]);
       
  2417         TRAP(error,decoder=DataDecoderNewL(decoderInfo, fs, aMatchString, EOptionAllowZeroFrameOpen));
       
  2418   		// if decoder didn't match, then it should return KErrCorrupt,
       
  2419 		// but we also accept KErrNotSupported & KErrNotFound
       
  2420 		if (error != KErrCorrupt && error != KErrNotSupported && error != KErrNotFound)
       
  2421 			break;
       
  2422 		decoderNo++;
       
  2423 		}
       
  2424 
       
  2425 	if (error!=KErrNone)
       
  2426 		{
       
  2427 		ASSERT(decoder==NULL);
       
  2428 		if (error == KErrCorrupt || error == KErrNotSupported)
       
  2429 			error = KErrNotFound;
       
  2430 		User::Leave(error);
       
  2431 		}
       
  2432     delete decoder;
       
  2433 	CleanupStack::PopAndDestroy(&fs); 
       
  2434 #endif  // defined (__GET_MIME_TYPE_THOROUGH)
       
  2435 
       
  2436 	//Use the highest rated decoder.
       
  2437 	CImageDecodeConstruct* construct = NewDecodeConstructL(*decoderList[decoderNo]);
       
  2438 	CleanupStack::PopAndDestroy(&decoderList);
       
  2439 	if (construct == NULL)
       
  2440 		{ // We didn't get a match - leave
       
  2441 		User::Leave(KErrNotFound); 
       
  2442 		}
       
  2443 	CleanupStack::PushL(construct);
       
  2444 
       
  2445 	// Determine the primary Mime type of the decoder	
       
  2446 	CImplementationInformationType* implementationInformation = NULL;
       
  2447 	implementationInformation = GetImplementationInformationL(construct->ImplementationUid());
       
  2448 	CleanupStack::PushL(implementationInformation);
       
  2449 
       
  2450 	TPtrC8 opaqueDataPtr = implementationInformation->OpaqueData();
       
  2451 	COpaqueDataParse* parse = COpaqueDataParse::NewLC(opaqueDataPtr);
       
  2452 
       
  2453 	if(parse->OnlyUidsAvail())
       
  2454 		{
       
  2455 		User::Leave(KErrNotFound);
       
  2456 		}
       
  2457 
       
  2458 	parse->EnsureMIMETypesReadL();
       
  2459 
       
  2460 	aMimeType = parse->MIMEType(0);
       
  2461 
       
  2462 	CleanupStack::PopAndDestroy(3); // parse, ImplementationInformation, decoderPtr
       
  2463 	}
       
  2464 
       
  2465 /**
       
  2466 Create a decoder for the image in the named file. The client supplies a
       
  2467 MIME type which will be used to try and select an appropriate plugin
       
  2468 decoder. If it finds a decoder it creates it and then goes on to use that
       
  2469 decoder to scan the beginning of the image file.
       
  2470 
       
  2471 If any file related errors are encountered opening the specified file, this 
       
  2472 function leaves with an appropriate file related leave code.
       
  2473 
       
  2474 @param  aFs
       
  2475         A reference to a file server session for the decoder to use.
       
  2476 @param  aSourceFilename
       
  2477         The name of the file to be decoded.
       
  2478 @param  aMIMEType
       
  2479         The MIME type of the image in the file.
       
  2480 @param	aOptions
       
  2481         Decoder options to use.
       
  2482 
       
  2483 @return	Returns a pointer to the newly created decoder.
       
  2484 
       
  2485 @leave  KEComErrNoInterfaceIdentified
       
  2486         ECom could not find the specified interface.
       
  2487 @leave  KErrNotFound
       
  2488         Either the specific plugin decoder for this file hasn't been found, or the file itself is missing.
       
  2489 
       
  2490 @see    TOptions
       
  2491 */
       
  2492 EXPORT_C CImageDecoder* CImageDecoder::FileNewL(RFs& aFs, const TDesC& aSourceFilename, const TDesC8& aMIMEType, const TOptions aOptions)
       
  2493 	{
       
  2494 	return CImageDecoder::FileNewImplL(aFs, aSourceFilename, aMIMEType, KDefaultContentObject, EPeek, aOptions);
       
  2495 	}
       
  2496 
       
  2497 /**
       
  2498 Create a decoder for the image in the named file. The client supplies a
       
  2499 MIME type which will be used to try and select an appropriate plugin
       
  2500 decoder. If it finds a decoder it creates it and then goes on to use that
       
  2501 decoder to scan the beginning of the image file.
       
  2502 
       
  2503 @param  aFs
       
  2504         A reference to a file server session for the decoder to use.
       
  2505 @param  aSourceFilename
       
  2506         The name of the file to be decoded.
       
  2507 @param  aMIMEType
       
  2508         The MIME type of the image in the file.
       
  2509 @param  aIntent
       
  2510         The DRM Intent for image conversion.
       
  2511 @param  aOptions
       
  2512         The decoder options to use.
       
  2513 
       
  2514 @return A pointer to the newly created decoder.
       
  2515 
       
  2516 @leave  KEComErrNoInterfaceIdentified
       
  2517         ECom could not find the specified interface.
       
  2518 @leave  KErrNotFound
       
  2519         Either the specific plugin decoder for this file hasn't been found, or the file itself is missing.
       
  2520 */
       
  2521 EXPORT_C CImageDecoder* CImageDecoder::FileNewL(RFs& aFs, const TDesC& aSourceFilename, const TDesC8& aMIMEType, TIntent aIntent, const TOptions aOptions)
       
  2522 	{
       
  2523 	return CImageDecoder::FileNewImplL(aFs, aSourceFilename, aMIMEType, KDefaultContentObject, aIntent, aOptions);
       
  2524 	}
       
  2525 
       
  2526 /**
       
  2527 Create a decoder for the image in the named file. The client supplies a
       
  2528 MIME type which will be used to try and select an appropriate plugin
       
  2529 decoder. If it finds a decoder it creates it and then goes on to use that
       
  2530 decoder to scan the beginning of the image file.
       
  2531 
       
  2532 @param  aFs
       
  2533         A reference to a file server session for the decoder to use.
       
  2534 @param  aSource
       
  2535         An interface between filename based and file handle.
       
  2536 @param  aMIMEType
       
  2537         The MIME type of the image in the file.
       
  2538 @param  aOptions
       
  2539         The decoder options to use. Specifying one of more extension options (for example EOptionExtCrop) can be used to cause the 
       
  2540 		to cause a plugin to load which supports the image type and supports the requested extensions.
       
  2541 
       
  2542 @return A pointer to the newly created decoder.
       
  2543 
       
  2544 @leave  KErrNotSupported
       
  2545         A matching decoder could not be found for the MIME type.
       
  2546 @leave	KErrNotFound
       
  2547 		Either the specific plugin decoder for this source image hasn't been found, or the source image itself is missing, or
       
  2548 		a plugin with the requested extensions cannot be found.
       
  2549 */
       
  2550 EXPORT_C CImageDecoder* CImageDecoder::FileNewL(RFs& aFs, const TMMSource& aSource, const TDesC8& aMIMEType, const TOptions aOptions)
       
  2551 	{
       
  2552 	if (aSource.SourceType()==KUidMMFileHandleSource)
       
  2553 		{
       
  2554 		const TMMFileHandleSource& source = static_cast<const TMMFileHandleSource&>(aSource);
       
  2555 		return CImageDecoder::FileNewImplL(source.Handle(), aMIMEType, source.UniqueId(), source.Intent(), aOptions);
       
  2556 		}
       
  2557 	else if (aSource.SourceType()==KUidMMFileSource)
       
  2558 		{
       
  2559 		const TMMFileSource& source = static_cast<const TMMFileSource&>(aSource);
       
  2560 		return CImageDecoder::FileNewImplL(aFs, source.Name(), aMIMEType, source.UniqueId(), source.Intent(), aOptions);
       
  2561 		}
       
  2562 	else
       
  2563 		{
       
  2564 		// unknown source type
       
  2565 		User::Leave(KErrNotSupported);
       
  2566 		return NULL;
       
  2567 		}
       
  2568 	}
       
  2569 
       
  2570 /**
       
  2571 Create a decoder for the image in the named source.
       
  2572 
       
  2573 @param  aFs
       
  2574         A reference to a file server session for the decoder to use.
       
  2575 @param  aSource
       
  2576         An interface between filename based and file handle.
       
  2577 @param  aOptions
       
  2578         The decoder options to use. Specifying one of more extension options (for example EOptionExtCrop) can be used to cause the 
       
  2579 		to cause a plugin to load which supports the image type and supports the requested extensions.
       
  2580 @param  aImageType
       
  2581         The image type of the image in the file.
       
  2582 @param  aImageSubType
       
  2583         The image sub-type of the image in the file.
       
  2584 @param  aDecoderUid
       
  2585         The implementation UID for a specific codec or a decoder/encoder class UID.        
       
  2586 @see	KUidICLJpegEXIFInterface
       
  2587 @see	KUidICLJpegImageFrameInterface
       
  2588 @return A pointer to the newly created decoder.
       
  2589 
       
  2590 @leave  KErrNotSupported
       
  2591         A matching decoder could not be found for the MIME type.
       
  2592 @leave  KErrNotFound
       
  2593         Either the specific plugin decoder for this source image hasn't been found, or the source image itself is missing.
       
  2594 @leave  KEComErrNoInterfaceIdentified
       
  2595 		ECom could not find the specified interface.		
       
  2596 
       
  2597 @panic  ImageConversion 19
       
  2598         No base type given for sub-type.
       
  2599 */
       
  2600 EXPORT_C CImageDecoder* CImageDecoder::FileNewL(RFs& aFs, const TMMSource& aSource, 
       
  2601                                                 const TOptions aOptions, const TUid aImageType, 
       
  2602                                                 const TUid aImageSubType, const TUid aDecoderUid)
       
  2603 	{
       
  2604 	if (aSource.SourceType()==KUidMMFileHandleSource)
       
  2605 		{
       
  2606 		const TMMFileHandleSource& source = static_cast<const TMMFileHandleSource&>(aSource);
       
  2607 		return CImageDecoder::FileNewImplL(source.Handle(), source.UniqueId(), source.Intent(), aOptions, aImageType, aImageSubType, aDecoderUid);
       
  2608 		}
       
  2609 	else if (aSource.SourceType()==KUidMMFileSource)
       
  2610 		{
       
  2611 		const TMMFileSource& source = static_cast<const TMMFileSource&>(aSource);
       
  2612 		return CImageDecoder::FileNewImplL(aFs, source.Name(), source.UniqueId(), source.Intent(), aOptions, aImageType, aImageSubType, aDecoderUid);
       
  2613 		}
       
  2614 	else
       
  2615 		{
       
  2616 		// unknown source type
       
  2617 		User::Leave(KErrNotSupported);
       
  2618 		return NULL;
       
  2619 		}
       
  2620 	}
       
  2621 
       
  2622 /**
       
  2623 
       
  2624 Sets the properties for the Image decoder.
       
  2625 
       
  2626 @param  aProperty
       
  2627         The property to set.
       
  2628 @param  aValue
       
  2629         The value of the property.
       
  2630                
       
  2631 @return KErrNone if successful, otherwise one of the system-wide errors.
       
  2632 */
       
  2633 EXPORT_C TInt CImageDecoder::SetAgentProperty(ContentAccess::TAgentProperty aProperty, TInt aValue)
       
  2634 	{
       
  2635 	ASSERT(ValidProperties());
       
  2636 	return iRelay->SetAgentProperty(aProperty, aValue);
       
  2637 	}
       
  2638 
       
  2639 /**
       
  2640 @internalTechnology
       
  2641 
       
  2642 Creates a decoder for the image in the named file. The client supplies a
       
  2643 MIME type which will be used to try and select an appropriate plugin
       
  2644 decoder. If it finds a decoder it creates it and then goes on to use that
       
  2645 decoder to scan the beginning of the image file.
       
  2646 
       
  2647 @param  aFs
       
  2648         A reference to a file server session for the decoder to use.
       
  2649 @param  aSourceFilename
       
  2650         The name of the file to be decoded.
       
  2651 @param  aMIMEType
       
  2652         The MIME type of the image in the file.
       
  2653 @param  aUniqueId
       
  2654         The object to open for reading. If the UniqueId is set to KNullDesC the entire file will be opened for reading with no transformation.
       
  2655 @param  aIntent
       
  2656         The DRM Intent for image conversion.
       
  2657 @param  aOptions
       
  2658         The decoder options to use.
       
  2659 
       
  2660 @return	A pointer to the newly created decoder.
       
  2661 
       
  2662 @leave  KEComErrNoInterfaceIdentified
       
  2663         ECom could not find the specified interface.
       
  2664 @leave  KErrNotFound
       
  2665         Either the specific plugin decoder for this file hasn't been found, or the file itself is missing.
       
  2666 */
       
  2667 
       
  2668 CImageDecoder* CImageDecoder::FileNewImplL(RFs& aFs, const TDesC& aSourceFilename, const TDesC8& aMIMEType, const TDesC& aUniqueId, TIntent aIntent, const TOptions aOptions)
       
  2669 	{
       
  2670 	CContent* content = NULL;
       
  2671 	content = GetContentLC(aSourceFilename);
       
  2672 	CData* data = content->OpenContentL(aIntent, aUniqueId); // check file presence, evaluate (not execute) intent
       
  2673 	CleanupStack::PopAndDestroy(content);
       
  2674 
       
  2675 	delete data; // close file
       
  2676 	
       
  2677 
       
  2678 	//Get a sorted list of decoders that will decode the image
       
  2679 	RImplInfoPtrArray decoderList;
       
  2680 	CleanupResetAndDestroyPushL(decoderList);
       
  2681 	CImageDecoder::MimeTypeGetDecoderListL(decoderList, aMIMEType, aOptions);
       
  2682 
       
  2683 	CImageDecoder* decoder = NULL;
       
  2684 	decoder = CImageDecoder::FileFindDecoderNewL(decoderList, aFs, aSourceFilename, aOptions, aUniqueId);
       
  2685 
       
  2686 	ASSERT(decoder!=NULL);
       
  2687 	CleanupStack::PushL(decoder);
       
  2688 	decoder->iRelay->SetIntent(aIntent);
       
  2689 
       
  2690 	CleanupStack::Pop(decoder);
       
  2691 	CleanupStack::PopAndDestroy(&decoderList);
       
  2692 	return decoder;
       
  2693 	}
       
  2694 
       
  2695 /**
       
  2696 Create a decoder for the image in the source buffer. The client supplies a
       
  2697 MIME type which will be used to try and select an appropriate plugin
       
  2698 decoder. If a decoder is found it is created and then used to scan
       
  2699 the beginning of the image file.
       
  2700 
       
  2701 @param  aFs
       
  2702         A reference to a file server session for the decoder to use.
       
  2703 @param  aSourceData
       
  2704         The buffer containing the image to be decoded. Note that the framework 
       
  2705         doesn't take a copy of the actual data, therefore both the descriptor
       
  2706         object and the data must persist during decoding.
       
  2707 @param  aMIMEType
       
  2708         The MIME type of the image in the file(used to determine the plugin
       
  2709 		to create).
       
  2710 @param  aOptions
       
  2711         The decoder options to use. Specifying one of more extension options (for example EOptionExtCrop) can be used to cause the 
       
  2712 		to cause a plugin to load which supports the image type and supports the requested extensions.
       
  2713 
       
  2714 @return	Returns a pointer to the newly created decoder.
       
  2715 
       
  2716 @leave  KEComErrNoInterfaceIdentified
       
  2717         ECom could not find the specified interface.
       
  2718 @leave  KErrNotFound
       
  2719         No appropriate plugin decoder for this image has been found.
       
  2720 
       
  2721 @see    TOptions
       
  2722 */
       
  2723 EXPORT_C CImageDecoder* CImageDecoder::DataNewL(RFs& aFs, const TDesC8& aSourceData, const TDesC8& aMIMEType, const TOptions aOptions)
       
  2724 	{
       
  2725 	//Get a list of decoders that will decode the image
       
  2726 	RImplInfoPtrArray decoderList;
       
  2727 	CleanupResetAndDestroyPushL(decoderList);
       
  2728 	CImageDecoder::MimeTypeGetDecoderListL(decoderList, aMIMEType, aOptions);
       
  2729 
       
  2730 	CImageDecoder* decoder = NULL;
       
  2731 	decoder = CImageDecoder::DataFindDecoderNewL(decoderList, aFs, aSourceData, aOptions);
       
  2732 	ASSERT(decoder!=NULL);
       
  2733 
       
  2734 	CleanupStack::PopAndDestroy(&decoderList);
       
  2735 	return decoder;
       
  2736 	}
       
  2737 
       
  2738 /**
       
  2739 Create a decoder for the image in the named file. 
       
  2740 
       
  2741 If the client supplies an image type (and sub-type, if applicable) or decoder 
       
  2742 UID, these will be used to try and select an appropriate plugin decoder. If 
       
  2743 not, then the selection will be done by matching the image header in the file. 
       
  2744 If it finds a decoder, it will be created and then used to scan the beginning 
       
  2745 of the image file.
       
  2746 
       
  2747 Note: Every image format has two IDs, known as the type and the sub-type (although 
       
  2748 generally the sub-type is KNullUid). To retrieve a list of supported types and 
       
  2749 sub-types that can be decoded, use the static functions GetImageTypesL() and 
       
  2750 GetImageSubTypesL().
       
  2751 
       
  2752 @param  aFs
       
  2753         A reference to a file server session for the decoder to use.
       
  2754 @param  aSourceFilename
       
  2755         The name of the file to be decoded.
       
  2756 @param	aOptions
       
  2757         Decoder options to use.
       
  2758 @param  aImageType
       
  2759         The image type of the image in the file (optional, defaults to KNullUid).
       
  2760 @param  aImageSubType
       
  2761         The image sub-type of the image in the file (optional, defaults to KNullUid).
       
  2762 @param  aDecoderUid
       
  2763 		The implementation UID for a specific codec or a decoder/encoder class UID (optional, defaults to KNullUid).
       
  2764 		If this option is selected for a specific codec the image type and image sub type for the displayer must be supplied.
       
  2765 		When loading plugins by class UID the image type and image subtype are not mandatory and the first valid plugin from 
       
  2766 		the list of available plugins with the specified class UID will be loaded.
       
  2767 @see	KUidICLJpegEXIFInterface
       
  2768 @see	KUidICLJpegImageFrameInterface
       
  2769 @return	Returns a pointer to the newly created decoder.
       
  2770 
       
  2771 @leave  KErrUnderflow
       
  2772         Not enough data in file to identify which plugin decoder to use.
       
  2773 @leave  KErrNotFound
       
  2774         Either the appropriate plugin decoder for this file hasn't been found, or the file itself is missing.
       
  2775 @leave  KEComErrNoInterfaceIdentified
       
  2776 		ECom could not find the specified interface.		
       
  2777 
       
  2778 @panic  ImageConversion 19
       
  2779         No base type given for sub-type.
       
  2780 
       
  2781 @see    TOptions
       
  2782 */
       
  2783 EXPORT_C CImageDecoder* CImageDecoder::FileNewL(RFs& aFs, const TDesC& aSourceFilename, const TOptions aOptions, const TUid aImageType, const TUid aImageSubType, const TUid aDecoderUid)
       
  2784 	{
       
  2785 	return CImageDecoder::FileNewImplL(aFs, aSourceFilename, KDefaultContentObject, EPeek, aOptions, aImageType, aImageSubType, aDecoderUid);
       
  2786 	}
       
  2787 
       
  2788 /**
       
  2789 Creates a decoder for the image in the named file. If the client supplies an
       
  2790 image type (and sub-type, if applicable) or decoder UID, these will be used
       
  2791 to try and select an appropriate plugin decoder. If not, then the selection
       
  2792 will be done by matching the image header in the file. If it finds a decoder
       
  2793 it creates it and then goes on to use that decoder to scan the beginning of
       
  2794 the image file.
       
  2795 
       
  2796 @param  aFs
       
  2797         A reference to a file server session for the decoder to use.
       
  2798 @param  aSourceFilename
       
  2799         The name of the file to be decoded.
       
  2800 @param  aIntent
       
  2801         The DRM Intent for image conversion.
       
  2802 @param  aOptions
       
  2803         The decoder options to use. See TOptions.
       
  2804 @param  aImageType
       
  2805         The image type of the image in the file (optional, defaults to KNullUid).
       
  2806 @param  aImageSubType
       
  2807         The image sub-type of the image in the file (optional, defaults to KNullUid).
       
  2808 @param  aDecoderUid
       
  2809 		The implementation UID for a specific codec or a decoder/encoder class UID (optional, defaults to KNullUid).
       
  2810 		If this option is selected for a specific codec the image type and image sub type for the displayer must be supplied.
       
  2811 		When loading plugins by class UID the image type and image subtype are not mandatory and the first valid plugin from 
       
  2812 		the list of available plugins with the specified class UID will be loaded.
       
  2813 @see	KUidICLJpegEXIFInterface
       
  2814 @see	KUidICLJpegImageFrameInterface
       
  2815 
       
  2816 @return	A pointer to the newly created decoder.
       
  2817 
       
  2818 @leave  KErrUnderflow
       
  2819         Not enough data in file to identify which plugin decoder to use.
       
  2820 @leave  KErrNotFound
       
  2821         Either the appropriate plugin decoder for this file hasn't been found, or the file itself is missing.
       
  2822 @leave  KEComErrNoInterfaceIdentified
       
  2823 		ECom could not find the specified interface.		
       
  2824 
       
  2825 @panic  ImageConversion 19
       
  2826         No base type given for sub-type.
       
  2827 
       
  2828 @see     TOptions
       
  2829 */
       
  2830 EXPORT_C CImageDecoder* CImageDecoder::FileNewL(RFs& aFs, const TDesC& aSourceFilename, TIntent aIntent, const TOptions aOptions, const TUid aImageType, const TUid aImageSubType, const TUid aDecoderUid)
       
  2831 	{
       
  2832 	return CImageDecoder::FileNewImplL(aFs, aSourceFilename, KDefaultContentObject, aIntent, aOptions, aImageType, aImageSubType, aDecoderUid);
       
  2833 	}
       
  2834 
       
  2835 /**
       
  2836 @internalTechnology
       
  2837 
       
  2838 Creates a decoder for the image in the named file. If the client supplies an
       
  2839 image type (and sub-type, if applicable) or decoder UID, these will be used
       
  2840 to try and select an appropriate plugin decoder. If not, then the selection
       
  2841 will be done by matching the image header in the file. If it finds a decoder
       
  2842 it creates it and then goes on to use that decoder to scan the beginning of
       
  2843 the image file.
       
  2844 
       
  2845 
       
  2846 @param  aFs
       
  2847         A reference to a file server session for the decoder to use.
       
  2848 @param  aSourceFilename
       
  2849         The name of the file to be decoded.
       
  2850 @param  aUniqueId
       
  2851         The object to open for reading. If the UniqueId is set to KNullDesC the entire file will be opened for reading with no transformation.
       
  2852 @param  aIntent
       
  2853         The DRM Intent for image conversion
       
  2854 @param  aOptions
       
  2855         The decoder options to use. See TOptions.
       
  2856 @param  aImageType
       
  2857         The image type of the image in the file (optional, defaults to KNullUid).
       
  2858 @param  aImageSubType
       
  2859         The image sub-type of the image in the file (optional, defaults to KNullUid).
       
  2860 @param  aDecoderUid
       
  2861 		The implementation UID for a specific codec or a decoder/encoder class UID (optional, defaults to KNullUid).
       
  2862 		If this option is selected for a specific codec the image type and image sub type for the displayer must be supplied.
       
  2863 		When loading plugins by class UID the image type and image subtype are not mandatory and the first valid plugin from 
       
  2864 		the list of available plugins with the specified class UID will be loaded.
       
  2865 @see	KUidICLJpegEXIFInterface
       
  2866 @see	KUidICLJpegImageFrameInterface
       
  2867 
       
  2868 @return A pointer to the newly created decoder.
       
  2869 
       
  2870 @leave  KErrUnderflow
       
  2871         Not enough data in file to identify which plugin decoder to use.
       
  2872 @leave  KEComErrNoInterfaceIdentified
       
  2873         ECom could not find the specified interface.
       
  2874 @leave  KErrNotFound
       
  2875         Either the appropriate plugin decoder for this file hasn't been found, or the file itself is missing.
       
  2876 @panic  ImageConversion 19
       
  2877         No base type given for sub-type.
       
  2878 
       
  2879 @see    TOptions
       
  2880  */
       
  2881 
       
  2882 CImageDecoder* CImageDecoder::FileNewImplL(RFs& aFs, const TDesC& aSourceFilename, const TDesC& aUniqueId, const TIntent aIntent, const TOptions aOptions, const TUid aImageType, const TUid aImageSubType, const TUid aDecoderUid)
       
  2883 	{
       
  2884 	if ((aImageType == KNullUid) && (aImageSubType != KNullUid))
       
  2885 		{ // Get out, no base type given for sub-type
       
  2886 		Panic(EIllegalImageSubType); 
       
  2887 		}
       
  2888 
       
  2889 	RImplInfoPtrArray decoderList;
       
  2890 	CleanupResetAndDestroyPushL(decoderList);
       
  2891 
       
  2892 	CContent* content = NULL;
       
  2893 	content = GetContentLC(aSourceFilename);
       
  2894 	CData* data = content->OpenContentL(aIntent, aUniqueId);
       
  2895 	CleanupStack::PopAndDestroy(content);
       
  2896 
       
  2897 	CleanupStack::PushL(data);
       
  2898 
       
  2899 	if (aImageType == KNullUid && aDecoderUid == KNullUid)
       
  2900 		{ 
       
  2901 		TBuf8<KMaxMimeLength> mimeType;
       
  2902 		if (data->GetMimeTypeL(mimeType))
       
  2903 			{
       
  2904 			// try to find a controller based on MIME type
       
  2905 			CImageDecoder::MimeTypeGetDecoderListL(decoderList, mimeType, aOptions);
       
  2906 			}
       
  2907 		if (decoderList.Count()==0)
       
  2908 			{
       
  2909 			// read header data
       
  2910 			TBuf8<KImageHeaderSize> imageHeader;
       
  2911 			User::LeaveIfError(data->Read(imageHeader, KImageHeaderSize));
       
  2912 			CImageDecoder::ImageTypeGetDecoderListL(decoderList, imageHeader, aImageType, aImageSubType, aDecoderUid, aOptions);
       
  2913 			}
       
  2914 		}
       
  2915 	else
       
  2916 		{
       
  2917 		TBuf8<KImageHeaderSize> imageHeader;
       
  2918 		User::LeaveIfError(data->Read(imageHeader, KImageHeaderSize));
       
  2919 		CImageDecoder::ImageTypeGetDecoderListL(decoderList, imageHeader, aImageType, aImageSubType, aDecoderUid, aOptions);
       
  2920 		}
       
  2921 	
       
  2922 	CleanupStack::PopAndDestroy(1, data); //data
       
  2923 
       
  2924 	//Try to match by file extension only
       
  2925 	//1) If no plugin was found and 
       
  2926 	//2) No specific decoder or format was specified
       
  2927 	const TBool formatSpecified = (aImageType!=KNullUid || aImageSubType!=KNullUid || aDecoderUid!=KNullUid);
       
  2928 	if(decoderList.Count()==0 && !formatSpecified)
       
  2929 		{
       
  2930 		CImageDecoder::SuffixTypeGetDecoderListL(decoderList, aSourceFilename, aOptions);
       
  2931 		}
       
  2932 
       
  2933 	CImageDecoder* decoder = NULL;
       
  2934 	decoder = CImageDecoder::FileFindDecoderNewL(decoderList, aFs, aSourceFilename, aOptions, aUniqueId);
       
  2935 
       
  2936 
       
  2937 	ASSERT(decoder!=NULL);
       
  2938 	CleanupStack::PushL(decoder);
       
  2939 	decoder->iRelay->SetIntent(aIntent);
       
  2940 
       
  2941 	CleanupStack::Pop(decoder);
       
  2942 	CleanupStack::PopAndDestroy(&decoderList);
       
  2943 	return decoder;
       
  2944 	}
       
  2945 
       
  2946 
       
  2947 /**
       
  2948 Creates a decoder for the image in the source buffer. 
       
  2949 
       
  2950 If the client supplies an image type (and sub-type, if applicable) or decoder UID, 
       
  2951 these will be used to try and select an appropriate plugin decoder. If not, then 
       
  2952 the selection will be done by matching the image header from the buffer. If it
       
  2953 finds a decoder, it is created and then used to scan the beginning of the image
       
  2954 buffer.
       
  2955 
       
  2956 @param  aFs
       
  2957         A reference to a file server session for the decoder to use.
       
  2958 @param  aSourceData
       
  2959         The buffer containing the image to be decoded. Note that the framework 
       
  2960         doesn't take a copy of the actual data, therefore both the descriptor
       
  2961         object and the data must persist during decoding.
       
  2962 @param  aOptions
       
  2963         Decoder options to use.
       
  2964 @param  aImageType
       
  2965         The image type of the image in the file (optional, defaults to KNullUid).
       
  2966 @param  aImageSubType
       
  2967         The image sub-type of the image in the file (optional, defaults to KNullUid).
       
  2968 @param	aDecoderUid
       
  2969 		The implementation UID for a specific codec or a decoder/encoder class UID (optional, defaults to KNullUid).
       
  2970 		If this option is selected for a specific codec the image type and image sub type for the displayer must be supplied.
       
  2971 		When loading plugins by class UID the image type and image subtype are not mandatory and the first valid plugin from 
       
  2972 		the list of available plugins with the specified class UID will be loaded.
       
  2973 @see	KUidICLJpegEXIFInterface
       
  2974 @see	KUidICLJpegImageFrameInterface
       
  2975 
       
  2976 @return	Returns a pointer to the newly created decoder.
       
  2977 
       
  2978 @leave  KErrUnderflow
       
  2979         Not enough data in descriptor to identify which plugin decoder to use.
       
  2980 @leave  KErrNotFound
       
  2981         No appropriate plugin decoder for this image has been found.
       
  2982 @leave  KEComErrNoInterfaceIdentified
       
  2983 		ECom could not find the specified interface.		
       
  2984 
       
  2985 @panic  ImageConversion 19
       
  2986         No base type given for sub-type.
       
  2987 
       
  2988 @see    TOptions
       
  2989 */
       
  2990 EXPORT_C CImageDecoder* CImageDecoder::DataNewL(RFs& aFs, const TDesC8& aSourceData, const TOptions aOptions, const TUid aImageType, const TUid aImageSubType, const TUid aDecoderUid)
       
  2991 	{
       
  2992 	if ((aImageType == KNullUid) && (aImageSubType != KNullUid))
       
  2993 		{ // Get out, no base type given for sub-type
       
  2994 		Panic(EIllegalImageSubType); 
       
  2995 		}
       
  2996 
       
  2997 	//Get a list of decoders that will decode the image
       
  2998 	RImplInfoPtrArray decoderList;
       
  2999 	CleanupResetAndDestroyPushL(decoderList);
       
  3000 	CImageDecoder::ImageTypeGetDecoderListL(decoderList, aSourceData, aImageType, aImageSubType, aDecoderUid, aOptions);
       
  3001 
       
  3002 	CImageDecoder* decoder = NULL;
       
  3003 	decoder = CImageDecoder::DataFindDecoderNewL(decoderList, aFs, aSourceData, aOptions);
       
  3004 	ASSERT(decoder!=NULL);
       
  3005 
       
  3006 	CleanupStack::PopAndDestroy(&decoderList);
       
  3007 	return decoder;
       
  3008 
       
  3009 
       
  3010 	}
       
  3011 
       
  3012 /**
       
  3013 @internalTechnology
       
  3014 
       
  3015 Called internally to create a CImageDecoder and associated iRelay body
       
  3016 
       
  3017 This member is internal and not intended for use.
       
  3018 */
       
  3019 CImageDecoder* CImageDecoder::NewL(CImageDecodeConstruct* aConstruct, TOptions aOptions)
       
  3020 	{
       
  3021 	CleanupStack::PushL(aConstruct); // we take ownership of this until can pass to relay
       
  3022 	CImageDecoder* self = aConstruct->NewDecoderL(); // typically will callback to CImageDecoder::NewL()
       
  3023 	CleanupStack::PushL(self);
       
  3024 	TBool alwaysThread = (aOptions & EOptionAlwaysThread)!=EFalse;
       
  3025 	self->iRelay = MImageDecoderRelay::NewL(aConstruct, alwaysThread);
       
  3026 	CleanupStack::Pop(2); // self and construct
       
  3027 	self->iRelay->TransferConstructOwnership();
       
  3028 	return self;
       
  3029 	}
       
  3030 
       
  3031 /**
       
  3032 @internalTechnology
       
  3033 
       
  3034 Actual factory function for CImageDecoder - ie. it creates the object
       
  3035 Called back plugin - to allow plugin to override if required
       
  3036 
       
  3037 This member is internal and not intended for use.
       
  3038 */
       
  3039 CImageDecoder* CImageDecoder::NewL()
       
  3040 	{
       
  3041 	CImageDecoder* self = new (ELeave) CImageDecoder;
       
  3042 	return self;
       
  3043 	}
       
  3044 
       
  3045 /**
       
  3046 Constructor for this class.
       
  3047 @internalTechnology
       
  3048 */
       
  3049 EXPORT_C CImageDecoder::CImageDecoder()
       
  3050 	{
       
  3051 	}
       
  3052 
       
  3053 /**
       
  3054 Destructor for this class.
       
  3055 
       
  3056 If using a local file session, it closes it.
       
  3057 It also informs ECom that has finished with the decoder instance.
       
  3058 
       
  3059 Frees all resources owned by the object prior to its destruction.
       
  3060 */
       
  3061 EXPORT_C CImageDecoder::~CImageDecoder()
       
  3062 	{
       
  3063 	Cancel();
       
  3064 
       
  3065 	delete iRelay;
       
  3066 	}
       
  3067 
       
  3068 /**
       
  3069 Start decoding an image frame asynchronously.
       
  3070 
       
  3071 @pre
       
  3072 The destination bitmap aDestination, must be created before the call to
       
  3073 Convert() is made. aDestination must be large enough to contain the frame and
       
  3074 be set to the required display mode. FrameInfo() can be used to obtain
       
  3075 the size and display mode of the frame.
       
  3076 
       
  3077 When the conversion is complete, successfully or otherwise, the status is 
       
  3078 returned in aRequestStatus. 
       
  3079 
       
  3080 If the operations completes with KErrUnderflow, then there is insufficient 
       
  3081 information in the descriptor. In this situation, ContinueConvert() should be 
       
  3082 called repeatedly until the descriptor has accumulated enough information 
       
  3083 for ContinueConvert() to complete with KErrNone.It is the responsibility of the 
       
  3084 caller to ensure that the original data source used to create this decoder object 
       
  3085 gets enough information. If there is no data available then a caller can ignore 
       
  3086 this error code and use partially decoded image.
       
  3087 
       
  3088 @param  aRequestStatus
       
  3089         Request status. On completion contains an error code.
       
  3090         KErrNone if frame was decoded successfully,
       
  3091         KErrUnderflow if the frame was partially decoded
       
  3092         otherwise another of the system-wide error codes.
       
  3093 @param  aDestination
       
  3094         A bitmap that will contain the decoded frame.
       
  3095 @param	aFrameNumber
       
  3096         The frame in a multi-frame image to decode (optional, defaults to zero).
       
  3097 
       
  3098 @note
       
  3099 As most codec plugins support downscaling the image but not upscaling, the standard behaviour (i.e. no requested
       
  3100 transformations) for codecs begins with the size of the destination bitmap passed to CImageDecoder::Convert being
       
  3101 inspected, and:
       
  3102 
       
  3103 - 1. If the destination size matches the frame size of the image then the image is decoded full size into the destination
       
  3104 bitmap.
       
  3105 - 2. If the destination size is larger than the frame size of the image then the image is decoded full size into the
       
  3106 destination bitmap with no upscaling. The image origin is aligned with the top left corner of the bitmap and any area
       
  3107 in the bitmap to the bottom and right of image is left in its initialised state.
       
  3108 - 3. If the destination size is smaller than the frame size of the image then a reduction factor is calculated and the
       
  3109 image is scaled down (1/2, 1/4, 1/8 size) whilst maintaining the aspect ratio of the image. The size is the next
       
  3110 smallest size that will fit in the destination bitmap. The use case for this is when the client wants to pass in the
       
  3111 screen size of device and have the image scaled to fill as much of the screen as possible.
       
  3112 However, if the extension interfaces (clipping, scale, operation) are used then the additional behaviour below applies.
       
  3113 - 4. If the extension interfaces for clipping rectangle and/or operation are applied, but not scaling, then the size of
       
  3114 the destination bitmap for an unscaled image can be obtained via CImageDecoder::GetDestinationSize.
       
  3115 Lets call that SizeA. The same rules apply as given in 1, 2, 3 above resulting in a down-scaled destination if the
       
  3116 destination bitmap is smaller than SizeA.
       
  3117 - 5. If the extension interface for scaling is called via one of the two TImageConvScaler::SetScalingL(.. functions then
       
  3118 it is required that the destination size is obtained through CImageDecoder::GetDestinationSize and that a destination
       
  3119 bitmap of that size is passed to CImageDecoder::Convert. Failure to do this will cause the decoder to fail with KErrArgument.
       
  3120 This rule holds if clipping and/or operation is applied as well as scaling.
       
  3121 */
       
  3122 EXPORT_C void CImageDecoder::Convert(TRequestStatus* aRequestStatus, CFbsBitmap& aDestination, TInt aFrameNumber)
       
  3123 	{
       
  3124 	ASSERT(ValidProperties());
       
  3125 	iRelay->Convert(aRequestStatus, aDestination, aFrameNumber);
       
  3126 	}
       
  3127 
       
  3128 /**
       
  3129 Set the source image type, this can be any value from TImageType. It can leave with a system wide
       
  3130 error. Typical leaves are documented below.
       
  3131    
       
  3132 @param 	aImageType
       
  3133 		An image type from TImageType to denote source image that the decoder should use.
       
  3134 @leave  KErrNotFound
       
  3135 		If the image for the type specified is not found.
       
  3136 @leave  KErrCorrupt
       
  3137 		For a corrupt image. In the case of failing to change the source image from a valid 
       
  3138 		EImageTypeMain image to a corrupt EImageTypeThumbnail, the decoder resets the image 
       
  3139 		type back to the valid EImageTypeMain.
       
  3140 */
       
  3141 EXPORT_C void CImageDecoder::SetImageTypeL(TInt aImageType)
       
  3142 	{
       
  3143 	ASSERT(ValidProperties());
       
  3144 	iRelay->SetImageTypeL(aImageType);
       
  3145 	}
       
  3146 
       
  3147 
       
  3148 /**
       
  3149 Start decoding an image frame and mask asynchronously.
       
  3150 
       
  3151 @pre
       
  3152 The destination bitmap aDestination, must be created before the call to
       
  3153 Convert() is made. aDestination must be large enough to contain the frame and
       
  3154 be set to the required display mode. FrameInfo() can be used to obtain
       
  3155 the size and display mode of the frame. The destination mask aDestinationMask
       
  3156 must be created before the call to Convert() is made and must be large enough for
       
  3157 the mask. The display mode must be EGray2 or EGray256 and must be EGray256 if the
       
  3158 image contains alpha-blending information. This information can be obtained from
       
  3159 the iFlags property of TFrameInfo obtained from a FrameInfo() call.
       
  3160 
       
  3161 When the conversion is complete, successfully or otherwise, the status is 
       
  3162 returned in aRequestStatus.
       
  3163 
       
  3164 If the operations completes with KErrUnderflow, then there is insufficient 
       
  3165 information in the descriptor. In this situation, ContinueConvert() should be 
       
  3166 called repeatedly until the descriptor has accumulated enough information 
       
  3167 for ContinueConvert() to complete with KErrNone.It is the responsibility of the 
       
  3168 caller to ensure that the original data source used to create this decoder object 
       
  3169 gets enough information. If there is no data available then a caller can ignore 
       
  3170 this error code and use partially decoded image.
       
  3171 
       
  3172 @param  aRequestStatus
       
  3173         Request status. On completion contains an error code.
       
  3174         KErrNone if frame was decoded successfully,
       
  3175         KErrUnderflow if the frame was partially decoded
       
  3176         otherwise another of the system-wide error codes.
       
  3177 @param  aDestination
       
  3178         A bitmap that will contain the decoded frame.
       
  3179 @param  aDestinationMask
       
  3180         A bitmap that will contain the decoded frame mask.
       
  3181 @param  aFrameNumber
       
  3182         The frame in multi-frame image to decode (optional, defaults to zero).
       
  3183 
       
  3184 @see    TFrameInfo
       
  3185 */
       
  3186 EXPORT_C void CImageDecoder::Convert(TRequestStatus* aRequestStatus, CFbsBitmap& aDestination, CFbsBitmap& aDestinationMask, TInt aFrameNumber)
       
  3187 	{
       
  3188 	ASSERT(ValidProperties());
       
  3189 	iRelay->Convert(aRequestStatus, aDestination, aDestinationMask, aFrameNumber);
       
  3190 	}
       
  3191 
       
  3192 /**
       
  3193 Continue decoding a frame and/or mask after new image data was added to
       
  3194 the source file or descriptor and a previous call to Convert() or
       
  3195 ContinueConvert() returned KErrUnderflow.
       
  3196 
       
  3197 @param  aRequestStatus
       
  3198         Request status. On completion contains an error code.
       
  3199         KErrNone if frame was decoded successfully,
       
  3200         KErrUnderflow if the frame was partially decoded
       
  3201         otherwise another of the system-wide error codes.
       
  3202 */
       
  3203 EXPORT_C void CImageDecoder::ContinueConvert(TRequestStatus* aRequestStatus)
       
  3204 	{
       
  3205 	ASSERT(ValidProperties());
       
  3206 	iRelay->ContinueConvert(aRequestStatus);
       
  3207 	}
       
  3208 
       
  3209 /**
       
  3210 Return the number of frames in the image being decoded. 
       
  3211 
       
  3212 This function can be called immediately after the call to create the decoder, 
       
  3213 thus enabling the caller to know how many frames need to be converted. Client 
       
  3214 may have to call IsImageHeaderProcessingComplete() & ContinueProcessingHeaders() 
       
  3215 to ensure all all data is available.
       
  3216 
       
  3217 @return The number of frames in the source image.
       
  3218 */
       
  3219 EXPORT_C TInt CImageDecoder::FrameCount() const
       
  3220 	{
       
  3221 	ASSERT(ValidProperties());
       
  3222 	return iRelay->FrameCount();
       
  3223 	}
       
  3224 
       
  3225 /**
       
  3226 Return the status of the image.
       
  3227 
       
  3228 If the image is incomplete EFalse will be returned. The client should continue
       
  3229 to supply more data and call ContinueProcessingHeaders() until ETrue is returned.
       
  3230 
       
  3231 Panic categories:  Many CImageDecoder functions are dependent upon this function
       
  3232 returning ETrue before they can successfully be called.  If the client calls one
       
  3233 of these dependent functions, then that function call may panic with either the 
       
  3234 'ImageConversion' panic category or a decoder plugin specific panic category,
       
  3235 for example: 'BMPConvertPlugin', 'GIFConvertPlugin', 'ICOConvertPlugin',
       
  3236 'JPEGConvertPlugin', 'MBMConvertPlugin', 'OTAConvertPlugin', 'PNGConvertPlugin',
       
  3237 'TIFFConvertPlugin', 'WBMPConvertPlugin', 'WMFConvertPlugin'.
       
  3238 
       
  3239 
       
  3240 @return Image status.
       
  3241 */
       
  3242 EXPORT_C TBool CImageDecoder::IsImageHeaderProcessingComplete() const
       
  3243 	{
       
  3244 	return iRelay->IsImageHeaderProcessingComplete();
       
  3245 	}
       
  3246 
       
  3247 /**
       
  3248 Continue processing image headers after new image data was added to
       
  3249 the source file or descriptor.
       
  3250 
       
  3251 @see IsImageHeaderProcessingComplete()
       
  3252 */
       
  3253 EXPORT_C void CImageDecoder::ContinueProcessingHeaderL()
       
  3254 	{
       
  3255 	ASSERT(ValidProperties());
       
  3256 	iRelay->ContinueProcessingHeaderL();
       
  3257 	}
       
  3258 
       
  3259 /**
       
  3260 Cancels any conversions currently in progress (Cancel is synchronous).
       
  3261 */
       
  3262 EXPORT_C void CImageDecoder::Cancel()
       
  3263 	{
       
  3264 	if(ValidProperties())
       
  3265 		iRelay->Cancel();
       
  3266 	}
       
  3267 
       
  3268 /**
       
  3269 Return the frame info for a specified frame of the image. 
       
  3270 
       
  3271 This function can be called immediately after the call to create 
       
  3272 the decoder, thus enabling the caller to know about each frame in 
       
  3273 advance of converting it.
       
  3274 
       
  3275 The returned information contains details of the size of the image,
       
  3276 the dimensions of the frame, its colour depth and so on. More advanced 
       
  3277 information may be available for the image using FrameData().
       
  3278 
       
  3279 Use FrameCount() to determine how many frames are contained in the image 
       
  3280 before using this function.
       
  3281 
       
  3282 @param  aFrameNumber
       
  3283         The frame number.
       
  3284 
       
  3285 @return The returned information for the specified frame.
       
  3286 
       
  3287 @panic  ImageConversion 10
       
  3288         Frame number outside the range 0 to FrameCount()-1.
       
  3289         See CImageDecoder::FrameCount().
       
  3290 
       
  3291 @see	CImageDecoder::FrameCount()
       
  3292 */
       
  3293 EXPORT_C const TFrameInfo& CImageDecoder::FrameInfo(TInt aFrameNumber) const
       
  3294 	{
       
  3295 	// Return the frame info for a particular frame
       
  3296 	ASSERT(ValidProperties());
       
  3297 	return iRelay->FrameInfo(aFrameNumber);
       
  3298 	}
       
  3299 
       
  3300 /**
       
  3301 Returns additional plugin specific information on a specified frame.
       
  3302 
       
  3303 The plugin specific information usually covers advanced image features such 
       
  3304 as image quality, advanced colour settings and so on.
       
  3305 
       
  3306 Use FrameCount() to determine how many frames are contained in the 
       
  3307 image before using this function.
       
  3308 
       
  3309 @param  aFrameNumber
       
  3310         The frame number.
       
  3311 
       
  3312 @return The data for the specified frame.
       
  3313 
       
  3314 @panic  ImageConversion 10
       
  3315         Frame number outside the range 0 to FrameCount()-1.
       
  3316         See CImageDecoder::FrameCount().
       
  3317 
       
  3318 @see	CImageDecoder::FrameCount()
       
  3319 */
       
  3320 EXPORT_C const CFrameImageData& CImageDecoder::FrameData(TInt aFrameNumber) const
       
  3321 	{
       
  3322 	// Return the frame image data for a particular frame.
       
  3323 	ASSERT(ValidProperties());
       
  3324 	return iRelay->FrameData(aFrameNumber);
       
  3325 	}
       
  3326 
       
  3327 /**
       
  3328 Return the number of comments attached to the image (as opposed to
       
  3329 a particular frame).
       
  3330 
       
  3331 For further informantion on panic categories, please see the note in
       
  3332 CImageDecoder::IsImageHeaderProcessingComplete().
       
  3333 
       
  3334 @panic  ImageConversion 13 Header processing has not completed.
       
  3335 		See CImageDecoder::IsImageHeaderProcessingComplete().
       
  3336 
       
  3337 @see	IsImageHeaderProcessingComplete()
       
  3338 
       
  3339 @return The number of comments attached to the image.
       
  3340 */
       
  3341 EXPORT_C TInt CImageDecoder::NumberOfImageComments() const
       
  3342 	{
       
  3343 	ASSERT(ValidProperties());
       
  3344 	return iRelay->Plugin()->NumberOfImageComments();
       
  3345 	}
       
  3346 
       
  3347 /**
       
  3348 Return a particular comment attached to the image.
       
  3349 
       
  3350 Ownership of the returned buffer is transferred to the caller. Use NumberOfImageComments() 
       
  3351 to determine how many (if any) comments are contained within the image.
       
  3352 
       
  3353 For further informantion on panic categories, please see the note in
       
  3354 CImageDecoder::IsImageHeaderProcessingComplete().
       
  3355 
       
  3356 @param  aCommentNumber	The comment number.
       
  3357 
       
  3358 @panic 	ImageConversion 12 Comments are not supported.
       
  3359 		See CImageDecoder::NumberOfImageComments().
       
  3360 
       
  3361 @panic  ImageConversion 13 Header processing has not completed.
       
  3362 		See CImageDecoder::IsImageHeaderProcessingComplete().
       
  3363 
       
  3364 @panic 	ImageConversion 14 aCommentNumber is not valid.
       
  3365 		See CImageDecoder::NumberOfImageComments().
       
  3366 
       
  3367 @see	IsImageHeaderProcessingComplete()
       
  3368 @see	NumberOfImageComments()
       
  3369 
       
  3370 @return A buffer containing the comment.
       
  3371 */
       
  3372 EXPORT_C HBufC* CImageDecoder::ImageCommentL(TInt aCommentNumber) const
       
  3373 	{
       
  3374 	ASSERT(ValidProperties());
       
  3375 	return iRelay->Plugin()->ImageCommentL(aCommentNumber);
       
  3376 	}
       
  3377 
       
  3378 /**
       
  3379 Return the number of comments attached to a given frame of the image
       
  3380 (as opposed to the whole image).
       
  3381 
       
  3382 Use FrameCount() to retrieve the number of frames in the image to ensure 
       
  3383 that a valid aFrameNumber is used.
       
  3384 
       
  3385 For further informantion on panic categories, please see the note in
       
  3386 CImageDecoder::IsImageHeaderProcessingComplete().
       
  3387 
       
  3388 @param	aFrameNumber The frame number.
       
  3389 
       
  3390 @panic 	ImageConversion 10 aFrameNumber is not valid.
       
  3391 		See CImageDecoder::FrameCount().
       
  3392 
       
  3393 @panic  ImageConversion 13 Header processing has not completed.
       
  3394 		See CImageDecoder::IsImageHeaderProcessingComplete().
       
  3395 
       
  3396 @see	IsImageHeaderProcessingComplete()
       
  3397 @see	FrameCount()
       
  3398 
       
  3399 @return	The number of comments attached to a given frame of the image.
       
  3400 */
       
  3401 EXPORT_C TInt CImageDecoder::NumberOfFrameComments(TInt aFrameNumber) const
       
  3402 	{
       
  3403 	ASSERT(ValidProperties());
       
  3404 	return iRelay->Plugin()->NumberOfFrameComments(aFrameNumber);
       
  3405 	}
       
  3406 
       
  3407 /**
       
  3408 Return a particular comment attached to a given frame of the image.
       
  3409 
       
  3410 The desired order of calling methods should be FrameCount(),NumberOfFrameComments() and then FrameCommentL().
       
  3411 
       
  3412 Use FrameCount() to retrieve the number of frames in the image to ensure that a valid aFrameNumber is used.
       
  3413 
       
  3414 Use NumberOfFrameComments() to retrieve the number of comments attached to a given frame
       
  3415 of the image (as opposed to the whole image),to ensure that a valid aCommentNumber is used.
       
  3416 
       
  3417 Ownership of the returned buffer is transferred to the caller.
       
  3418 
       
  3419 For further informantion on panic categories, please see the note in
       
  3420 CImageDecoder::IsImageHeaderProcessingComplete().
       
  3421 
       
  3422 @param  aFrameNumber	The frame number within the image from which to retrieve the specified comment.
       
  3423 
       
  3424 @param  aCommentNumber	The comment number to retrieve from the specified frame.
       
  3425 
       
  3426 @panic 	ImageConversion 10 aFrameNumber is not valid.
       
  3427 		See CImageDecoder::FrameCount().
       
  3428 
       
  3429 @panic  ImageConversion 13 Header processing has not completed.
       
  3430 		See CImageDecoder::IsImageHeaderProcessingComplete().
       
  3431 		
       
  3432 @panic	ImageConversion 14 aCommentNumber is not valid.
       
  3433 		See CImageDecoder::NumberOfFrameComments().
       
  3434 
       
  3435 @see	IsImageHeaderProcessingComplete()
       
  3436 @see	FrameCount()
       
  3437 @see	NumberOfFrameComments()
       
  3438 
       
  3439 @return A buffer containing the specified comment.
       
  3440 */
       
  3441 EXPORT_C HBufC* CImageDecoder::FrameCommentL(TInt aFrameNumber, TInt aCommentNumber) const
       
  3442 	{
       
  3443 	ASSERT(ValidProperties());
       
  3444 	return iRelay->Plugin()->FrameCommentL(aFrameNumber, aCommentNumber);
       
  3445 	}
       
  3446 
       
  3447 /**
       
  3448 Return the formatted frame information strings for a specific frame
       
  3449 and leave it on the cleanup stack.
       
  3450 
       
  3451 Ownership is transferred to the caller.
       
  3452 
       
  3453 @param  aFrameNumber
       
  3454         The frame number from which to retrieve the formatted information string.
       
  3455 
       
  3456 @return The formatted frame information strings.
       
  3457 */
       
  3458 EXPORT_C CFrameInfoStrings* CImageDecoder::FrameInfoStringsLC(TInt aFrameNumber)
       
  3459 	{
       
  3460 	ASSERT(ValidProperties());
       
  3461 	return iRelay->FrameInfoStringsLC(aFrameNumber);
       
  3462 	}
       
  3463 
       
  3464 /**
       
  3465 Return the formatted frame information strings for a specific frame.
       
  3466 Ownership is transferred to the caller.
       
  3467 
       
  3468 @param  aFrameNumber
       
  3469         The frame number from which to retrieve the formatted information string.
       
  3470 
       
  3471 @return The formatted frame information strings.
       
  3472 */
       
  3473 EXPORT_C CFrameInfoStrings* CImageDecoder::FrameInfoStringsL(TInt aFrameNumber)
       
  3474 	{
       
  3475 	CFrameInfoStrings* frameInfoStrings = FrameInfoStringsLC(aFrameNumber);
       
  3476 	CleanupStack::Pop();
       
  3477 
       
  3478 	return frameInfoStrings;
       
  3479 	}
       
  3480 
       
  3481 /**
       
  3482 Return the implementation UID of the decoder being used to decode the image.
       
  3483 
       
  3484 @return	The implementation UID of the decoder.
       
  3485 */
       
  3486 EXPORT_C TUid CImageDecoder::ImplementationUid() const
       
  3487 	{
       
  3488 	return iRelay->ImplementationUid();
       
  3489 	}
       
  3490 
       
  3491 /**
       
  3492 Retrieves the image type and sub-type for a given frame of the image that
       
  3493 has just been decoded.
       
  3494 
       
  3495 For further informantion on panic categories, please see the note in
       
  3496 CImageDecoder::IsImageHeaderProcessingComplete().
       
  3497 
       
  3498 @param  aFrameNumber
       
  3499         The frame number for which type information should be retreived.
       
  3500 @param  aImageType
       
  3501         On return contains the image type UID for the specified frame.
       
  3502 @param  aImageSubType
       
  3503         On return contains the image sub-type UID if there is one (or KNullUid if 
       
  3504 		there is not).
       
  3505 
       
  3506 @panic 	ImageConversion 10 aFrameNumber is not valid.
       
  3507 		See CImageDecoder::FrameCount().
       
  3508 
       
  3509 @see	IsImageHeaderProcessingComplete()
       
  3510 @see	FrameCount()
       
  3511 */
       
  3512 EXPORT_C void CImageDecoder::ImageType(TInt aFrameNumber, TUid& aImageType, TUid& aImageSubType) const
       
  3513 	{
       
  3514 	ASSERT(ValidProperties());
       
  3515 	iRelay->Plugin()->ImageType(aFrameNumber, aImageType, aImageSubType);	
       
  3516 	}
       
  3517 
       
  3518 /**
       
  3519 Calls CImageDecoderPlugin::HandleCustomSyncL(aParam) that executes user defined plugin 
       
  3520 specific functions. Subsequent behaviour depends on the CImageDecoderPlugin class.
       
  3521 
       
  3522 This function is part of the support for extended codecs for use within classes 
       
  3523 derived from CImageDecoder.
       
  3524 
       
  3525 Note: This function is intended for use by plugin writers only.
       
  3526 
       
  3527 @param  aParam
       
  3528         Interpretation dependent on plugin.
       
  3529         
       
  3530 @see    CImageDecoderPlugin::HandleCustomSyncL()
       
  3531 */
       
  3532 
       
  3533 EXPORT_C void CImageDecoder::CustomSyncL(TInt aParam)
       
  3534 	{
       
  3535 	ASSERT(ValidProperties());
       
  3536 	iRelay->CustomSyncL(aParam);
       
  3537 	}
       
  3538 
       
  3539 /**
       
  3540 Sets up background convert cycle, bypassing Convert().
       
  3541 A call to this will result in a call to the associated CImageDecoderPlugin::InitCustomAsyncL(aParam),
       
  3542 which if successful will start background processing. This function uses the same mechanism as Convert(),
       
  3543 and therefore cannot be used concurrently. Cancel() etc work as expected.
       
  3544 
       
  3545 Note: This function is intended for use by plugin writers only.
       
  3546 
       
  3547 @param  aRequestStatus
       
  3548         Request status. On completion contains an error code.
       
  3549         KErrNone if the bitmap was successfully decoded,
       
  3550         otherwise another of the system-wide error codes.
       
  3551 @param  aParam
       
  3552         Interpretation dependent on plugin.
       
  3553 */
       
  3554 EXPORT_C void CImageDecoder::CustomAsync(TRequestStatus* aRequestStatus, TInt aParam)
       
  3555 	{
       
  3556 	ASSERT(ValidProperties());
       
  3557 	iRelay->CustomAsync(aRequestStatus, aParam);
       
  3558 	}
       
  3559 
       
  3560 /**
       
  3561 Returns associated CImageDecoderPlugin.
       
  3562 
       
  3563 Allows the extended CImageDecoder object to talk to its CImageDecoderPlugin equivalent.
       
  3564 
       
  3565 Note: This function is intendend for use by plugin writers only.
       
  3566 
       
  3567 @return A pointer to the related CImageDecoderPlugin instance.
       
  3568 */
       
  3569 EXPORT_C CImageDecoderPlugin* CImageDecoder::Plugin() const
       
  3570 	{
       
  3571 	ASSERT(ValidProperties());
       
  3572 	return iRelay->Plugin();	
       
  3573 	}
       
  3574 
       
  3575 /**
       
  3576 @internalTechnology
       
  3577 
       
  3578 Intended for future proofing - will panic if called
       
  3579 
       
  3580 @panic  ImageConversion 30
       
  3581 */
       
  3582 EXPORT_C void CImageDecoder::ReservedVirtual1()
       
  3583 	{
       
  3584 	Panic(EReservedCall);
       
  3585 	}
       
  3586 
       
  3587 /**
       
  3588 @internalTechnology
       
  3589 
       
  3590 Intended for future proofing - will panic if called
       
  3591 
       
  3592 @panic  ImageConversion 30
       
  3593 */
       
  3594 EXPORT_C void CImageDecoder::ReservedVirtual2()
       
  3595 	{
       
  3596 	Panic(EReservedCall);
       
  3597 	}
       
  3598 
       
  3599 /**
       
  3600 @internalTechnology
       
  3601 
       
  3602 Intended for future proofing - will panic if called
       
  3603 
       
  3604 @panic  ImageConversion 30
       
  3605 */
       
  3606 EXPORT_C void CImageDecoder::ReservedVirtual3()
       
  3607 	{
       
  3608 	Panic(EReservedCall);
       
  3609 	}
       
  3610 
       
  3611 /**
       
  3612 @internalTechnology
       
  3613 
       
  3614 Intended for future proofing - will panic if called
       
  3615 
       
  3616 @panic  ImageConversion 30
       
  3617 */
       
  3618 EXPORT_C void CImageDecoder::ReservedVirtual4()
       
  3619 	{
       
  3620 	Panic(EReservedCall);
       
  3621 	}
       
  3622 
       
  3623 /**
       
  3624 Function to calculate the reduction factor based on the input parameters.
       
  3625 
       
  3626 @param  aOriginalSize
       
  3627         A reference to the original size of an image.
       
  3628 @param  aReducedSize
       
  3629         A reference to the new size of an image.
       
  3630 @return The reduction factor.
       
  3631 */
       
  3632 
       
  3633 EXPORT_C TInt CImageDecoder::ReductionFactor(const TSize& aOriginalSize, const TSize& aReducedSize) const
       
  3634 	{
       
  3635 	ASSERT(ValidProperties());
       
  3636 	return iRelay->ReductionFactor(aOriginalSize, aReducedSize);	
       
  3637 	}
       
  3638 
       
  3639 /**
       
  3640 Calculates reduced size of the decoded bitmap based on the input parameters and updates aReducedSize with this value.
       
  3641 
       
  3642 @param  aOriginalSize
       
  3643         A reference to the original size of an image.
       
  3644 @param  aReductionFactor
       
  3645         The Reduction Factor to be applied
       
  3646 @param  aReducedSize
       
  3647         A reference to the new size of the image.
       
  3648 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
       
  3649         KErrArgument.
       
  3650 */
       
  3651 	
       
  3652 EXPORT_C TInt CImageDecoder::ReducedSize(const TSize& aOriginalSize, TInt aReductionFactor, TSize& aReducedSize) const	
       
  3653 	{
       
  3654 	ASSERT(ValidProperties());
       
  3655 	return iRelay->ReducedSize(aOriginalSize, aReductionFactor, aReducedSize);	
       
  3656 	}
       
  3657 
       
  3658 
       
  3659 /**
       
  3660 Set the decoder worker thread priority
       
  3661 
       
  3662 @param  aPriority
       
  3663 		a new value for worker thread priority
       
  3664 @return KErrNotSupported 
       
  3665 		the decoder object doesn't use a worker thread.
       
  3666 		Other system-wide error codes.
       
  3667 @see	TThreadPriority
       
  3668 */
       
  3669 EXPORT_C TInt CImageDecoder::SetDecoderThreadPriority(TThreadPriority aPriority)
       
  3670 	{
       
  3671 	return iRelay->SetDecoderThreadPriority( aPriority );
       
  3672 	}
       
  3673 
       
  3674 
       
  3675 /* IMAGE ENCODER */
       
  3676 
       
  3677 /**
       
  3678 Returns a list of the basic image types that can be encoded, based on the
       
  3679 currently available encoder plugins.
       
  3680 
       
  3681 The returned array contains entries for the supported image types. Each entry
       
  3682 consists of the "display string" as well as the UID for that image type. Since 
       
  3683 this function only returns basic image type UID's, the second UID which represents 
       
  3684 the sub-type will always be zero.
       
  3685 
       
  3686 Ownership of the array is passed to the caller so, before the array goes out of 
       
  3687 scope in the client, the caller must call the array's ResetAndDestroy() method to free 
       
  3688 any entries.
       
  3689 
       
  3690 @param  aImageTypeArray
       
  3691         An empty array, into which this function will put a list of supported image types.
       
  3692 */
       
  3693 EXPORT_C void CImageEncoder::GetImageTypesL(RImageTypeDescriptionArray& aImageTypeArray)
       
  3694 	{
       
  3695 	ImageEnDecoderUtils::DoGetImageTypesL(KImageEncoderInterfaceUid, aImageTypeArray);
       
  3696 	}
       
  3697 
       
  3698 /**
       
  3699 @publishedAll
       
  3700 @released
       
  3701 
       
  3702 Gets a list of the properties of a specific encoder plugin.
       
  3703 
       
  3704 @param	aImplementationUid
       
  3705         The encoder implementation UID for which the plugin properties need to be retrieved.
       
  3706 @param	aPropertiesArray
       
  3707 		The array of plugin properties owned by the specified encoder.
       
  3708 		The caller has the ownership of the array.
       
  3709 */
       
  3710 EXPORT_C void CImageEncoder::GetPluginPropertiesL(const TUid aImplementationUid, RUidDataArray& aPropertiesArray)
       
  3711 	{
       
  3712 	ImageEnDecoderUtils::DoGetPluginPropertiesL(KImageEncoderInterfaceUid, aImplementationUid, aPropertiesArray);
       
  3713 	}
       
  3714 
       
  3715 /**
       
  3716 @publishedAll
       
  3717 @released
       
  3718 
       
  3719 Gets a list of encoder implementations UIDs that have some specific uids (properties, image type, image sub-type or class uids).
       
  3720 
       
  3721 @param	aRequiredUids
       
  3722         The array containing the UIDs of the required uids (properties, image type, image sub-type or class uids).
       
  3723 @param	aImplArray
       
  3724 		The array containing the implementation UIDs of the available encoder plugins with the required UIDs.
       
  3725 		The caller has the ownership of the array.
       
  3726 */
       
  3727 EXPORT_C void CImageEncoder::GetInterfaceImplementationsL(const RUidDataArray& aRequiredUids, RUidDataArray& aImplArray)
       
  3728 	{
       
  3729 	ImageEnDecoderUtils::DoGetInterfaceImplementationsL(KImageEncoderInterfaceUid, aRequiredUids, aImplArray);
       
  3730 	}
       
  3731 
       
  3732 /**
       
  3733 @publishedAll
       
  3734 @released
       
  3735 
       
  3736 Gets a list of encoder implementations UIDs that have some specific required uids (properties, image type, image sub-type or class uids).
       
  3737 
       
  3738 @param	aRequiredUids
       
  3739         The array containing the UIDs of the required uids (properties, image type, image sub-type or class uids).
       
  3740 @param	aLength
       
  3741 		The length of aRequiredUids (number of required uids).
       
  3742 @param	aImplArray
       
  3743 		The array containing the implementation UIDs of the available encoder plugins with the required UIDs.
       
  3744 		The caller has the ownership of the array.
       
  3745 */	
       
  3746 EXPORT_C void CImageEncoder::GetInterfaceImplementationsL(const TUid* aRequiredUids, const TInt aLength, RUidDataArray& aImplArray)
       
  3747 	{
       
  3748 	RUidDataArray requiredUids;
       
  3749 	CleanupClosePushL(requiredUids);
       
  3750 	for(TInt index = 0 ; index < aLength ; index++)
       
  3751 		{
       
  3752 		User::LeaveIfError(requiredUids.Append(aRequiredUids[index]));
       
  3753 		}
       
  3754 	ImageEnDecoderUtils::DoGetInterfaceImplementationsL(KImageEncoderInterfaceUid, requiredUids, aImplArray);
       
  3755 	CleanupStack::PopAndDestroy(1); //requiredUids
       
  3756 	}
       
  3757 
       
  3758 /**
       
  3759 For a given basic image type, returns a list of the image sub-types that can
       
  3760 be encoded, based on the currently available encoder plugins.
       
  3761 
       
  3762 Each entry in the returned array consists of the "display string" for
       
  3763 the plugin as well as the UID for the sub-type. The first UID represents
       
  3764 the basic type and is always set to aImageType.
       
  3765 
       
  3766 Ownership of the array is passed to the caller, so before the
       
  3767 array goes out of scope in the client, the caller must call
       
  3768 the array's ResetAndDestroy() method to free any entries.
       
  3769 
       
  3770 @param  aImageType
       
  3771         The basic image type for which a list of sub-types should be returned.
       
  3772 @param  aSubTypeArray
       
  3773         An empty array, into which this function will put a list of of supported
       
  3774         image sub-types.
       
  3775 */
       
  3776 EXPORT_C void CImageEncoder::GetImageSubTypesL(const TUid aImageType, RImageTypeDescriptionArray& aSubTypeArray)
       
  3777 	{
       
  3778 	ImageEnDecoderUtils::DoGetImageTypesL(KImageEncoderInterfaceUid, aSubTypeArray, aImageType);
       
  3779 	}
       
  3780 
       
  3781 /**
       
  3782 Get a list of the file extensions that can be encoded and their corresponding
       
  3783 MIME types, based on the currently available encoder plugins.
       
  3784 
       
  3785 @param  aFileTypeArray
       
  3786         An empty array, into which this function will put a list of
       
  3787         entries. Each entry will consist of a file extension string for
       
  3788         which an encoder plugin has been found, accompanied by the
       
  3789         primary MIME type and then any secondary MIME types
       
  3790         (if present).
       
  3791         
       
  3792 		Ownership of the array is passed to the caller, so before the
       
  3793 		array goes out of scope in the client, the caller must call
       
  3794 		the array's ResetAndDestroy() method to free any entries.
       
  3795 */
       
  3796 EXPORT_C void CImageEncoder::GetFileTypesL(RFileExtensionMIMETypeArray& aFileTypeArray)
       
  3797 	{
       
  3798 	ImageEnDecoderUtils::DoGetFileTypesL(KImageEncoderInterfaceUid, aFileTypeArray);
       
  3799 	}
       
  3800 
       
  3801 
       
  3802 /**
       
  3803 Creates an encoder based on a specified MIME type and write output to a named file.
       
  3804 
       
  3805 The client supplies a MIME type which will be used to try and select an appropriate
       
  3806 plugin encoder. If an appropriate encoder is found, it is created.
       
  3807 
       
  3808 If any file related errors are encountered opening the specified file, this
       
  3809 function leaves with an appropriate file related leave code.
       
  3810 
       
  3811 @param  aFs
       
  3812         A reference to a file server session for the encoder to use.
       
  3813 @param  aDestinationFilename
       
  3814         The name of the file into which to put the encoded image.
       
  3815 @param  aMIMEType
       
  3816         The MIME type to use for the encoding.
       
  3817 @param  aOptions
       
  3818         The encoder options to use.
       
  3819 
       
  3820 @return Returns a pointer to the newly created encoder.
       
  3821 
       
  3822 @see    TOptions
       
  3823 */
       
  3824 EXPORT_C CImageEncoder* CImageEncoder::FileNewL(RFs& aFs, const TDesC& aDestinationFilename, const TDesC8& aMIMEType, const TOptions aOptions)
       
  3825 	{
       
  3826 	//Get a sorted list of encoders
       
  3827 	RImplInfoPtrArray encoderList;
       
  3828 	CleanupResetAndDestroyPushL(encoderList);
       
  3829 	CImageEncoder::MimeTypeGetEncoderListL(encoderList, aMIMEType, aOptions);
       
  3830 
       
  3831 	if(encoderList.Count() == 0)
       
  3832 		User::Leave(KErrNotFound);
       
  3833 
       
  3834 	//Use the highest rated encoder.
       
  3835 	CImageEncodeConstruct* construct = NewEncodeConstructL(*encoderList[0], aOptions);
       
  3836 	CleanupStack::PopAndDestroy(&encoderList);
       
  3837 
       
  3838 	CImageEncoder* encoderPtr = NewL(construct, aOptions); // NewL takes ownership of construct - no need to push on stack
       
  3839 	CleanupStack::PushL(encoderPtr);
       
  3840 	encoderPtr->iRelay->SetFileL(aFs, aDestinationFilename, aOptions);
       
  3841 	CleanupStack::Pop(encoderPtr); 
       
  3842 
       
  3843 	return encoderPtr;
       
  3844 	}
       
  3845 
       
  3846 /**
       
  3847 Creates a plugin encoder for a specified MIME type and writes output to a descriptor.
       
  3848 
       
  3849 The client supplies a MIME type which will be used to try and select an appropriate
       
  3850 plugin encoder. If an appropriate encoder is found, it creates it.
       
  3851 
       
  3852 @param  aDestinationData
       
  3853         The buffer pointer into which to put the encoded image. This must be
       
  3854         a NULL pointer. Memory will be allocated internally and ownership of
       
  3855         the data passed to the caller.
       
  3856 @param  aMIMEType
       
  3857         The MIME type to use for the encoding.
       
  3858 @param  aOptions
       
  3859         Encoder options to use.
       
  3860 
       
  3861 @return	A pointer to the newly created encoder.
       
  3862 
       
  3863 @see    TOptions
       
  3864 */
       
  3865 EXPORT_C CImageEncoder* CImageEncoder::DataNewL(HBufC8*&  aDestinationData, const TDesC8& aMIMEType, const TOptions aOptions)
       
  3866 	{
       
  3867 	if (aDestinationData!=NULL)
       
  3868 		Panic(ENonNullDescriptorPassed);
       
  3869 
       
  3870 	//Get a sorted list of encoders
       
  3871 	RImplInfoPtrArray encoderList;
       
  3872 	CleanupResetAndDestroyPushL(encoderList);
       
  3873 	CImageEncoder::MimeTypeGetEncoderListL(encoderList, aMIMEType, aOptions);
       
  3874 
       
  3875 	if(encoderList.Count() == 0)
       
  3876 		User::Leave(KErrNotFound);
       
  3877 
       
  3878 	//Use the highest rated encoder.
       
  3879 	CImageEncodeConstruct* construct = NewEncodeConstructL(*encoderList[0], aOptions);
       
  3880 	CleanupStack::PopAndDestroy(&encoderList);
       
  3881 	CImageEncoder* encoderPtr = NewL(construct, aOptions); // NewL takes ownership of construct - no need to push on stack
       
  3882 	CleanupStack::PushL(encoderPtr);
       
  3883 	encoderPtr->iRelay->SetDataL(aDestinationData, aOptions);
       
  3884 	CleanupStack::Pop(encoderPtr); 
       
  3885 	return encoderPtr;
       
  3886 	}
       
  3887 
       
  3888 /**
       
  3889 @internalTechnology
       
  3890 
       
  3891 Creates a list of encoders that support the specified MIME type.
       
  3892 
       
  3893 @param  aEncoderList
       
  3894         Create a list of encoders that support the given MIME type.
       
  3895 @param	aMIMEType
       
  3896         The MIME type to encode to.
       
  3897 @param	aOptions
       
  3898 		Decoder options to use.
       
  3899 */
       
  3900 void CImageEncoder::MimeTypeGetEncoderListL(RImplInfoPtrArray& aEncoderList, const TDesC8& aMIMEType, const TOptions aOptions)
       
  3901 	{
       
  3902 	if (aMIMEType.Length() == 0)
       
  3903 		{ // Get out, empty MIME type string
       
  3904 		User::Leave(KErrArgument);
       
  3905 		}
       
  3906 
       
  3907 	CCustomMatchData* customMatchData = CCustomMatchData::NewLC();
       
  3908 	customMatchData->SetMatchType(EMatchMIMEType);
       
  3909 	customMatchData->SetMatchStringL(aMIMEType);
       
  3910 	customMatchData->SetExtensionOptions(aOptions);
       
  3911 
       
  3912 	HBufC8* package  = customMatchData->NewPackLC();
       
  3913 	TPtr8 packageDes = package->Des();
       
  3914 
       
  3915 	TEComResolverParams resolverParams; // Parameters on which to match
       
  3916 	resolverParams.SetDataType(packageDes);
       
  3917 
       
  3918 	REComSession::ListImplementationsL(KImageEncoderInterfaceUid, resolverParams, KImageConvertResolverUid, aEncoderList);
       
  3919 
       
  3920 	CleanupStack::PopAndDestroy(2); // package, customMatchData
       
  3921 	}
       
  3922 
       
  3923 /**
       
  3924 @internalTechnology
       
  3925 
       
  3926 Create a list of encoders that support the specified image type.
       
  3927 
       
  3928 @param  aEncoderList
       
  3929         A list of encoders that support the specified image type.
       
  3930 @param  aImageType
       
  3931         The image base type.
       
  3932 @param  aImageSubType
       
  3933         The image sub type.
       
  3934 @param  aEncoderUid
       
  3935         The implementation UID for a specific codec or a decoder/encoder class UID.
       
  3936 @param	aOptions
       
  3937 		Encoder options to use.
       
  3938 
       
  3939 @see	KUidICLJpegEXIFInterface
       
  3940 @see	KUidICLJpegImageFrameInterface
       
  3941 */
       
  3942 void CImageEncoder::ImageTypeGetEncoderListL(RImplInfoPtrArray& aEncoderList, const TUid aImageType, const TUid aImageSubType, const TUid aEncoderUid, const TOptions aOptions)
       
  3943 	{
       
  3944 	if ((aImageType == KNullUid) && (aEncoderUid == KNullUid))
       
  3945 		{ // Get out, no base type specified
       
  3946 		Panic(EIllegalImageType); 
       
  3947 		}
       
  3948 
       
  3949 	if ((aImageType == KNullUid) && (aImageSubType != KNullUid))
       
  3950 		{ // Get out, no base type given for sub-type
       
  3951 		Panic(EIllegalImageSubType); 
       
  3952 		}
       
  3953 
       
  3954 	CCustomMatchData* customMatchData = CCustomMatchData::NewLC();
       
  3955 	customMatchData->SetMatchType(EMatchUids);
       
  3956 	customMatchData->SetBaseType(aImageType);
       
  3957 	customMatchData->SetSubType(aImageSubType);
       
  3958 	customMatchData->SetImplementationType(aEncoderUid);
       
  3959 	customMatchData->SetExtensionOptions(aOptions);
       
  3960 
       
  3961 	HBufC8* package  = customMatchData->NewPackLC();
       
  3962 	TPtr8 packageDes = package->Des();
       
  3963 	
       
  3964 	TEComResolverParams resolverParams; // Parameters on which to match
       
  3965 	resolverParams.SetDataType(packageDes);
       
  3966    
       
  3967 	REComSession::ListImplementationsL(KImageEncoderInterfaceUid, resolverParams, KImageConvertResolverUid, aEncoderList);
       
  3968 
       
  3969 	CleanupStack::PopAndDestroy(2); // package, customMatchData
       
  3970    	}
       
  3971 
       
  3972 /**
       
  3973 @internalTechnology
       
  3974 
       
  3975 Create an encode construct using a image type, sub type and encoder
       
  3976 implementation UID.
       
  3977 
       
  3978 @param  aEncoderInfo
       
  3979         Implementation information for the encoder to be created.
       
  3980 @param	aOptions
       
  3981 		Encoder options to use.
       
  3982 @return Returns a pointer to the newly created encoder construct.
       
  3983 
       
  3984 */
       
  3985 CImageEncodeConstruct* CImageEncoder::NewEncodeConstructL(const CImplementationInformation& aEncoderInfo, const TOptions aOptions)
       
  3986 	{
       
  3987 	CCustomMatchData* customMatchData = CCustomMatchData::NewLC();
       
  3988 	COpaqueDataParse* parse = COpaqueDataParse::NewLC(aEncoderInfo.OpaqueData());
       
  3989 
       
  3990 	customMatchData->SetMatchType(EMatchUids);
       
  3991 	customMatchData->SetBaseType(parse->ImageTypeUid());
       
  3992 	customMatchData->SetSubType(parse->ImageSubTypeUid());
       
  3993 	customMatchData->SetImplementationType(aEncoderInfo.ImplementationUid());
       
  3994 	customMatchData->SetExtensionOptions(aOptions);
       
  3995 
       
  3996 	CleanupStack::PopAndDestroy(parse);
       
  3997 
       
  3998 	HBufC8* package = customMatchData->NewPackLC();
       
  3999 	TPtr8 packageDes = package->Des();
       
  4000 
       
  4001 	TEComResolverParams resolverParams;
       
  4002 	resolverParams.SetDataType(packageDes);
       
  4003 
       
  4004 	CImageEncodeConstruct* construct = NULL;
       
  4005 	construct = STATIC_CAST(CImageEncodeConstruct*,
       
  4006 			REComSession::CreateImplementationL(KImageEncoderInterfaceUid,
       
  4007 			_FOFF(CImageEncodeConstruct, iDtorIDKey),
       
  4008 			resolverParams,
       
  4009 			KImageConvertResolverUid));
       
  4010 	ASSERT(construct!=NULL);
       
  4011 
       
  4012 	CleanupStack::PopAndDestroy(2, customMatchData); //package, customMatchData
       
  4013 
       
  4014 	return construct;
       
  4015 	}
       
  4016 
       
  4017 /**
       
  4018 Creates an encoder based on a supplied parameters and writes output to a named file.
       
  4019 
       
  4020 The client must supply a basic image type (and a sub-type, if applicable) or a specific
       
  4021 encoder implementation UID, which will be used to try and select an appropriate plugin
       
  4022 encoder. If an appropriate encoder is found, it is created.
       
  4023 
       
  4024 Note:
       
  4025 Every image format has two IDs, known as the type and the sub-type (although generally
       
  4026 the sub-type is KNullUid). To retrieve a list of supported types and sub-types that can be
       
  4027 encoded, use the static functions GetImageTypesL() and GetImageSubTypesL().
       
  4028 
       
  4029 If no plugin encoder can be found that matches the details provided in aImageType, aImageSubType
       
  4030 and possibly aEncoderUid this function leaves with KErrNotFound or KEComErrNoInterfaceIdentified.
       
  4031 
       
  4032 If any file related errors are encountered opening the specified file, this function leaves
       
  4033 with an appropriate file related leave code.
       
  4034 
       
  4035 @param  aFs
       
  4036         A reference to a file server session for the encoder to use.
       
  4037 @param  aDestinationFilename
       
  4038         The name of the file into which to put the encoded image.
       
  4039 @param  aOptions
       
  4040         Options to use.
       
  4041 @param  aImageType
       
  4042         The image type to use for the encoding (mandatory).
       
  4043 @param  aImageSubType
       
  4044         The image sub-type to use for the encoding (only if applicable, defaults to KNullUid).
       
  4045 @param  aEncoderUid
       
  4046 		The implementation UID for a specific codec or a decoder/encoder class UID (optional, defaults to KNullUid).
       
  4047 		If this option is selected for a specific codec the image type and image sub type for the displayer must be supplied.
       
  4048 		When loading plugins by class UID the image type and image subtype are not mandatory and the first valid plugin from 
       
  4049 		the list of available plugins with the specified class UID will be loaded.
       
  4050 @see	KUidICLJpegEXIFInterface
       
  4051 @see	KUidICLJpegImageFrameInterface
       
  4052 
       
  4053 @return A pointer to the newly created encoder.
       
  4054 
       
  4055 @leave  KErrNotFound
       
  4056         No appropriate plugin encoder for this image has been found.
       
  4057 @leave  KEComErrNoInterfaceIdentified
       
  4058 		ECom could not find the specified interface.		
       
  4059 
       
  4060 @panic  ImageConversion 19
       
  4061         No base type given for sub-type.
       
  4062 @panic  ImageConversion 20
       
  4063         No base type given for encoder implementation.
       
  4064 
       
  4065 @see    TOptions
       
  4066 */
       
  4067 EXPORT_C CImageEncoder* CImageEncoder::FileNewL(RFs& aFs, const TDesC& aDestinationFilename, const TOptions aOptions, const TUid aImageType, const TUid aImageSubType, const TUid aEncoderUid)
       
  4068 	{
       
  4069 	//Get a sorted list of encoders
       
  4070 	RImplInfoPtrArray encoderList;
       
  4071 	CleanupResetAndDestroyPushL(encoderList);
       
  4072 	CImageEncoder::ImageTypeGetEncoderListL(encoderList, aImageType, aImageSubType, aEncoderUid, aOptions);
       
  4073 
       
  4074 	if(encoderList.Count() == 0)
       
  4075 		User::Leave(KErrNotFound);
       
  4076 
       
  4077 	//Use the highest rated encoder.
       
  4078 	CImageEncodeConstruct* construct = NewEncodeConstructL(*encoderList[0], aOptions);
       
  4079 	CleanupStack::PopAndDestroy(&encoderList);
       
  4080 	CImageEncoder* encoderPtr = NewL(construct, aOptions); // NewL takes ownership of construct - no need to push on cleanstack
       
  4081 	CleanupStack::PushL(encoderPtr);
       
  4082 	encoderPtr->iRelay->SetFileL(aFs, aDestinationFilename, aOptions);
       
  4083 	CleanupStack::Pop(); //encoderPtr
       
  4084 	return encoderPtr;
       
  4085 	}
       
  4086 
       
  4087 /**
       
  4088 Creates a plugin encoder based on optional parameters and writes output to a descriptor.
       
  4089 
       
  4090 The client must supply a basic image type (and a sub-type, if applicable) or specific encoder/class,
       
  4091 implementation UID which will be used to try and select an appropriate plugin
       
  4092 encoder. If an appropriate encoder is found, it is created.
       
  4093 
       
  4094 Note: 
       
  4095 Every image format has two IDs, known as the type and the sub-type (although generally the sub-type 
       
  4096 is KNullUid). To retrieve a list of supported types and sub-types that can be encoded, use the 
       
  4097 static functions GetImageTypesL() and GetImageSubTypesL().
       
  4098 
       
  4099 If no plugin encoder can be found that matches the details provided in aImageType, aImageSubType
       
  4100 and possibly aEncoderUid this function leaves with KErrNotFound or KEComErrNoInterfaceIdentified.
       
  4101 
       
  4102 @param  aDestinationData
       
  4103         The buffer pointer into which to put the encoded image.
       
  4104 @param  aOptions
       
  4105         The encoder options to use.
       
  4106 @param  aImageType
       
  4107         The image type to use for the encoding (mandatory).
       
  4108 @param  aImageSubType
       
  4109         The image sub-type to use for the encoding (only if applicable, defaults to KNullUid).
       
  4110 @param  aEncoderUid
       
  4111 		The implementation UID for a specific codec or a decoder/encoder class UID (optional, defaults to KNullUid).
       
  4112 		If this option is selected for a specific codec the image type and image sub type for the displayer must be supplied.
       
  4113 		When loading plugins by class UID the image type and image subtype are not mandatory and the first valid plugin from 
       
  4114 		the list of available plugins with the specified class UID will be loaded.
       
  4115 @see	KUidICLJpegEXIFInterface
       
  4116 @see	KUidICLJpegImageFrameInterface
       
  4117 
       
  4118 @return A pointer to the newly created encoder.
       
  4119 
       
  4120 @leave  KErrNotFound
       
  4121         No appropriate plugin encoder for this image has been found.
       
  4122 @leave  KEComErrNoInterfaceIdentified
       
  4123 		ECom could not find the specified interface.		
       
  4124 
       
  4125 @panic  ImageConversion 19
       
  4126         No base type given for sub-type.
       
  4127 @panic  ImageConversion 20
       
  4128         No base type given for encoder implementation.
       
  4129 
       
  4130 @see    TOptions
       
  4131 */
       
  4132 EXPORT_C CImageEncoder* CImageEncoder::DataNewL(HBufC8*& aDestinationData, const TOptions aOptions, const TUid aImageType, const TUid aImageSubType, const TUid aEncoderUid)
       
  4133 	{
       
  4134 	if (aDestinationData!=NULL)
       
  4135 		Panic(ENonNullDescriptorPassed);
       
  4136 
       
  4137 	//Get a sorted list of encoders
       
  4138 	RImplInfoPtrArray encoderList;
       
  4139 	CleanupResetAndDestroyPushL(encoderList);
       
  4140 	CImageEncoder::ImageTypeGetEncoderListL(encoderList, aImageType, aImageSubType, aEncoderUid, aOptions);
       
  4141 
       
  4142 	if(encoderList.Count() == 0)
       
  4143 		User::Leave(KErrNotFound);
       
  4144 
       
  4145 	//Use the highest rated encoder.
       
  4146 	CImageEncodeConstruct* construct = NewEncodeConstructL(*encoderList[0], aOptions);
       
  4147 	CleanupStack::PopAndDestroy(&encoderList);
       
  4148 	CImageEncoder* encoderPtr = NewL(construct, aOptions); // NewL takes ownership of construct - no need to push on cleanstack
       
  4149 	CleanupStack::PushL(encoderPtr);
       
  4150 	encoderPtr->iRelay->SetDataL(aDestinationData, aOptions);
       
  4151 	CleanupStack::Pop(); //encoderPtr
       
  4152 	return encoderPtr;
       
  4153 	}
       
  4154 
       
  4155 /**
       
  4156 @internalTechnology
       
  4157 
       
  4158 Called internally to create a CImageEncoder and associated iRelay body
       
  4159 */
       
  4160 CImageEncoder* CImageEncoder::NewL(CImageEncodeConstruct* aConstruct, TOptions aOptions)
       
  4161 	{
       
  4162 	CleanupStack::PushL(aConstruct); // we take ownership of aConstruct
       
  4163 	CImageEncoder* self = aConstruct->NewEncoderL(); // typically will callback to CImageEncoder::NewL()
       
  4164 	CleanupStack::PushL(self);
       
  4165 	TBool alwaysThread = (aOptions & EOptionAlwaysThread)!=EFalse;
       
  4166 	self->iRelay = MImageEncoderRelay::NewL(aConstruct, alwaysThread); // ownership of aConstruct switches to properties
       
  4167 	CleanupStack::Pop(2); // self  and aConstruct
       
  4168 	self->iRelay->TransferConstructOwnership();
       
  4169 	return self;
       
  4170 	}
       
  4171 
       
  4172 /**
       
  4173 @internalTechnology
       
  4174 
       
  4175 Actual factory function for CImageEncoder - ie. it creates the object
       
  4176 Called back plugin - to allow plugin to override if required
       
  4177 */
       
  4178 CImageEncoder* CImageEncoder::NewL()
       
  4179 	{
       
  4180 	CImageEncoder* self = new (ELeave) CImageEncoder;
       
  4181 	return self;
       
  4182 	}
       
  4183 
       
  4184 /**
       
  4185 Constructor for this class.
       
  4186 */
       
  4187 EXPORT_C CImageEncoder::CImageEncoder()
       
  4188 	{
       
  4189 	}
       
  4190 
       
  4191 /**
       
  4192 Destructor for this class.
       
  4193 
       
  4194 Closes the file. If using a local file session, it closes it.
       
  4195 Calls ECom to tell it the encoder instance is no longer required.
       
  4196 
       
  4197 Frees all other resources owned by the object prior to its destruction.
       
  4198 */
       
  4199 EXPORT_C CImageEncoder::~CImageEncoder()
       
  4200 	{
       
  4201 	Cancel();
       
  4202 
       
  4203 	delete iRelay;
       
  4204 	}
       
  4205 
       
  4206 /**
       
  4207 Encodes a bitmap asynchronously.
       
  4208 
       
  4209 When encoding is complete, successfully or otherwise, the
       
  4210 status is returned in aRequestStatus.
       
  4211 
       
  4212 @param  aRequestStatus
       
  4213         The request status. On completion contains an error code.
       
  4214         KErrNone if the bitmap was successfully encoded,
       
  4215         otherwise another of the system-wide error codes.
       
  4216 @param  aSource
       
  4217         A bitmap to encode.
       
  4218 @param  aFrameImageData
       
  4219         The frame image data (optional, defaults to NULL).
       
  4220 		There exists format-specific image data variants that are used by 
       
  4221 		encoders to obtain image specific data. This behaviour is invoked by specifying 
       
  4222 		aFrameImageData. Otherwise, encoder specific defaults are invoked.
       
  4223 @see TBmpImageData
       
  4224 */
       
  4225 EXPORT_C void CImageEncoder::Convert(TRequestStatus* aRequestStatus, const CFbsBitmap& aSource, const CFrameImageData* aFrameImageData)
       
  4226 	{
       
  4227 	ASSERT(ValidProperties());
       
  4228 	iRelay->Convert(aRequestStatus, aSource, aFrameImageData);
       
  4229 	}
       
  4230 
       
  4231 /**
       
  4232 Asynchronously cancels any conversions currently in progress.
       
  4233 */
       
  4234 EXPORT_C void CImageEncoder::Cancel()
       
  4235 	{
       
  4236 	if(ValidProperties())
       
  4237 		iRelay->Cancel();
       
  4238 	}
       
  4239 
       
  4240 /**
       
  4241 Returns the implementation UID of the encoder being used to encode the bitmap.
       
  4242 
       
  4243 @return	The implementation UID of the encoder.
       
  4244 */
       
  4245 EXPORT_C TUid CImageEncoder::ImplementationUid() const
       
  4246 	{
       
  4247 	return iRelay->ImplementationUid();
       
  4248 	}
       
  4249 
       
  4250 /**
       
  4251 Calls CImageEncoderPlugin::HandleCustomSyncL() that executes user defined
       
  4252 plugin specific functions. Subsequent behaviour therefore depends on the 
       
  4253 CImageEncoderPlugin class.
       
  4254 
       
  4255 Note:
       
  4256 For use by plugin writers only.
       
  4257 
       
  4258 @param  aParam
       
  4259         Interpretation determined by plugin.
       
  4260 */
       
  4261 EXPORT_C void CImageEncoder::CustomSyncL(TInt aParam)
       
  4262 	{
       
  4263 	ASSERT(ValidProperties());
       
  4264 	iRelay->CustomSyncL(aParam);
       
  4265 	}
       
  4266 
       
  4267 /**
       
  4268 Sets up background convert cycle, bypassing Convert().
       
  4269 
       
  4270 Use this function to inititate CImageEncoderPlugin::InitCustomAsyncL(aParam),
       
  4271 which if successful will start background processing. Convert() uses the same
       
  4272 mechanism as CustomAsync(), and therefore cannot be used concurrently. Cancel() 
       
  4273 and other related functions still work as expected.
       
  4274 
       
  4275 Note:
       
  4276 For use by plugin writers only.
       
  4277 
       
  4278 @param  aRequestStatus
       
  4279         The request status. On completion contains an error code.
       
  4280         KErrNone if the bitmap was successfully encoded,
       
  4281         otherwise another of the system-wide error codes.
       
  4282 @param  aParam
       
  4283         Interpretation determined by plugin.
       
  4284 */
       
  4285 EXPORT_C void CImageEncoder::CustomAsync(TRequestStatus* aRequestStatus, TInt aParam)
       
  4286 	{
       
  4287 	ASSERT(ValidProperties());
       
  4288 	iRelay->CustomAsync(aRequestStatus, aParam);
       
  4289 	}
       
  4290 
       
  4291 /**
       
  4292 Returns the associated CImageEncoderPlugin.
       
  4293 
       
  4294 This is part of support for extended codecs, for use within classes derived from 
       
  4295 CImageEncoder. Allows the extended CImageEncoder object to talk to its 
       
  4296 CImageEncoderPlugin equivalent.
       
  4297 
       
  4298 Note:
       
  4299 For use by plugin writers only.
       
  4300 */
       
  4301 EXPORT_C CImageEncoderPlugin* CImageEncoder::Plugin() const
       
  4302 	{
       
  4303 	ASSERT(ValidProperties());
       
  4304 	return iRelay->Plugin();
       
  4305 	}
       
  4306 
       
  4307 /**
       
  4308 @internalTechnology
       
  4309 
       
  4310 Intended for future proofing - will pannic if called
       
  4311 
       
  4312 @panic  ImageConversion 30
       
  4313 */
       
  4314 EXPORT_C void CImageEncoder::ReservedVirtual1()
       
  4315 	{
       
  4316 	Panic(EReservedCall);
       
  4317 	}
       
  4318 
       
  4319 /**
       
  4320 @internalTechnology
       
  4321 
       
  4322 Intended for future proofing - will pannic if called
       
  4323 
       
  4324 @panic  ImageConversion 30
       
  4325 */
       
  4326 EXPORT_C void CImageEncoder::ReservedVirtual2()
       
  4327 	{
       
  4328 	Panic(EReservedCall);
       
  4329 	}
       
  4330 
       
  4331 /**
       
  4332 @internalTechnology
       
  4333 
       
  4334 Intended for future proofing - will pannic if called
       
  4335 
       
  4336 @panic  ImageConversion 30
       
  4337 */
       
  4338 EXPORT_C void CImageEncoder::ReservedVirtual3()
       
  4339 	{
       
  4340 	Panic(EReservedCall);
       
  4341 	}
       
  4342 
       
  4343 /**
       
  4344 @internalTechnology
       
  4345 
       
  4346 Intended for future proofing - will pannic if called
       
  4347 
       
  4348 @panic  ImageConversion 30
       
  4349 */
       
  4350 EXPORT_C void CImageEncoder::ReservedVirtual4()
       
  4351 	{
       
  4352 	Panic(EReservedCall);
       
  4353 	}
       
  4354 
       
  4355 /**
       
  4356 Create a decoder for the image in the named file. The client supplies a
       
  4357 MIME type which will be used to try and select an appropriate plugin
       
  4358 decoder. If it finds a decoder it creates it and then goes on to use that
       
  4359 decoder to scan the beginning of the image file.
       
  4360 
       
  4361 If any file related errors are encountered opening the specified file, this 
       
  4362 function leaves with an appropriate file related leave code.
       
  4363 
       
  4364 @param  aFile
       
  4365         The handle of the file to decode
       
  4366 @param  aMIMEType
       
  4367         The MIME type of the image in the file.
       
  4368 @param  aIntent
       
  4369 		The DRM Intent to open the file with
       
  4370 @param	aOptions
       
  4371         Decoder options to use.
       
  4372 
       
  4373 @return	Returns a pointer to the newly created decoder.
       
  4374 
       
  4375 @leave  KEComErrNoInterfaceIdentified
       
  4376         ECom could not find the specified interface.
       
  4377 @leave  KErrNotFound
       
  4378         Either the appropriate plugin decoder for this file hasn't been found, or the file itself is missing.
       
  4379 
       
  4380 @see    TOptions
       
  4381 */
       
  4382 EXPORT_C CImageDecoder* CImageDecoder::FileNewL(RFile& aFile, const TDesC8& aMIMEType, TIntent aIntent, const TOptions aOptions)
       
  4383 	{
       
  4384 	return CImageDecoder::FileNewImplL(aFile, aMIMEType, KDefaultContentObject, aIntent, aOptions);
       
  4385 	}
       
  4386 
       
  4387 /**
       
  4388 Creates a decoder for the image in the named file. If the client supplies an
       
  4389 image type (and sub-type, if applicable) or decoder UID, these will be used
       
  4390 to try and select an appropriate plugin decoder. If not, then the selection
       
  4391 will be done by matching the image header in the file. If it finds a decoder
       
  4392 it creates it and then goes on to use that decoder to scan the beginning of
       
  4393 the image file.
       
  4394 
       
  4395 @param  aFile
       
  4396         The handle of the file to decode
       
  4397 @param  aIntent
       
  4398         The DRM Intent for image conversion.
       
  4399 @param  aOptions
       
  4400         The decoder options to use. See TOptions.
       
  4401 @param  aImageType
       
  4402         The image type of the image in the file (optional, defaults to KNullUid).
       
  4403 @param  aImageSubType
       
  4404         The image sub-type of the image in the file (optional, defaults to KNullUid).
       
  4405 @param  aDecoderUid
       
  4406 		The implementation UID for a specific codec or a decoder/encoder class UID (optional, defaults to KNullUid).
       
  4407 		If this option is selected for a specific codec the image type and image sub type for the displayer must be supplied.
       
  4408 		When loading plugins by class UID the image type and image subtype are not mandatory and the first valid plugin from 
       
  4409 		the list of available plugins with the specified class UID will be loaded.
       
  4410 @see	KUidICLJpegEXIFInterface
       
  4411 @see	KUidICLJpegImageFrameInterface
       
  4412 
       
  4413 @return	A pointer to the newly created decoder.
       
  4414 
       
  4415 @leave  KErrUnderflow
       
  4416         Not enough data in file to identify which plugin decoder to use.
       
  4417 @leave  KErrNotFound
       
  4418         Either the appropriate plugin decoder for this file hasn't been found, or the file itself is missing.
       
  4419 @leave  KEComErrNoInterfaceIdentified
       
  4420 		ECom could not find the specified interface.		
       
  4421 
       
  4422 @panic  ImageConversion 19
       
  4423         No base type given for sub-type.
       
  4424 
       
  4425 @see     TOptions
       
  4426 */
       
  4427 
       
  4428 EXPORT_C CImageDecoder* CImageDecoder::FileNewL(RFile& aFile, TIntent aIntent, const TOptions aOptions, const TUid aImageType, const TUid aImageSubType, const TUid aDecoderUid)
       
  4429 	{
       
  4430 	return CImageDecoder::FileNewImplL(aFile, KDefaultContentObject, aIntent, aOptions, aImageType, aImageSubType, aDecoderUid);
       
  4431 	}
       
  4432 
       
  4433 CImageDecoder* CImageDecoder::FileNewImplL(RFile& aFile, const TDesC8& aMIMEType, const TDesC& aUniqueId, TIntent aIntent, const TOptions aOptions)
       
  4434 	{
       
  4435 	CContent* content = CContent::NewLC(aFile);
       
  4436 	CData* data = content->OpenContentL(aIntent, aUniqueId); // check file presence, evaluate (not execute) intent
       
  4437 
       
  4438 	delete data; // close file
       
  4439 	CleanupStack::PopAndDestroy(content);
       
  4440 
       
  4441 	//Get a sorted list of decoders that will decode the image
       
  4442 	RImplInfoPtrArray decoderList;
       
  4443 	CleanupResetAndDestroyPushL(decoderList);
       
  4444 	CImageDecoder::MimeTypeGetDecoderListL(decoderList, aMIMEType, aOptions);
       
  4445 
       
  4446 	CImageDecoder* decoder = NULL;
       
  4447 	decoder = CImageDecoder::FileFindDecoderNewL(decoderList, aFile, aOptions, aUniqueId);
       
  4448 
       
  4449 	ASSERT(decoder!=NULL);
       
  4450 	CleanupStack::PushL(decoder);
       
  4451 	decoder->iRelay->SetIntent(aIntent);
       
  4452 
       
  4453 	CleanupStack::Pop(decoder);
       
  4454 	CleanupStack::PopAndDestroy(&decoderList);
       
  4455 	return decoder;
       
  4456 	}
       
  4457 	
       
  4458 CImageDecoder* CImageDecoder::FileNewImplL(RFile& aFile, const TDesC& aUniqueId, const TIntent aIntent, const TOptions aOptions, const TUid aImageType, const TUid aImageSubType, const TUid aDecoderUid)
       
  4459 	{
       
  4460 	if ((aImageType == KNullUid) && (aImageSubType != KNullUid))
       
  4461 		{ // Get out, no base type given for sub-type
       
  4462 		Panic(EIllegalImageSubType); 
       
  4463 		}
       
  4464 
       
  4465 	RImplInfoPtrArray decoderList;
       
  4466 	CleanupResetAndDestroyPushL(decoderList);
       
  4467 
       
  4468 	CContent* content = CContent::NewLC(aFile);
       
  4469 	CData* data = content->OpenContentL(aIntent, aUniqueId);
       
  4470 	CleanupStack::PushL(data);
       
  4471 
       
  4472 	if (aImageType == KNullUid && aDecoderUid == KNullUid)
       
  4473 		{ 
       
  4474 		TBuf8<KMaxMimeLength> mimeType;
       
  4475 		if (data->GetMimeTypeL(mimeType))
       
  4476 			{
       
  4477 			// try to find a controller based on MIME type
       
  4478 			CImageDecoder::MimeTypeGetDecoderListL(decoderList, mimeType, aOptions);
       
  4479 			}
       
  4480 		if (decoderList.Count()==0)
       
  4481 			{
       
  4482 			// read header data
       
  4483 			TBuf8<KImageHeaderSize> imageHeader;
       
  4484 			User::LeaveIfError(data->Read(imageHeader, KImageHeaderSize));
       
  4485 			CImageDecoder::ImageTypeGetDecoderListL(decoderList, imageHeader, aImageType, aImageSubType, aDecoderUid, aOptions);
       
  4486 			}
       
  4487 		}
       
  4488 	else
       
  4489 		{
       
  4490 		TBuf8<KImageHeaderSize> imageHeader;
       
  4491 		User::LeaveIfError(data->Read(imageHeader, KImageHeaderSize));
       
  4492 		CImageDecoder::ImageTypeGetDecoderListL(decoderList, imageHeader, aImageType, aImageSubType, aDecoderUid, aOptions);
       
  4493 		}
       
  4494 	
       
  4495 	CleanupStack::PopAndDestroy(2, content); // content, data
       
  4496 
       
  4497 	//Try to match by file extension only
       
  4498 	//1) If no plugin was found and 
       
  4499 	//2) No specific decoder or format was specified
       
  4500 	TBuf<256> filename;
       
  4501 	aFile.Name(filename);
       
  4502 	const TBool formatSpecified = (aImageType!=KNullUid || aImageSubType!=KNullUid || aDecoderUid!=KNullUid);
       
  4503 	if(decoderList.Count()==0 && !formatSpecified)
       
  4504 		{
       
  4505 		CImageDecoder::SuffixTypeGetDecoderListL(decoderList, filename, aOptions);
       
  4506 		}
       
  4507 
       
  4508 	CImageDecoder* decoder = NULL;
       
  4509 	decoder = CImageDecoder::FileFindDecoderNewL(decoderList, aFile, aOptions, aUniqueId);
       
  4510 	ASSERT(decoder!=NULL);
       
  4511 	CleanupStack::PushL(decoder);
       
  4512 	decoder->iRelay->SetIntent(aIntent);
       
  4513 
       
  4514 	CleanupStack::Pop(decoder);
       
  4515 	CleanupStack::PopAndDestroy(&decoderList);
       
  4516 	return decoder;
       
  4517 	}
       
  4518 	
       
  4519 /**
       
  4520 @internalTechnology
       
  4521 
       
  4522 Scans a sorted list of decoders for the first one that can decode the image.
       
  4523 
       
  4524 @param  aDecoderList
       
  4525         A list of decoders that support the image format.
       
  4526 @param  aFile
       
  4527         A file server session for the decoder to use.
       
  4528 @param  aOptions
       
  4529         The options to use during decoding.
       
  4530 @param  aUniqueId
       
  4531         Identifier of file within a multi-part archive.
       
  4532 
       
  4533 @return A pointer to the decoder.
       
  4534 */
       
  4535 CImageDecoder* CImageDecoder::FileFindDecoderNewL(const RImplInfoPtrArray& aDecoderList, RFile& aFile, const TOptions aOptions, const TDesC& aUniqueId)
       
  4536 	{
       
  4537 	TInt noOfDecoders = aDecoderList.Count();
       
  4538 
       
  4539 	if(noOfDecoders == 0)
       
  4540 		User::Leave(KErrNotFound);
       
  4541 
       
  4542 	CImageDecoder* decoder = NULL;
       
  4543 	TInt decoderNo = 0;
       
  4544 	TInt error = KErrNone;
       
  4545 	do
       
  4546 		{
       
  4547 		const CImplementationInformation& decoderInfo = *(aDecoderList[decoderNo++]);
       
  4548 		TRAP(error,decoder=FileDecoderNewL(decoderInfo, aFile, aOptions, aUniqueId));
       
  4549 		if (error != KErrCorrupt && error != KErrNotSupported && error != KErrNotFound)
       
  4550 			break;
       
  4551 		}
       
  4552 	while(decoderNo < noOfDecoders);
       
  4553 
       
  4554 	if(error!=KErrNone)
       
  4555 		{
       
  4556 		ASSERT(decoder==NULL);
       
  4557 		if (error == KErrCorrupt || error == KErrNotSupported)
       
  4558 			error = KErrNotFound;
       
  4559 		User::Leave(error);
       
  4560 		}
       
  4561 
       
  4562 	return decoder;
       
  4563 	}
       
  4564 	
       
  4565 /**
       
  4566 @internalTechnology
       
  4567 
       
  4568 Create a construct that can create a decoder and call
       
  4569 functions to initialise the decoder with the image data.
       
  4570 
       
  4571 @param  aDecoderInfo
       
  4572         Implementation information for the decoder to be created.
       
  4573 @param  aFile
       
  4574         A file server session for the decoder to use.
       
  4575 @param  aOptions
       
  4576         Options the decoder must use.
       
  4577 @param  aUniqueId
       
  4578         Identifier of file within a multi-part archive.
       
  4579 
       
  4580 @return	A pointer to the decoder.
       
  4581 */
       
  4582 CImageDecoder* CImageDecoder::FileDecoderNewL(const CImplementationInformation& aDecoderInfo, RFile& aFile, const TOptions aOptions, const TDesC& aUniqueId)
       
  4583 	{
       
  4584 	CImageDecodeConstruct* construct = NULL;
       
  4585 	construct = NewDecodeConstructL(aDecoderInfo, aOptions);
       
  4586 	ASSERT(construct!= NULL);
       
  4587 
       
  4588 	CImageDecoder* decoder = NewL(construct, aOptions); // note NewL takes ownership of construct - don't push on stack
       
  4589 	ASSERT(decoder!=NULL);
       
  4590 	CleanupStack::PushL(decoder);
       
  4591 
       
  4592 	decoder->iRelay->SetUniqueIdL(aUniqueId);
       
  4593 
       
  4594 	decoder->iRelay->SetFileL(aFile, aOptions);
       
  4595 	decoder->iRelay->HandleNewlyOpenedImageL();
       
  4596 
       
  4597 	CleanupStack::Pop(decoder);
       
  4598 	return decoder;
       
  4599 	}
       
  4600 
       
  4601 
       
  4602 /**
       
  4603 Creates an encoder based on a specified MIME type and write output to a named file.
       
  4604 
       
  4605 The client supplies a MIME type which will be used to try and select an appropriate
       
  4606 plugin encoder. If an appropriate encoder is found, it is created.
       
  4607 
       
  4608 If any file related errors are encountered opening the specified file, this
       
  4609 function leaves with an appropriate file related leave code.
       
  4610 
       
  4611 @param  aFile
       
  4612         The handle of an open file to write the encoded image to
       
  4613 @param  aMIMEType
       
  4614         The MIME type to use for the encoding.
       
  4615 @param  aOptions
       
  4616         The encoder options to use.
       
  4617 
       
  4618 @return Returns a pointer to the newly created encoder.
       
  4619 
       
  4620 @leave  KEComErrNoInterfaceIdentified
       
  4621         ECom could not find the specified interface.
       
  4622 @leave  KErrNotFound
       
  4623         No appropriate plugin encoder for this image has been found.
       
  4624 
       
  4625 @see    TOptions
       
  4626 */
       
  4627 EXPORT_C CImageEncoder* CImageEncoder::FileNewL(RFile& aFile, const TDesC8& aMIMEType, const TOptions aOptions)
       
  4628 	{
       
  4629 	//Get a sorted list of encoders
       
  4630 	RImplInfoPtrArray encoderList;
       
  4631 	CleanupResetAndDestroyPushL(encoderList);
       
  4632 	CImageEncoder::MimeTypeGetEncoderListL(encoderList, aMIMEType, aOptions);
       
  4633 
       
  4634 	if(encoderList.Count() == 0)
       
  4635 		User::Leave(KErrNotFound);
       
  4636 
       
  4637 	//Use the highest rated encoder.
       
  4638 	CImageEncodeConstruct* construct = NewEncodeConstructL(*encoderList[0], aOptions);
       
  4639 	CleanupStack::PopAndDestroy(&encoderList);
       
  4640 
       
  4641 	CImageEncoder* encoderPtr = NewL(construct, aOptions); // NewL takes ownership of construct - no need to push on stack
       
  4642 	CleanupStack::PushL(encoderPtr);
       
  4643 	encoderPtr->iRelay->SetFileL(aFile, aOptions);
       
  4644 	CleanupStack::Pop(encoderPtr); 
       
  4645 	return encoderPtr;
       
  4646 	}
       
  4647 	
       
  4648 /**
       
  4649 Creates an encoder based on a supplied parameters and writes output to a named file.
       
  4650 
       
  4651 The client must supply a basic image type (and a sub-type, if applicable) or a specific
       
  4652 encoder/class implementation UID, which will be used to try and select an appropriate plugin
       
  4653 encoder. If an appropriate encoder is found, it is created.
       
  4654 
       
  4655 Note:
       
  4656 Every image format has two IDs, known as the type and the sub-type (although generally
       
  4657 the sub-type is KNullUid). To retrieve a list of supported types and sub-types that can be
       
  4658 encoded, use the static functions GetImageTypesL() and GetImageSubTypesL().
       
  4659 
       
  4660 If no plugin encoder can be found that matches the details provided in aImageType, aImageSubType
       
  4661 and possibly aEncoderUid this function leaves with KErrNotFound or KEComErrNoInterfaceIdentified.
       
  4662 
       
  4663 If any file related errors are encountered opening the specified file, this function leaves
       
  4664 with an appropriate file related leave code.
       
  4665 
       
  4666 @param  aFile
       
  4667         The handle of an open file to write the encoded image to
       
  4668 @param  aOptions
       
  4669         Options to use.
       
  4670 @param  aImageType
       
  4671         The image type to use for the encoding (mandatory).
       
  4672 @param  aImageSubType
       
  4673         The image sub-type to use for the encoding (only if applicable, defaults to KNullUid).
       
  4674 @param  aEncoderUid
       
  4675 		The implementation UID for a specific codec or a decoder/encoder class UID (optional, defaults to KNullUid).
       
  4676 		If this option is selected for a specific codec the image type and image sub type for the displayer must be supplied.
       
  4677 		When loading plugins by class UID the image type and image subtype are not mandatory and the first valid plugin from 
       
  4678 		the list of available plugins with the specified class UID will be loaded.
       
  4679 @see	KUidICLJpegEXIFInterface
       
  4680 @see	KUidICLJpegImageFrameInterface
       
  4681 
       
  4682 @return A pointer to the newly created encoder.
       
  4683 
       
  4684 @leave  KErrNotFound
       
  4685         No appropriate plugin encoder for this image has been found.
       
  4686 @leave  KEComErrNoInterfaceIdentified
       
  4687 		ECom could not find the specified interface.		
       
  4688 
       
  4689 @panic  ImageConversion 19
       
  4690         No base type given for sub-type.
       
  4691 @panic  ImageConversion 20
       
  4692         No base type given for encoder implementation.
       
  4693 
       
  4694 @see    TOptions
       
  4695 */
       
  4696 EXPORT_C CImageEncoder* CImageEncoder::FileNewL(RFile& aFile, const TOptions aOptions, const TUid aImageType, const TUid aImageSubType, const TUid aEncoderUid)
       
  4697 	{
       
  4698 	//Get a sorted list of encoders
       
  4699 	RImplInfoPtrArray encoderList;
       
  4700 	CleanupResetAndDestroyPushL(encoderList);
       
  4701 	CImageEncoder::ImageTypeGetEncoderListL(encoderList, aImageType, aImageSubType, aEncoderUid, aOptions);
       
  4702 
       
  4703 	if(encoderList.Count() == 0)
       
  4704 		User::Leave(KErrNotFound);
       
  4705 
       
  4706 	//Use the highest rated encoder.
       
  4707 	CImageEncodeConstruct* construct = NewEncodeConstructL(*encoderList[0], aOptions);
       
  4708 	CleanupStack::PopAndDestroy(&encoderList);
       
  4709 	CImageEncoder* encoderPtr = NewL(construct, aOptions); // NewL takes ownership of construct - no need to push on cleanstack
       
  4710 	CleanupStack::PushL(encoderPtr);
       
  4711 	encoderPtr->iRelay->SetFileL(aFile, aOptions);
       
  4712 	CleanupStack::Pop(); //encoderPtr
       
  4713 	return encoderPtr;
       
  4714 	}
       
  4715 
       
  4716 	
       
  4717 /**
       
  4718 Select to encode or not the thumbnail
       
  4719 
       
  4720 @param  aDoGenerateThumbnail
       
  4721 		EFalse if no generation of thumbnail
       
  4722 */
       
  4723 EXPORT_C void CImageEncoder::SetThumbnail(TBool aDoGenerateThumbnail)
       
  4724 	{
       
  4725 	ASSERT(ValidProperties());
       
  4726 	iRelay->SetThumbnail(aDoGenerateThumbnail);
       
  4727 	}
       
  4728 	
       
  4729 /**
       
  4730 Set the encoder worker thread priority
       
  4731 
       
  4732 @param  aPriority
       
  4733 		a new value for worker thread priority
       
  4734 @return KErrNotSupported 
       
  4735 		the encoder object doesn't use a worker thread.
       
  4736 		Other system-wide error codes.
       
  4737 @see	TThreadPriority
       
  4738 */
       
  4739 EXPORT_C TInt CImageEncoder::SetEncoderThreadPriority(TThreadPriority aPriority)
       
  4740 	{
       
  4741 	return iRelay->SetEncoderThreadPriority( aPriority );
       
  4742 	}
       
  4743 
       
  4744 /**
       
  4745 @publishedAll
       
  4746 @released
       
  4747 
       
  4748 Optional call from client which may be made on the encoder to allow analysis of image prior to calling
       
  4749 Convert.
       
  4750 
       
  4751 Should be called once encode is fully set up e.g. any encode operations defined.
       
  4752 
       
  4753 @param	aRequestStatus
       
  4754 		Request status. On completion this contains an error code. This is KErrNone if the frame
       
  4755 		was analyzed successfully, KErrNotSupported if the codec does not support analysis, or a
       
  4756 		system-wide error code.
       
  4757 
       
  4758 @see CImageEncoder::Convert
       
  4759 */
       
  4760 EXPORT_C void CImageEncoder::Prepare(TRequestStatus* aRequestStatus)
       
  4761 	{
       
  4762 	ASSERT(ValidProperties());
       
  4763 	ASSERT(aRequestStatus);
       
  4764 
       
  4765 	CImageConvExtensionCache* cache = &iRelay->ExtensionCache();
       
  4766 	TImageConvPrepare* prepare = cache->Prepare();
       
  4767 
       
  4768 	if(!prepare)
       
  4769 		{
       
  4770 		MImageConvExtension* prepareExtension = NULL;
       
  4771 		TRAPD(err,
       
  4772 			{
       
  4773 			iRelay->GetExtensionL(KICLPrepareUid, prepareExtension);
       
  4774 			prepare = new (ELeave) TImageConvPrepare();
       
  4775 			prepare->SetExtension(prepareExtension);
       
  4776 			cache->SetPrepareExtension(prepare);
       
  4777 			});
       
  4778 		if ( err != KErrNone )
       
  4779 			{
       
  4780 			User::RequestComplete(aRequestStatus, err);
       
  4781 			return;
       
  4782 			}
       
  4783 		}
       
  4784 	prepare->Prepare(aRequestStatus);
       
  4785 	}
       
  4786 
       
  4787 CContent* CImageDecoder::GetContentLC(const TDesC& aSourceFilename)
       
  4788 	{
       
  4789 	CContent* content = NULL;
       
  4790 	TRAPD(err,content = CContent::NewL(aSourceFilename, EContentShareReadOnly));
       
  4791 	if(err != KErrNone && err != KErrNoMemory)
       
  4792 		{
       
  4793 		content = CContent::NewL(aSourceFilename, EContentShareReadWrite);
       
  4794 		}
       
  4795 	User::LeaveIfNull(content);
       
  4796 	CleanupStack::PushL(content);
       
  4797 	return content;
       
  4798 	}
       
  4799 
       
  4800 /**
       
  4801 @publishedAll
       
  4802 @released
       
  4803 
       
  4804 
       
  4805 Get the extension interface for operations on the image.
       
  4806 @return Interface to image conversion operations.
       
  4807 @leave KErrNotSupported if loaded codec plugin does not support this optional extension.
       
  4808 @leave Other system wide errors
       
  4809 
       
  4810 @note The order of post processing operations when applied for decoding is
       
  4811 
       
  4812 - 1. Clip the image 
       
  4813 - 2. Scale the image 
       
  4814 - 3. Operate on the image 
       
  4815 
       
  4816 @see CImageDecoder::SetClippingRectL()
       
  4817 @see TImageConvScaler
       
  4818 @see TImageConvOperation
       
  4819 */
       
  4820 EXPORT_C TImageConvOperation* CImageDecoder::OperationL()
       
  4821 	{
       
  4822 	ASSERT(ValidProperties());
       
  4823 
       
  4824 	CImageConvExtensionCache* cache = &iRelay->ExtensionCache();
       
  4825 	TImageConvOperation* operation = cache->Operation();
       
  4826 
       
  4827 	if(!operation)
       
  4828 		{
       
  4829 		MImageConvExtension* operationExtension = NULL;
       
  4830 		iRelay->GetExtensionL(KICLOperationUid, operationExtension);
       
  4831 		operation = new (ELeave) TImageConvOperation();
       
  4832 		operation->SetExtension(operationExtension);
       
  4833 		cache->SetOperationExtension(operation);
       
  4834 		}
       
  4835 	return operation;
       
  4836 	}
       
  4837 
       
  4838 /**
       
  4839 @publishedAll
       
  4840 @released
       
  4841 
       
  4842 
       
  4843 Get the extension interface for scaling the image. @see TImageConvScaler
       
  4844 @return Interface to image conversion scaler.
       
  4845 @leave KErrNotSupported if loaded codec plugin does not support this optional extension.
       
  4846 @leave Other system wide errors.
       
  4847 
       
  4848 @see note under CImageDecoder::OperationL.
       
  4849 */
       
  4850 EXPORT_C TImageConvScaler* CImageDecoder::ScalerL()
       
  4851 	{
       
  4852 	ASSERT(ValidProperties());
       
  4853 
       
  4854 	CImageConvExtensionCache* cache = &iRelay->ExtensionCache();
       
  4855 	TImageConvScaler* scaler = cache->Scaler();
       
  4856 
       
  4857 	if(!scaler)
       
  4858 		{
       
  4859 		MImageConvExtension* scalerExtension = NULL;
       
  4860 		iRelay->GetExtensionL(KICLScalerUid, scalerExtension);
       
  4861 		scaler = new (ELeave) TImageConvScaler();
       
  4862 		scaler->SetExtension(scalerExtension);
       
  4863 		cache->SetScalerExtension(scaler);
       
  4864 		}
       
  4865 	return scaler;
       
  4866 	}
       
  4867 
       
  4868 /**
       
  4869 @publishedAll
       
  4870 @released
       
  4871 
       
  4872 
       
  4873 Get the extension interface for block streaming on the image. @see TImageConvStreamedDecode
       
  4874 @return Interface to image conversion block streamer.
       
  4875 @leave KErrNotSupported if loaded codec plugin does not support this optional extension.
       
  4876 @leave Other system wide errors.
       
  4877 */
       
  4878 EXPORT_C TImageConvStreamedDecode* CImageDecoder::BlockStreamerL()
       
  4879 	{
       
  4880 	ASSERT(ValidProperties());
       
  4881 
       
  4882 	CImageConvExtensionCache* cache = &iRelay->ExtensionCache();
       
  4883 	TImageConvStreamedDecode* streamer = cache->DecodeBlockStreamer();
       
  4884 
       
  4885 	if(!streamer)
       
  4886 		{
       
  4887 		MImageConvExtension* streamExtension = NULL;
       
  4888 		iRelay->GetExtensionL(KICLStreamedDecodeUid, streamExtension);
       
  4889 		streamer = new (ELeave) TImageConvStreamedDecode();
       
  4890 		streamer->SetExtension(streamExtension);
       
  4891 		cache->SetBlockStreamerExtension(streamer);
       
  4892 		}
       
  4893 	return streamer;
       
  4894 	}
       
  4895 
       
  4896 /**
       
  4897 @publishedAll
       
  4898 @released
       
  4899 
       
  4900 
       
  4901 Sets the area of interest of the image to be decoded.  This function can leave with
       
  4902 any of the system-wide error codes.
       
  4903 
       
  4904 @param aClipRect	A pointer to a TRect that specifies the
       
  4905 					location and size of the region to be decoded.  This
       
  4906 					rectangle must have positive width and height values as
       
  4907 					per TRect::IsNormalized() and TRect::Normalize().
       
  4908 					Passing in a NULL value will clear the clipping rectangle.
       
  4909 					Note that a clipping rectangle may not be valid for all frames of an image.
       
  4910 
       
  4911 @leave KErrNotSupported		This function is not supported.
       
  4912 @leave KErrArgument			Returned if the clipping rectangle:
       
  4913 							a) is empty (i.e. IsEmpty() returns ETrue)
       
  4914 							b) is not normalised (i.e. IsNormalized() returns EFalse)
       
  4915 							c) has coordinates that are not located within, or on,
       
  4916 							the coodinates of at least one frame of the original image.
       
  4917 							d) has a width or a height of 0
       
  4918 
       
  4919 @see	TRect::IsEmpty()
       
  4920 @see	TRect::IsNormalized()
       
  4921 @see	TRect::Normalize()
       
  4922 
       
  4923 @see note under CImageDecoder::OperationL
       
  4924 */
       
  4925 EXPORT_C void CImageDecoder::SetClippingRectL(const TRect* aClipRect)
       
  4926 	{
       
  4927 	ASSERT(ValidProperties());
       
  4928 	iRelay->SetClippingRectL(aClipRect);
       
  4929 	}
       
  4930 
       
  4931 /**
       
  4932 @publishedAll
       
  4933 @released
       
  4934 
       
  4935 
       
  4936 Optional call from client which may be made on the decoder to allow analysis of image prior to calling
       
  4937 Convert.
       
  4938 
       
  4939 Should be called once decode is fully set up e.g. clipping rectangle set.
       
  4940 
       
  4941 @param	aRequestStatus
       
  4942 		Request status. On completion this contains an error code. This is KErrNone if the frame
       
  4943 		was analyzed successfully, KErrNotSupported if the codec does not support analysis, or a
       
  4944 		system-wide error code.
       
  4945 
       
  4946 @see CImageDecoder::Convert
       
  4947 */
       
  4948 EXPORT_C void CImageDecoder::Prepare(TRequestStatus* aRequestStatus)
       
  4949 	{
       
  4950 	ASSERT(ValidProperties());
       
  4951 	ASSERT(aRequestStatus);
       
  4952 
       
  4953 	CImageConvExtensionCache* cache = &iRelay->ExtensionCache();
       
  4954 	TImageConvPrepare* prepare = cache->Prepare();
       
  4955 
       
  4956 	if(!prepare)
       
  4957 		{
       
  4958 		MImageConvExtension* prepareExtension = NULL;
       
  4959 		TRAPD(err,
       
  4960 			{
       
  4961 			iRelay->GetExtensionL(KICLPrepareUid, prepareExtension);
       
  4962 			prepare = new (ELeave) TImageConvPrepare();
       
  4963 			prepare->SetExtension(prepareExtension);
       
  4964 			cache->SetPrepareExtension(prepare);
       
  4965 			});
       
  4966 		if ( err != KErrNone )
       
  4967 			{
       
  4968 			User::RequestComplete(aRequestStatus, err);
       
  4969 			return;
       
  4970 			}
       
  4971 		}
       
  4972 	prepare->Prepare(aRequestStatus);
       
  4973 	}
       
  4974 
       
  4975 /**
       
  4976 @publishedAll
       
  4977 @released
       
  4978 
       
  4979 
       
  4980 Get the size of the decoded image for the given frame. The calculation will account for any clipping rectangle set,
       
  4981 scaling applied through the TImageConvScaler extension and any operation applied through TImageConvOperation.
       
  4982 If TImageConvScaler::SetScalingL(.. has been called then the size of the bitmap passed to CImageDecoder::Convert must match the size returned from
       
  4983 this function.
       
  4984 
       
  4985 @param aSize 
       
  4986 	   Returns the size of the decoded image.
       
  4987 @param aFrameNumber
       
  4988 	   The frame number.
       
  4989 	   
       
  4990 @return KErrArgument if an error in calculation is detected e.g. if clipping rectangle is outside of the overall frame boundary.
       
  4991 @return Other system wide errors.
       
  4992 */
       
  4993 EXPORT_C TInt CImageDecoder::GetDestinationSize(TSize& aSize, TInt aFrameNumber)
       
  4994 	{
       
  4995 	ASSERT(ValidProperties());
       
  4996 	return iRelay->GetDestinationSize(aSize, aFrameNumber);
       
  4997 	}
       
  4998 
       
  4999 /**
       
  5000 @publishedAll
       
  5001 @released
       
  5002 
       
  5003 
       
  5004 Get the extension interface for operations on image. @see TImageConvOperation
       
  5005 @return Interface to image conversion operations (rotate/mirror over axis).
       
  5006 @leave KErrNotSupported if loaded codec plugin does not support this optional extension.
       
  5007 @leave Other system wide errors
       
  5008 */
       
  5009 EXPORT_C TImageConvOperation* CImageEncoder::OperationL()
       
  5010 	{
       
  5011 	ASSERT(ValidProperties());
       
  5012 
       
  5013 	CImageConvExtensionCache* cache = &iRelay->ExtensionCache();
       
  5014 	TImageConvOperation* operation = cache->Operation();
       
  5015 
       
  5016 	if(!operation)
       
  5017 		{
       
  5018 		MImageConvExtension* operationExtension = NULL;
       
  5019 		iRelay->GetExtensionL(KICLOperationUid, operationExtension);
       
  5020 		operation = new (ELeave) TImageConvOperation();
       
  5021 		operation->SetExtension(operationExtension);
       
  5022 		cache->SetOperationExtension(operation);
       
  5023 		}
       
  5024 	return operation;
       
  5025 	}
       
  5026 
       
  5027 /**
       
  5028 @publishedAll
       
  5029 @released
       
  5030 
       
  5031 
       
  5032 Get the extension interface for block streaming on image. @see TImageConvStreamedEncode
       
  5033 @return Interface to image conversion operations.
       
  5034 @leave KErrNotSupported if loaded codec plugin does not support this optional extension.
       
  5035 @leave Other system wide errors
       
  5036 */
       
  5037 EXPORT_C TImageConvStreamedEncode* CImageEncoder::BlockStreamerL()
       
  5038 	{
       
  5039 	ASSERT(ValidProperties());
       
  5040 
       
  5041 	CImageConvExtensionCache* cache = &iRelay->ExtensionCache();
       
  5042 	TImageConvStreamedEncode* streamer = cache->EncodeBlockStreamer();
       
  5043 
       
  5044 	if(!streamer)
       
  5045 		{
       
  5046 		MImageConvExtension* streamExtension = NULL;
       
  5047 		iRelay->GetExtensionL(KICLStreamedEncodeUid, streamExtension);
       
  5048 		streamer = new (ELeave) TImageConvStreamedEncode();
       
  5049 		streamer->SetExtension(streamExtension);
       
  5050 		cache->SetBlockStreamerExtension(streamer);
       
  5051 		}
       
  5052 	return streamer;
       
  5053 	}
       
  5054 
       
  5055 
       
  5056