imaging/imagingfws/src/ImagePlugin.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 <bitdev.h>
       
    17 #include <bautils.h>
       
    18 #include <barsc.h>
       
    19 #include "ImageConversion.h"
       
    20 #include "ImageClientMain.h"
       
    21 #include "ImageConversionPriv.h"
       
    22 #include "icl/ImagePlugin.h"
       
    23 #include "icl/ImageConstruct.h"
       
    24 #include "EnDecoderUtils.h"
       
    25 
       
    26 /**
       
    27 Constructor for this class.
       
    28 */
       
    29 EXPORT_C CImageDecoderPlugin::CImageDecoderPlugin()
       
    30 	{
       
    31 	}
       
    32 
       
    33 /**
       
    34 Destructor for this class.
       
    35 */
       
    36 EXPORT_C CImageDecoderPlugin::~CImageDecoderPlugin()
       
    37 	{
       
    38 	}
       
    39 
       
    40 /**
       
    41 Called when the plugin is destroyed or a decode is cancelled. This may be
       
    42 overriden in derived classes.
       
    43 
       
    44 Note:
       
    45 Derived classes must call this version after performing any plugin
       
    46 specific cleanup.
       
    47 */
       
    48 EXPORT_C void CImageDecoderPlugin::Cleanup()
       
    49 	{
       
    50 	if(ValidProperties())
       
    51 		iProperties->Cleanup();
       
    52 	}
       
    53 
       
    54 /**
       
    55 Initialises data structures prior to decoding a frame.
       
    56 
       
    57 This function may be overriden in derived classes. Any override should also
       
    58 call this version after performing any plugin initialistion.
       
    59 */
       
    60 EXPORT_C void CImageDecoderPlugin::InitConvertL()
       
    61 	{
       
    62 	ASSERT(ValidProperties());
       
    63 	iProperties->InitConvertL();
       
    64 	}
       
    65 /**
       
    66 Forces initialization of data structures prior to decoding a frame.
       
    67 
       
    68 @param	aFrameNumber
       
    69         The frame in a multi-frame image to decode.
       
    70 */
       
    71 EXPORT_C void CImageDecoderPlugin::RequestInitL(TInt aFrameNumber)
       
    72 	{
       
    73 	ASSERT(ValidProperties());
       
    74 	iProperties->RequestInitL(aFrameNumber);
       
    75 	}
       
    76 
       
    77 /**
       
    78 Performs a decode step. This effectively forms the RunL() call of the decoder.
       
    79 
       
    80 This call may be overriden in derived classes. However, if this
       
    81 the case, then if the custom decode is not performed and the derived class should
       
    82 either ensure that this base class's version is called or should completely replace
       
    83 the base class's version calling PrepareForProcessFrameL(), ProcessFrameL() and
       
    84 HandleProcessFrameResult() as appropriate. Unlike the standard version, an override
       
    85 instance may choose to spread these calls over several RunL() instances.
       
    86 */
       
    87 EXPORT_C void CImageDecoderPlugin::DoConvert()
       
    88 	{
       
    89 	ASSERT(ValidProperties());
       
    90 	iProperties->DoConvert();
       
    91 	}
       
    92 
       
    93 /**
       
    94 Initialises system for ProcessFrameL(). This reads in a new buffer for ProcessFrameL().
       
    95 */
       
    96 EXPORT_C void CImageDecoderPlugin::PrepareForProcessFrameL()
       
    97 	{
       
    98 	ASSERT(ValidProperties());
       
    99 	iProperties->PrepareForProcessFrameL();
       
   100 	}
       
   101 
       
   102 /**
       
   103 Deals with result from ProcessFrameL(). This function processes the results of the standard
       
   104 ProcessFrameL() call, feeding in the resultant error code from its TRAP and the status result.
       
   105 It will call RequestComplete() or SelfComplete() as appropriate.
       
   106 
       
   107 Note that if no data was consumed by ProcessFrameL(), HandleProcessFrameResult() assumes that
       
   108 it requires more data and calls RequestComplete(KErrUnderflow). If this is not appropriate, an
       
   109 overloaded DoConvert() should be made to handle it.
       
   110 
       
   111 @param  aErrCode
       
   112         The error result of TRAP arround ProcessFrameL().
       
   113 @param  aCodecState
       
   114         The result of ProcessFrameL() itself.
       
   115 */
       
   116 
       
   117 EXPORT_C void CImageDecoderPlugin::HandleProcessFrameResult(TInt aErrCode, TFrameState aCodecState)
       
   118 	{
       
   119 	ASSERT(ValidProperties());
       
   120 	iProperties->HandleProcessFrameResult(aErrCode, aCodecState);
       
   121 	}
       
   122 
       
   123 /**
       
   124 Value to be fed to CImageReadCodec::ProcessFrameL().
       
   125 
       
   126 This value is setup by PrepareForProcessFrameL() - it returns the value that will be
       
   127 fed to CImageReadCodec::ProcessFrameL(), and will be used by codecs that fully override
       
   128 DoConvert().
       
   129 */
       
   130 EXPORT_C TBufPtr8& CImageDecoderPlugin::SourceData()
       
   131 	{
       
   132 	ASSERT(ValidProperties());
       
   133 	return iProperties->SourceData();
       
   134 	}
       
   135 
       
   136 
       
   137 
       
   138 /**
       
   139 Returns the plugin's read codec.
       
   140 
       
   141 @return Pointer to the plugin's read codec.
       
   142 */
       
   143 EXPORT_C CImageReadCodec* CImageDecoderPlugin::ImageReadCodec() const
       
   144 	{
       
   145 	ASSERT(ValidProperties());
       
   146 	return iProperties->ImageReadCodec();
       
   147 	}
       
   148 
       
   149 /**
       
   150 Sets the plugin's read codec. Ownership of the codec is transferred to the plugin.
       
   151 
       
   152 @param  aImageReadCodec
       
   153         Pointer to the codec.
       
   154 */
       
   155 EXPORT_C void CImageDecoderPlugin::SetImageReadCodec(CImageReadCodec* aImageReadCodec)
       
   156 	{
       
   157 	ASSERT(ValidProperties());
       
   158 	iProperties->SetImageReadCodec(aImageReadCodec);
       
   159 	}
       
   160 
       
   161 /**
       
   162 Returns the maximum number of bytes of data that can be decoded.
       
   163 
       
   164 @return The maximum number of bytes of data.
       
   165 */
       
   166 EXPORT_C TInt CImageDecoderPlugin::DataLength() const
       
   167 	{
       
   168 	ASSERT(ValidProperties());
       
   169 	return iProperties->DataLength();
       
   170 	}
       
   171 
       
   172 /**
       
   173 Sets the maximum number of bytes of data that can be decoded.
       
   174 
       
   175 @param  aDataLength
       
   176         The maximum number of bytes of data.
       
   177 */
       
   178 EXPORT_C void CImageDecoderPlugin::SetDataLength(TInt aDataLength)
       
   179 	{
       
   180 	ASSERT(ValidProperties());
       
   181 	iProperties->SetDataLength(aDataLength);
       
   182 	}
       
   183 
       
   184 /**
       
   185 Returns the starting position of the frame to be decoded.
       
   186 
       
   187 @return The starting position.
       
   188 */
       
   189 EXPORT_C TInt CImageDecoderPlugin::StartPosition() const
       
   190 	{
       
   191 	ASSERT(ValidProperties());
       
   192 	return iProperties->StartPosition();
       
   193 	}
       
   194 
       
   195 /**
       
   196 Sets the starting position of the frame to be decoded.
       
   197 
       
   198 @param  aStartPosition
       
   199         The starting position in the data.
       
   200 */
       
   201 EXPORT_C void CImageDecoderPlugin::SetStartPosition(TInt aStartPosition)
       
   202 	{
       
   203 	ASSERT(ValidProperties());
       
   204 	iProperties->SetStartPosition(aStartPosition);
       
   205 	}
       
   206 
       
   207 /**
       
   208 Returns the image data block for the specified index.
       
   209 
       
   210 @param	aIndex
       
   211         The index of the image data block to return.
       
   212 
       
   213 @return The image data block.
       
   214 */
       
   215 EXPORT_C const TImageDataBlock* CImageDecoderPlugin::ImageData(TInt aIndex) const
       
   216 	{
       
   217 	ASSERT(ValidProperties());
       
   218 	return iProperties->ImageData(aIndex);
       
   219 	}
       
   220 
       
   221 /**
       
   222 Inserts an image data block into the internally held array at the specified position.
       
   223 
       
   224 @param  aEntry
       
   225         Pointer to the image data block to be inserted.
       
   226 @param  aPos
       
   227         The position within the arrary to insert the data block.
       
   228 
       
   229 @return KErrNone if the insertion was successful, otherwise a system
       
   230         wide error code.
       
   231 */
       
   232 EXPORT_C TInt CImageDecoderPlugin::InsertImageData(const TImageDataBlock* aEntry, TInt aPos)
       
   233 	{
       
   234 	ASSERT(ValidProperties());
       
   235 	return iProperties->InsertImageData(aEntry, aPos);
       
   236 	}
       
   237 
       
   238 /**
       
   239 Removes a specified image data block from the internally held array.
       
   240 
       
   241 @param  aPos
       
   242         The index of the image data block to be removed.
       
   243 */
       
   244 EXPORT_C void CImageDecoderPlugin::RemoveImageData(TInt aPos)
       
   245 	{
       
   246 	ASSERT(ValidProperties());
       
   247 	iProperties->RemoveImageData(aPos);
       
   248 	}
       
   249 
       
   250 /**
       
   251 Appends a new image data data block to the end of the internally held array.
       
   252 
       
   253 @param  aEntry
       
   254         The image data block to be appended.
       
   255 
       
   256 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
       
   257         another of the system-wide error codes.
       
   258 */
       
   259 EXPORT_C TInt CImageDecoderPlugin::AppendImageData(const TImageDataBlock* aEntry)
       
   260 	{
       
   261 	ASSERT(ValidProperties());
       
   262 	return iProperties->AppendImageData(aEntry);
       
   263 	}
       
   264 
       
   265 /**
       
   266 Returns the number of image data blocks present in the image data.
       
   267 
       
   268 @return The number of blocks.
       
   269 */
       
   270 EXPORT_C TInt CImageDecoderPlugin::ImageDataCount() const
       
   271 	{
       
   272 	ASSERT(ValidProperties());
       
   273 	return iProperties->ImageDataCount();
       
   274 	}
       
   275 
       
   276 /**
       
   277 Appends a new image data buffer to the end of the internally held array
       
   278 
       
   279 @param  aImageBuffer
       
   280         The data buffer to append.
       
   281 
       
   282 @return An error code indicating if the function call was successful. KErrNone on success, otherwise
       
   283         another of the system-wide error codes.
       
   284 */
       
   285 EXPORT_C TInt CImageDecoderPlugin::AppendImageDataBuffer(const HBufC8* aImageBuffer)
       
   286 	{
       
   287 	ASSERT(ValidProperties());
       
   288 	return iProperties->AppendImageDataBuffer(aImageBuffer);
       
   289 	}
       
   290 
       
   291 /**
       
   292 Returns the number of frames to be decoded.
       
   293 
       
   294 @return The number of frames.
       
   295 */
       
   296 EXPORT_C TInt CImageDecoderPlugin::NumberOfFrames() const
       
   297 	{
       
   298 	ASSERT(ValidProperties());
       
   299 	return iProperties->NumberOfFrames();
       
   300 	}
       
   301 
       
   302 /**
       
   303 Returns the current position within the data.
       
   304 
       
   305 @return The current position.
       
   306 */
       
   307 EXPORT_C TInt CImageDecoderPlugin::Position() const
       
   308 	{
       
   309 	ASSERT(ValidProperties());
       
   310 	return iProperties->Position();
       
   311 	}
       
   312 
       
   313 /**
       
   314 Sets the current position in the data.
       
   315 
       
   316 @param  aPosition
       
   317         The current position in the data.
       
   318 */
       
   319 EXPORT_C void CImageDecoderPlugin::SetPosition(const TInt aPosition)
       
   320 	{
       
   321 	ASSERT(ValidProperties());
       
   322 	iProperties->SetPosition(aPosition);
       
   323 	}
       
   324 
       
   325 /**
       
   326 Must be called on completion of decoding the image data.
       
   327 
       
   328 @param  aReason
       
   329         KErrNone should be returned if the decoding completes successfully. If the
       
   330 		request fails an appropriate error code should be returned.
       
   331 
       
   332 @see    CImageDecoderPlugin::SelfComplete(TInt aReason)
       
   333 */
       
   334 EXPORT_C void CImageDecoderPlugin::RequestComplete(TInt aReason)
       
   335 	{
       
   336 	ASSERT(ValidProperties());
       
   337 	iProperties->RequestComplete(aReason);
       
   338 	}
       
   339 
       
   340 /**
       
   341 Must be called at the end of a slice of decoding.
       
   342 
       
   343 If successful specify KErrNone that results in a repeat call to DoConvert().
       
   344 
       
   345 @param  aReason
       
   346         The error code giving the reason for completion, or KErrNone
       
   347         if no error occurred.
       
   348 
       
   349 @see    CImageDecoderPlugin::RequestComplete(TInt aReason)
       
   350 */
       
   351 EXPORT_C void CImageDecoderPlugin::SelfComplete(TInt aReason)
       
   352 	{
       
   353 	ASSERT(ValidProperties());
       
   354 	iProperties->SelfComplete(aReason);
       
   355 	}
       
   356 
       
   357 /**
       
   358 May be called at the start of a slice of decoding if the decoding
       
   359 is expected to complete asynchronously. This sets the AO in CImageDecoderPriv
       
   360 to active, but does not complete the request.
       
   361 
       
   362 When decoding of the slice is complete, there must be a call to SelfComplete().
       
   363 
       
   364 @see    CImageDecoderPlugin::SelfComplete(TInt aReason)
       
   365 */
       
   366 EXPORT_C void CImageDecoderPlugin::SetSelfPending(void)
       
   367 	{
       
   368 	ASSERT(ValidProperties());
       
   369 	iProperties->SetSelfPending();
       
   370 	}
       
   371 
       
   372 _LIT(KResourcePath,"\\Resource\\ICL\\");
       
   373 
       
   374 _LIT(KExtraResourceExtension,"_extra.rsc");
       
   375 
       
   376 /**
       
   377 Locates the extra resource file for the decoder aUid_extra.rsc, opens
       
   378 the resource file and pushes it on the cleanup stack.
       
   379 
       
   380 If the resource file is not found the method leaves with KErrNotFound.
       
   381 If more than one resource file is found, only the first one is opened.
       
   382 
       
   383 @param	aFs
       
   384       	A reference to the file server.
       
   385 @param	aUid
       
   386       	The decoder's UID.
       
   387 @param	aResourceFile
       
   388       	A reference to the opened resource file.
       
   389 */
       
   390 EXPORT_C void CImageDecoderPlugin::OpenExtraResourceFileLC(RFs& aFs, const TUid aUid, RResourceFile& aResourceFile) const
       
   391 	{
       
   392 	// Build the extra resource file name from the uid
       
   393 	TFileName fileName;
       
   394 
       
   395 	TUid implementationUid = iProperties->ImplementationUid();
       
   396 	CImplementationInformationType* implementationInformation = CImplementationInformationType::NewLC();
       
   397 	ImageEnDecoderUtils::DoGetImplementationInformationL(KImageDecoderInterfaceUid, *implementationInformation, implementationUid);
       
   398 
       
   399 	fileName.Copy(implementationInformation->Drive().Name());
       
   400 	CleanupStack::PopAndDestroy(implementationInformation);
       
   401 	
       
   402 
       
   403 	fileName.Append(KResourcePath);
       
   404 	fileName.AppendNum(aUid.iUid,EHex);
       
   405 	fileName.Append(KExtraResourceExtension);
       
   406 
       
   407 	// Get the locale specific file
       
   408 	BaflUtils::NearestLanguageFile(aFs,fileName);
       
   409 
       
   410 	aResourceFile.OpenL(aFs,fileName);
       
   411 
       
   412 	CleanupClosePushL(aResourceFile);
       
   413 	}
       
   414 
       
   415 /**
       
   416 Reads a block of data into an internal buffer.
       
   417 
       
   418 A block of data of size aLength is read from the position specified by aPosition
       
   419 to an internal data buffer. After a successful read, aReadBuffer is set to point to
       
   420 the internal buffer.
       
   421 
       
   422 If an attempt is made to read past the end of data, all available data is read and the
       
   423 descriptors length will indicate the actual number of bytes read.
       
   424 
       
   425 @param  aPosition
       
   426         The start position from where data will be read.
       
   427 @param  aReadBuffer
       
   428         Upon completion of a successful call, points to the internal buffer containing
       
   429         the data read from the source.
       
   430 @param  aLength
       
   431         The size in bytes of the block of data to be read.
       
   432 */
       
   433 EXPORT_C void CImageDecoderPlugin::ReadDataL(TInt aPosition, TPtrC8& aReadBuffer, TInt aLength)
       
   434 	{
       
   435 	ASSERT(ValidProperties());
       
   436 	iProperties->ReadDataL(aPosition, aReadBuffer, aLength);
       
   437 	}
       
   438 
       
   439 /**
       
   440 Returns image information such as colour depth, scaling support etc.
       
   441 
       
   442 @return Image information.
       
   443 */
       
   444 EXPORT_C const TFrameInfo& CImageDecoderPlugin::ImageInfo() const
       
   445 	{
       
   446 	ASSERT(ValidProperties());
       
   447 	return iProperties->ImageInfo();
       
   448 	}
       
   449 
       
   450 /**
       
   451 Sets the image information.
       
   452 
       
   453 @param  aImageInfo
       
   454         The image information.
       
   455 */
       
   456 EXPORT_C void CImageDecoderPlugin::SetImageInfo(const TFrameInfo& aImageInfo)
       
   457 	{
       
   458 	ASSERT(ValidProperties());
       
   459 	iProperties->SetImageInfo(aImageInfo);
       
   460 	}
       
   461 
       
   462 /**
       
   463 Returns the number of comments attatched to the image.
       
   464 
       
   465 Some image formats allow comments to be attached to the entire image, others allow
       
   466 comments to be attached to individual frames within the image. Use this function to
       
   467 retrieve the number of comments in the image. Use NumberOfFrameComments() for the
       
   468 frame equivalent.
       
   469 
       
   470 @return The number of comments attatched to the image.
       
   471 */
       
   472 EXPORT_C TInt CImageDecoderPlugin::NumberOfImageComments() const
       
   473 	{
       
   474 	__ASSERT_ALWAYS(IsImageHeaderProcessingComplete(), Panic(EHeaderProcessingNotComplete));
       
   475 	return 0;
       
   476 	}
       
   477 
       
   478 /**
       
   479 Returns a particular comment attatched to the image.
       
   480 Ownership of the returned buffer is transferred to the caller.
       
   481 
       
   482 @param  aCommentNumber
       
   483         The comment number.
       
   484 
       
   485 @return A buffer containing the specified comment.
       
   486 */
       
   487 EXPORT_C HBufC* CImageDecoderPlugin::ImageCommentL(TInt /* aCommentNumber */) const
       
   488 	{
       
   489 	__ASSERT_ALWAYS(IsImageHeaderProcessingComplete(), Panic(EHeaderProcessingNotComplete));
       
   490 	Panic(ECommentsNotSupported);
       
   491 	return NULL;
       
   492 	}
       
   493 
       
   494 /**
       
   495 Returns the number of comments attatched to a given frame of the image.
       
   496 
       
   497 Use NumberOfImageComments() for the image equivalent.
       
   498 
       
   499 @param  aFrameNumber
       
   500         The frame number.
       
   501 
       
   502 @return The number of comments attatched to a given frame of the image.
       
   503 */
       
   504 EXPORT_C TInt CImageDecoderPlugin::NumberOfFrameComments(TInt aFrameNumber) const
       
   505 	{
       
   506 	ASSERT(ValidProperties());
       
   507 	__ASSERT_ALWAYS(IsImageHeaderProcessingComplete(), Panic(EHeaderProcessingNotComplete));
       
   508 	__ASSERT_ALWAYS((aFrameNumber >= 0) && (aFrameNumber < iProperties->FrameCount()), Panic(EFrameNumberOutOfRange));
       
   509 	return 0;
       
   510 	}
       
   511 
       
   512 /**
       
   513 Returns a particular comment attatched to a given frame of the image.
       
   514 
       
   515 Ownership of the returned buffer is transferred to the caller.
       
   516 
       
   517 @param  aFrameNumber
       
   518         The index of the frame containing the comments.
       
   519 @param  aCommentNumber
       
   520         The index of the comment to retrieve from the specified frame.
       
   521 
       
   522 @return A buffer containing the specified comment.
       
   523 */
       
   524 EXPORT_C HBufC* CImageDecoderPlugin::FrameCommentL(TInt aFrameNumber, TInt /*aCommentNumber*/) const
       
   525 	{
       
   526 	ASSERT(ValidProperties());
       
   527 	__ASSERT_ALWAYS(IsImageHeaderProcessingComplete(), Panic(EHeaderProcessingNotComplete));
       
   528 	__ASSERT_ALWAYS((aFrameNumber >= 0) && (aFrameNumber < iProperties->FrameCount()), Panic(EFrameNumberOutOfRange));
       
   529 	Panic(ECommentsNotSupported);
       
   530 	return NULL;
       
   531 	}
       
   532 
       
   533 /**
       
   534 Invokes the ReadFrameHeadersL method of the supplied plugin which
       
   535 should process the frame headers contained within the image.
       
   536 */
       
   537 EXPORT_C void CImageDecoderPlugin::ReadFrameHeadersL()
       
   538 	{
       
   539 	ASSERT(ValidProperties());
       
   540 	iProperties->ReadFrameHeadersL();
       
   541 	}
       
   542 
       
   543 /**
       
   544 Returns the block size used in the specified frame's header.
       
   545 Always returns 4096 regardless of the frame number specified.
       
   546 Should be overriden by codecs that use larger blocks.
       
   547 
       
   548 @param  aFrameNumber
       
   549         The frame to which the header block size information applies.
       
   550 
       
   551 @return The returned frame header block size (always 4096).
       
   552 */
       
   553 EXPORT_C TInt CImageDecoderPlugin::FrameHeaderBlockSize(TInt /*aFrameNumber*/) const
       
   554 	{
       
   555 	return 4096;
       
   556 	}
       
   557 
       
   558 /**
       
   559 Returns the block size used in the specified frame.
       
   560 Always returns 4096 regardless of the frame number specified.
       
   561 Should be overriden by codecs that use larger blocks.
       
   562 
       
   563 @param  aFrameNumber
       
   564         The frame to which the block size information applies.
       
   565 
       
   566 @return The returned frame block size (always 4096).
       
   567 */
       
   568 EXPORT_C TInt CImageDecoderPlugin::FrameBlockSize(TInt /*aFrameNumber*/) const
       
   569 	{
       
   570 	return 4096;
       
   571 	}
       
   572 
       
   573 /**
       
   574 Returns the destination bitmap.
       
   575 
       
   576 @return A reference to the destination bitmap.
       
   577 */
       
   578 EXPORT_C const CFbsBitmap& CImageDecoderPlugin::Destination() const
       
   579 	{
       
   580 	ASSERT(ValidProperties());
       
   581 	ASSERT(ValidDestination());
       
   582 	return iProperties->Destination();
       
   583 	}
       
   584 
       
   585 /**
       
   586 Returns the validity of the destination bitmap.
       
   587 
       
   588 @return A boolean indicating if the destination bitmap is valid. ETrue if the destination bitmap 
       
   589         is valid, EFalse otherwise.
       
   590 */
       
   591 EXPORT_C TBool CImageDecoderPlugin::ValidDestination() const
       
   592 	{
       
   593 	return iProperties->ValidDestination();
       
   594 	}
       
   595 
       
   596 /**
       
   597 Returns the destination bitmap mask.
       
   598 
       
   599 @return A reference to the destination bitmap mask.
       
   600 */
       
   601 EXPORT_C const CFbsBitmap& CImageDecoderPlugin::DestinationMask() const
       
   602 	{
       
   603 	ASSERT(ValidProperties());
       
   604 	ASSERT(ValidDestinationMask());
       
   605 	return iProperties->DestinationMask();
       
   606 	}
       
   607 
       
   608 /**
       
   609 Indicates if the destination bitmap mask is valid.
       
   610 
       
   611 @return A boolean indicating if the destination bitmap is valid. ETrue if the destination bitmap 
       
   612         mask is valid, otherwise EFalse.
       
   613 */
       
   614 EXPORT_C TBool CImageDecoderPlugin::ValidDestinationMask() const
       
   615 	{
       
   616 	return iProperties->ValidDestinationMask();
       
   617 	}
       
   618 
       
   619 
       
   620 /**
       
   621 Paints the entire bitmap aBitmap with the color supplied as aColor.
       
   622 
       
   623 @param     aBitmap
       
   624            A reference to a fully constructed bitmap.
       
   625 @param     aColor
       
   626            The color to use for painting.
       
   627 */
       
   628 EXPORT_C void CImageReadCodec::ClearBitmapL(CFbsBitmap& aBitmap, TRgb aColor)
       
   629 	{
       
   630 	if (aBitmap.Handle())
       
   631 		{
       
   632 		if(aBitmap.ExtendedBitmapType()!=KNullUid)
       
   633 		    {
       
   634 		    User::Leave(KErrNotSupported);
       
   635 		    }
       
   636 		CFbsBitmapDevice* device = CFbsBitmapDevice::NewL(&aBitmap);
       
   637 		CleanupStack::PushL(device);
       
   638 		CFbsBitGc* gc = NULL;
       
   639 		User::LeaveIfError(device->CreateContext(gc));
       
   640 		
       
   641 		// with alpha channel addition, the best way to paint an entire 
       
   642 		// bitmap is to set the draw mode to WriteAlpha
       
   643 		TDisplayMode mode = aBitmap.DisplayMode();
       
   644 		if( mode == EColor16MA || mode == EColor16MAP )
       
   645 			{
       
   646 			gc->SetDrawMode(CGraphicsContext::EDrawModeWriteAlpha);	
       
   647 			}
       
   648 
       
   649 		gc->SetBrushColor(aColor);
       
   650 		gc->SetBrushStyle(CGraphicsContext::ESolidBrush);
       
   651 		gc->Clear();
       
   652 		delete gc;
       
   653 		CleanupStack::PopAndDestroy(); // device
       
   654 		}
       
   655 	}
       
   656 
       
   657 /**
       
   658 Checks that the constructed decoder is valid.
       
   659 
       
   660 This function is internal and not intended for use.
       
   661 
       
   662 @return A boolean indicating if the decoders construction is valid. ETrue if valid, EFalse otherwise.
       
   663 */
       
   664 TBool CImageDecoderPlugin::ValidProperties() const
       
   665 	{
       
   666 	return iProperties != NULL;
       
   667 	}
       
   668 
       
   669 /**
       
   670 Returns the status of header processing. If the processing is incomplete or not
       
   671 terminated correctly EFalse will be returned
       
   672 
       
   673 @return The header processing status.
       
   674 */
       
   675 EXPORT_C TBool CImageDecoderPlugin::IsImageHeaderProcessingComplete() const
       
   676 	{
       
   677 	return iProperties->IsImageHeaderProcessingComplete();
       
   678 	}
       
   679 
       
   680 /**
       
   681 Returns the frame info for a specified frame of the image.
       
   682 
       
   683 This function can be called immediately after the call to create the decoder,
       
   684 thus enabling the caller to know about each frame in advance of decoding it.
       
   685 
       
   686 @param  aFrameNumber
       
   687         The frame number for which information is requested (Optional, defaults to 0).
       
   688 
       
   689 @return The information for the specified frame.
       
   690 */
       
   691 EXPORT_C const TFrameInfo& CImageDecoderPlugin::FrameInfo(TInt aFrameNumber) const
       
   692 	{
       
   693 	// Return the frame info for a particular frame
       
   694 	ASSERT(ValidProperties());
       
   695 	return iProperties->FrameInfo(aFrameNumber);
       
   696 	}
       
   697 
       
   698 /**
       
   699 Returns the frame data for a specified frame of the image.
       
   700 
       
   701 @param  aFrameNumber
       
   702         The frame number from which to retreive the frame data (Optional, defaults to 0).
       
   703 
       
   704 @return The data for the specified frame.
       
   705  */
       
   706 EXPORT_C const CFrameImageData& CImageDecoderPlugin::FrameData(TInt aFrameNumber) const
       
   707 	{
       
   708 	// Return the frame image data for a particular frame.
       
   709 	ASSERT(ValidProperties());
       
   710 	return iProperties->FrameData(aFrameNumber);
       
   711 	}
       
   712 
       
   713 /**
       
   714 Returns the length of the source data in bytes.
       
   715 
       
   716 @return The length of the source data.
       
   717 */
       
   718 EXPORT_C TInt CImageDecoderPlugin::SourceLength() const
       
   719 	{
       
   720 	ASSERT(ValidProperties());
       
   721 	return iProperties->SourceLength();
       
   722 	}
       
   723 
       
   724 /**
       
   725 This function must be called on completion of encoding the image data.
       
   726 
       
   727 @param  aReason
       
   728         The error code giving the reason for completion, or KErrNone
       
   729         if no error occurred.
       
   730 
       
   731 @see    CImageEncoderPlugin::SelfComplete(TInt aReason)
       
   732 */
       
   733 EXPORT_C void CImageEncoderPlugin::RequestComplete(TInt aReason)
       
   734 	{
       
   735 	ASSERT(ValidProperties());
       
   736 	iProperties->RequestComplete(aReason);
       
   737 	}
       
   738 
       
   739 /**
       
   740 Must be called at the end of a slice of encoding. If called with
       
   741 KErrNone will cause a repeat call to DoConvert().
       
   742 
       
   743 @param aReason
       
   744        The error code giving the reason for completion, or KErrNone
       
   745        if no error occurred.
       
   746 
       
   747 @see   CImageEncoderPlugin::RequestComplete(TInt aReason)
       
   748 */
       
   749 EXPORT_C void CImageEncoderPlugin::SelfComplete(TInt aReason)
       
   750 	{
       
   751 	ASSERT(ValidProperties());
       
   752 	iProperties->SelfComplete(aReason);
       
   753 	}
       
   754 
       
   755 /**
       
   756 May be called at the start of a slice of encoding if the encoding
       
   757 is expected to complete asynchronously. This sets the AO in CImageEncoderPriv
       
   758 to active, but does not complete the request.
       
   759 
       
   760 When the encoding of the slice is complete, there must be a call to SelfComplete()
       
   761 
       
   762 @see   CImageEncoderPlugin::SelfComplete(TInt aReason)
       
   763 */
       
   764 EXPORT_C void CImageEncoderPlugin::SetSelfPending(void)
       
   765 	{
       
   766 	ASSERT(ValidProperties());
       
   767 	iProperties->SetSelfPending();
       
   768 	}
       
   769 
       
   770 /**
       
   771 Called as a result of an associated CImageDecoder::CustomSyncL() function being called.
       
   772 Plugins may override this to provide extended commands in CImageDecoder. Default version
       
   773 leaves with KErrNotSupported.
       
   774 
       
   775 @param  aParam
       
   776         Interpretation dependent on plugin.
       
   777 */
       
   778 EXPORT_C void CImageDecoderPlugin::HandleCustomSyncL(TInt aParam)
       
   779 	{
       
   780 	ASSERT(ValidProperties());
       
   781 	iProperties->BodyHandleCustomSyncL(aParam);
       
   782 	}
       
   783 
       
   784 /**
       
   785 Called as a result of the associated CImageDecoder::CustomAsync() function being called.
       
   786 
       
   787 If this function finishes normally, then a convert cycle is started - so that DoConvert()
       
   788 will be subsequently started in the background - otherwise, if this function leaves then
       
   789 the error result is immediately signalled back to the caller of CustomAsync().
       
   790 
       
   791 Plugins may override this to provide extended commands in CImageDecoder.Users of
       
   792 CImageEncoder can then use the extended encoder functions by calling CustomAsync, rather
       
   793 than CImageEncoder::Convert().
       
   794 
       
   795 By default this function leaves with KErrNotSupported unless overriden.
       
   796 
       
   797 @param  aParam
       
   798         Interpretation dependent on plugin.
       
   799 */
       
   800 
       
   801 EXPORT_C void CImageDecoderPlugin::InitCustomAsyncL(TInt aParam)
       
   802 	{
       
   803 	ASSERT(ValidProperties());
       
   804 	iProperties->BodyInitCustomAsyncL(aParam);
       
   805 	}
       
   806 
       
   807 /**
       
   808 Plugin defined actions resulting from a call by RequestComplete().
       
   809 
       
   810 This function is called when a RequestComplete() is issued indicating that an
       
   811 asynchronous command has finished. Plugins can extend this function to,
       
   812 clear any custom command flags.
       
   813 */
       
   814 EXPORT_C void CImageDecoderPlugin::NotifyComplete()
       
   815 	{
       
   816 	ASSERT(ValidProperties());
       
   817 	iProperties->BodyNotifyComplete();
       
   818 	}
       
   819 
       
   820 /**
       
   821 Indicates if this decoder is running in a separate thread.
       
   822 
       
   823 @return ETrue if running in separate thread, otherwise EFalse
       
   824 */
       
   825 
       
   826 EXPORT_C TBool CImageDecoderPlugin::AmInThread() const
       
   827 	{
       
   828 	return iProperties->AmInThread();
       
   829 	}
       
   830 
       
   831 /**
       
   832 Passes a pointer to a descriptor containing the thumbnail from the 
       
   833 plugin to the framework. The framework then owns this descriptor.
       
   834 
       
   835 @param aThumbnailData
       
   836 	   A pointer to a HBufC8 containing the thumbnail data
       
   837 */
       
   838 
       
   839 EXPORT_C void CImageDecoderPlugin::SetThumbnailData(HBufC8* aThumbnailData)
       
   840 	{
       
   841 	ASSERT(ValidProperties());	
       
   842 	iProperties->SetThumbnailData(aThumbnailData);
       
   843 	}
       
   844 
       
   845 
       
   846 /**
       
   847 Indicates if the decoder should abort early ie. following a call to
       
   848 Cancel().
       
   849 
       
   850 Note: This function always returns false unless the decoder is running
       
   851 in its own thread.
       
   852 
       
   853 @return ETrue if it should abort early, otherwise EFalse
       
   854 */
       
   855 
       
   856 EXPORT_C TBool CImageDecoderPlugin::ShouldAbort() const
       
   857 	{
       
   858 	return iProperties->ShouldAbort();
       
   859 	}
       
   860 
       
   861 /**
       
   862 @internalComponent
       
   863 
       
   864 Enables generation of an image mask (to be implemented by the plugin
       
   865 if this feature is supported).
       
   866 */
       
   867 EXPORT_C void CImageDecoderPlugin::EnableMaskGeneration()
       
   868 	{
       
   869 	}
       
   870 
       
   871 /**
       
   872 @internalComponent
       
   873 
       
   874 Notify the plugin that the client has changed the requested source 
       
   875 image type (e.g. Main to Thumb or vice-versa)
       
   876 */
       
   877 EXPORT_C void CImageDecoderPlugin::NotifyImageTypeChangeL(TInt)
       
   878 	{
       
   879 	}
       
   880 
       
   881 /**
       
   882 @publishedAll
       
   883 @released
       
   884 
       
   885 Returns the decoding options specified by the client when it created the CImageDecoder object.
       
   886 
       
   887 @return The decoding options.
       
   888 */
       
   889 EXPORT_C CImageDecoder::TOptions CImageDecoderPlugin::DecoderOptions() const
       
   890 	{
       
   891 	return iProperties->DecoderOptions();
       
   892 	}
       
   893 
       
   894 /**
       
   895 
       
   896 */
       
   897 EXPORT_C void CImageDecoderPlugin::GetExtensionL(TUid /*aExtUid*/, MImageConvExtension*& /*aExtPtr*/)
       
   898 	{
       
   899 	User::Leave(KErrNotSupported);
       
   900 	}
       
   901 
       
   902 /**
       
   903 Gets the size of the destination CFbsBitmap needed prior to a call to Convert().
       
   904 Essential when using the ICL Framework Extensions such as SetClippingRectL() or
       
   905 codec extensions obtained through the OperationL(), ScalerL() and BlockStreamerL()
       
   906 calls.
       
   907 
       
   908 @param  aSize	A reference to a TSize that specifies the size
       
   909 				of the region that is to be decoded by a call to
       
   910 				Convert().
       
   911 @param 	aFrameNumber The number of the frame that is to be decoded.
       
   912 
       
   913 @see	CImageDecoder::OperationL()
       
   914 @see	CImageDecoder::ScalerL()
       
   915 @see	CImageDecoder::BlockStreamerL()
       
   916 @see	CImageDecoder::SetClippingRectL()
       
   917 @see	CImageDecoder::Convert()
       
   918 */
       
   919 EXPORT_C TInt CImageDecoderPlugin::GetDestinationSize(TSize& /*aSize*/, TInt /*aFrameNumber*/)
       
   920 	{
       
   921 	return KErrNotSupported;
       
   922 	}
       
   923 
       
   924 /**
       
   925 Sets the area of interest of the image to be decoded.  This function can leave with
       
   926 any of the system-wide error codes.
       
   927 
       
   928 @param aClipRect	A pointer to a TRect that specifies the
       
   929 					location and size of the region to be decoded.  This
       
   930 					rectangle must have positive width and height values as
       
   931 					per TRect::IsNormalized() and TRect::Normalize().
       
   932 					Passing in a NULL value will clear the clipping rectangle.
       
   933 
       
   934 @leave KErrNotSupported		This function is not supported.
       
   935 @leave KErrArgument			Returned if the clipping rectangle:
       
   936 							a) is empty (i.e. IsEmpty() returns ETrue)
       
   937 							b) is not normalised (i.e. IsNormalized() returns EFalse)
       
   938 							c) has coordinates that are not located within, or on,
       
   939 							the coodinates of at least one frame of the original image.
       
   940 							d) has a width or a height of 0
       
   941 
       
   942 @see	TRect::IsEmpty()
       
   943 @see	TRect::IsNormalized()
       
   944 @see	TRect::Normalize()
       
   945 */
       
   946 EXPORT_C void CImageDecoderPlugin::SetClippingRectL(const TRect* /*aClipRect*/)
       
   947 	{
       
   948 	User::Leave(KErrNotSupported);
       
   949 	}
       
   950 
       
   951 /**
       
   952 @internalComponent
       
   953 
       
   954 Intended for future proofing - will panic if called.
       
   955 
       
   956 @panic  EReservedCall
       
   957 */
       
   958 EXPORT_C void CImageDecoderPlugin::ReservedVirtual1()
       
   959 	{
       
   960 	Panic(EReservedCall);
       
   961 	}
       
   962 
       
   963 /* IMAGE ENCODER */
       
   964 
       
   965 /**
       
   966 Constructor for this class.
       
   967 */
       
   968 EXPORT_C CImageEncoderPlugin::CImageEncoderPlugin()
       
   969 	{
       
   970 	}
       
   971 
       
   972 /**
       
   973 Destructor for this class.
       
   974 */
       
   975 EXPORT_C CImageEncoderPlugin::~CImageEncoderPlugin()
       
   976 	{
       
   977 	}
       
   978 
       
   979 /**
       
   980 Called when the plugin is destroyed or an encode is cancelled to perform
       
   981 cleanup functions.
       
   982 
       
   983 This function may be overriden in derived classes in which case the derived
       
   984 class should ensure it calls this version after performing any plugin
       
   985 specific cleanup.
       
   986 */
       
   987 EXPORT_C void CImageEncoderPlugin::Cleanup()
       
   988 	{
       
   989 	if(ValidProperties())
       
   990 		iProperties->Cleanup();
       
   991 	}
       
   992 
       
   993 /**
       
   994 Initialises data structures prior to encoding a frame.
       
   995 
       
   996 This may be overriden in derived classes in which case the derived class
       
   997 should ensure it calls this version after performing any plugin
       
   998 initialisation.
       
   999 */
       
  1000 EXPORT_C void CImageEncoderPlugin::InitConvertL()
       
  1001 	{
       
  1002 	ASSERT(ValidProperties());
       
  1003 	iProperties->InitConvertL();
       
  1004 	}
       
  1005 
       
  1006 /**
       
  1007 Forces initialization of data structures prior to decoding a frame.
       
  1008 */
       
  1009 EXPORT_C void CImageEncoderPlugin::RequestInitL()
       
  1010 	{
       
  1011 	ASSERT(ValidProperties());
       
  1012 	iProperties->RequestInitL();
       
  1013 	}
       
  1014 	
       
  1015 /**
       
  1016 Performs the encoding process.
       
  1017 
       
  1018 This call may be overriden in derived classes. If this is not
       
  1019 the case and a custom decode is not performed, the derived class should
       
  1020 ensure that this base class's version is called.
       
  1021 */
       
  1022 EXPORT_C void CImageEncoderPlugin::DoConvert()
       
  1023 	{
       
  1024 	ASSERT(ValidProperties());
       
  1025 	iProperties->DoConvert();
       
  1026 	}
       
  1027 
       
  1028 /**
       
  1029 @internalComponent
       
  1030 
       
  1031 Tells the encoder to generate the thumbnail
       
  1032 
       
  1033 THis is used only for Exif format. If aDoGenerateThumbnail=EFalse, the 
       
  1034 thumbnail is not generated. The default value is ETrue
       
  1035 
       
  1036 */
       
  1037 EXPORT_C void CImageEncoderPlugin::SetThumbnail(TBool /*aDoGenerateThumbnail*/)
       
  1038 	{
       
  1039 	}
       
  1040 
       
  1041 /**
       
  1042 Deals with the result from ProcessFrameL().
       
  1043 
       
  1044 This processes the results of the standard ProcessFrameL() call, feeding in the resultant
       
  1045 error code from its TRAP and the status result. It will call RequestComplete() or
       
  1046 SelfComplete() as appropriate. Note that if no data was created by ProcessFrameL(),
       
  1047 HandleProcessFrameResult() assumes that the encoding process is complete.
       
  1048 If this is not appropriate, an overloaded DoConvert() should be used to handle it.
       
  1049 
       
  1050 @param  aErrCode
       
  1051         The error result of TRAP around ProcessFrameL().
       
  1052 @param  aCodecState
       
  1053         The result of ProcessFrameL() itself.
       
  1054 */
       
  1055 
       
  1056 EXPORT_C void CImageEncoderPlugin::HandleProcessFrameResult(TInt aErrCode, TFrameState aCodecState)
       
  1057 	{
       
  1058 	ASSERT(ValidProperties());
       
  1059 	iProperties->HandleProcessFrameResult(aErrCode, aCodecState);
       
  1060 	}
       
  1061 
       
  1062 /**
       
  1063 Returns the value to be fed to CImageWriteCodec::ProcessFrameL(),
       
  1064 and will be used by codecs that fully override DoConvert().
       
  1065 */
       
  1066 EXPORT_C TBufPtr8& CImageEncoderPlugin::DestinationData()
       
  1067 	{
       
  1068 	ASSERT(ValidProperties());
       
  1069 	return iProperties->DestinationData();
       
  1070 	}
       
  1071 
       
  1072 /**
       
  1073 Writes a descriptor to the internal data buffer of the encoded image without 
       
  1074 incrementing the position in the buffer, and therefore a call to Position()
       
  1075 will return the same value before or after a call to this function.
       
  1076 
       
  1077 @param	aPosition
       
  1078 		The start position in the internal data buffer of the encoded image from
       
  1079 		which point the data in aDes is written.
       
  1080 @param	aDes
       
  1081 		The descriptor containing the data to be written to the internal data buffer
       
  1082 		of the encoded image.
       
  1083 @see	Position()
       
  1084 */
       
  1085 EXPORT_C void CImageEncoderPlugin::WriteDataL(TInt aPosition,const TDesC8& aDes)
       
  1086 	{
       
  1087 	ASSERT(ValidProperties());
       
  1088 	iProperties->WriteDataL(aPosition, aDes);
       
  1089 	}
       
  1090 	
       
  1091 /**
       
  1092 Writes a descriptor to the internal data buffer of the encoded image.  In addition,
       
  1093 the position in the buffer that is written to (obtained with Position()) will be
       
  1094 incremented returning aPosition + aDes.Length().
       
  1095 
       
  1096 @param	aPosition
       
  1097 		The start position in the internal data buffer of the encoded image from
       
  1098 		which point the data in aDes is written.
       
  1099 @param	aDes
       
  1100 		The descriptor containing the data to be written to the internal data buffer
       
  1101 		of the encoded image.
       
  1102 @see	Position()
       
  1103 */
       
  1104 EXPORT_C void CImageEncoderPlugin::WriteDataPositionIncL(TInt aPosition,const TDesC8& aDes)
       
  1105 	{
       
  1106 	ASSERT(ValidProperties());
       
  1107 	iProperties->WriteDataPositionIncL(aPosition, aDes);
       
  1108 	}	
       
  1109 
       
  1110 /**
       
  1111 Returns the plugin's write codec.
       
  1112 
       
  1113 @return A pointer to the plugin's write codec.
       
  1114 */
       
  1115 EXPORT_C CImageWriteCodec* CImageEncoderPlugin::ImageWriteCodec() const
       
  1116 	{
       
  1117 	ASSERT(ValidProperties());
       
  1118 	return iProperties->ImageWriteCodec();
       
  1119 	}
       
  1120 
       
  1121 /**
       
  1122 Sets the plugin's write codec.
       
  1123 
       
  1124 Ownership of the codec is transferred to the plugin.
       
  1125 
       
  1126 @param  aImageWriteCodec
       
  1127         A pointer to the codec.
       
  1128 */
       
  1129 EXPORT_C void CImageEncoderPlugin::SetImageWriteCodec(CImageWriteCodec* aImageWriteCodec) const
       
  1130 	{
       
  1131 	ASSERT(aImageWriteCodec != NULL);
       
  1132 	ASSERT(ValidProperties());
       
  1133 	iProperties->SetImageWriteCodec(aImageWriteCodec);
       
  1134 	}
       
  1135 
       
  1136 /**
       
  1137 Returns the bitmap which is being encoded.
       
  1138 
       
  1139 @return A reference to the source bitmap.
       
  1140 */
       
  1141 EXPORT_C const CFbsBitmap& CImageEncoderPlugin::Source() const
       
  1142 	{
       
  1143 	ASSERT(ValidProperties());
       
  1144 	return iProperties->Source();
       
  1145 	}
       
  1146 
       
  1147 /**
       
  1148 Checks the validity of the bitmap which is being encoded. Returns ETrue if the 
       
  1149 bitmap is valid, otherwise EFalse.
       
  1150 
       
  1151 @return A boolean describing the validity of the bitamp.
       
  1152 */
       
  1153 EXPORT_C TBool CImageEncoderPlugin::ValidSource() const
       
  1154 	{
       
  1155 	ASSERT(ValidProperties());
       
  1156 	return iProperties->ValidSource();
       
  1157 	}
       
  1158 
       
  1159 /**
       
  1160 Returns the starting position of the internal data buffer of the encoded image
       
  1161 that is being written to.
       
  1162 
       
  1163 @return The starting position.
       
  1164 */
       
  1165 EXPORT_C TInt& CImageEncoderPlugin::StartPosition() const
       
  1166 	{
       
  1167 	ASSERT(ValidProperties());
       
  1168 	return iProperties->StartPosition();
       
  1169 	}
       
  1170 
       
  1171 /**
       
  1172 Returns the current position within the internal data buffer that is being written to.
       
  1173 
       
  1174 @return The current position.
       
  1175 @see	WriteDataPositionIncL(TInt aPosition,const TDesC8& aDes)
       
  1176 @see	WriteDataL(TInt aPosition,const TDesC8& aDes)
       
  1177 */
       
  1178 EXPORT_C TInt& CImageEncoderPlugin::Position() const
       
  1179 	{
       
  1180 	ASSERT(ValidProperties());
       
  1181 	return iProperties->Position();
       
  1182 	}
       
  1183 
       
  1184 /**
       
  1185 Returns the overall size of the image frame in pixels.
       
  1186 
       
  1187 @return The size of the image frame.
       
  1188 */
       
  1189 EXPORT_C const TSize& CImageEncoderPlugin::FrameInfoOverallSizeInPixels() const
       
  1190 	{
       
  1191 	ASSERT(ValidProperties());
       
  1192 	return iProperties->FrameInfoOverallSizeInPixels();
       
  1193 	}
       
  1194 
       
  1195 /**
       
  1196 Checks that the constructed encoder is valid.
       
  1197 
       
  1198 @return ETrue if valid, EFalse otherwise.
       
  1199 */
       
  1200 TBool CImageEncoderPlugin::ValidProperties() const
       
  1201 	{
       
  1202 	return iProperties != NULL;
       
  1203 	}
       
  1204 
       
  1205 /**
       
  1206 Returns the current size of the encoded image in bytes.
       
  1207 
       
  1208 @return The current size of the encoded image in bytes.
       
  1209 */
       
  1210 EXPORT_C TInt CImageEncoderPlugin::CurrentImageSizeL() const
       
  1211 	{
       
  1212 	ASSERT(ValidProperties());
       
  1213 	return iProperties->CurrentImageSizeL();
       
  1214 	}
       
  1215 
       
  1216 /**
       
  1217 Called as a result of the associated CImageEncoder::CustomSyncL() function being called.
       
  1218 Plugins may override this to provide extended commands in CImageEncoder. Default version
       
  1219 leaves with KErrNotSupported.
       
  1220 
       
  1221 @param  aParam
       
  1222         Interpretation dependent on plugin.
       
  1223 */
       
  1224 
       
  1225 EXPORT_C void CImageEncoderPlugin::HandleCustomSyncL(TInt aParam)
       
  1226 	{
       
  1227 	ASSERT(ValidProperties());
       
  1228 	iProperties->BodyHandleCustomSyncL(aParam);
       
  1229 	}
       
  1230 
       
  1231 /**
       
  1232 Called as a result of the associated CImageEncoder::CustomAsync() function being called.
       
  1233 If this function finishes normally, then a convert cycle is started - so that DoConvert()
       
  1234 will be subsequently started in the background - otherwise, if this function leaves then
       
  1235 the error result is immediately signalled back to the caller of CustomAsync().
       
  1236 
       
  1237 The default version leaves with KErrNotSupported unless overridden to change this behaviour. Plugins may
       
  1238 override this to provide extended commands in CImageEncoder.
       
  1239 
       
  1240 @param  aParam
       
  1241         Interpretation dependent on plugin.
       
  1242 */
       
  1243 
       
  1244 EXPORT_C void CImageEncoderPlugin::InitCustomAsyncL(TInt aParam)
       
  1245 	{
       
  1246 	ASSERT(ValidProperties());
       
  1247 	iProperties->BodyInitCustomAsyncL(aParam);
       
  1248 	}
       
  1249 
       
  1250 /**
       
  1251 Plugin defined actions resulting from a call by RequestComplete().
       
  1252 
       
  1253 This function is called when a RequestComplete() is issued indicating that
       
  1254 an asynchronous command has finished. Plugins can extend this function to
       
  1255 clear any custom command flags.
       
  1256 */
       
  1257 EXPORT_C void CImageEncoderPlugin::NotifyComplete()
       
  1258 	{
       
  1259 	ASSERT(ValidProperties());
       
  1260 	iProperties->BodyNotifyComplete();
       
  1261 	}
       
  1262 
       
  1263 /**
       
  1264 Indicates if this encoder is running in a separate thread.
       
  1265 
       
  1266 @return	A boolean indicating if the encoder is running in a seperate thread. ETrue if running in 
       
  1267         separate thread, otherwise EFalse.
       
  1268 */
       
  1269 EXPORT_C TBool CImageEncoderPlugin::AmInThread() const
       
  1270 	{
       
  1271 	ASSERT(ValidProperties());
       
  1272 	return iProperties->AmInThread();
       
  1273 	}
       
  1274 
       
  1275 /**
       
  1276 Indicates if an encode should abort early (ie. following a Cancel).
       
  1277 
       
  1278 Note:
       
  1279 This function always returns EFalse unless the encoder is running in its own thread.
       
  1280 
       
  1281 @return A boolean indicating if the encode should abort early. ETrue if should abort early, 
       
  1282         otherwise EFalse.
       
  1283 */
       
  1284 
       
  1285 EXPORT_C TBool CImageEncoderPlugin::ShouldAbort() const
       
  1286 	{
       
  1287 	ASSERT(ValidProperties());
       
  1288 	return iProperties->ShouldAbort();
       
  1289 	}
       
  1290 
       
  1291 /**
       
  1292 Notifies the framework that the main frame encoding is complete, so it can tidy up. This
       
  1293 results in a call to UpdateHeaderL() and then either the descriptor is copied across
       
  1294 or the file is closed.
       
  1295 
       
  1296 Note:
       
  1297 This function is only used if a decoder replaces the DoConvert() call - the default
       
  1298 version does this as part of its processing.
       
  1299 */
       
  1300 EXPORT_C void CImageEncoderPlugin::FinishConvertL()
       
  1301 	{
       
  1302 	ASSERT(ValidProperties());
       
  1303 	iProperties->FinishConvertL();
       
  1304 	}
       
  1305 
       
  1306 /**
       
  1307 @internalComponent
       
  1308 
       
  1309 Sets the thumbnail in the encoded file
       
  1310 
       
  1311 @panic  EReservedCall
       
  1312 */
       
  1313 EXPORT_C void CImageEncoderPlugin::WriteThumbnailL()
       
  1314 	{
       
  1315 	
       
  1316 	}
       
  1317 
       
  1318 /**
       
  1319 @internalComponent
       
  1320 
       
  1321 Intended for future proofing - will panic if called
       
  1322 
       
  1323 @param the status which will be notified once the scale operation on the thumbnail will be performed
       
  1324 
       
  1325 @panic  EReservedCall
       
  1326 */
       
  1327 EXPORT_C void CImageEncoderPlugin::WriteExifDataL(TRequestStatus*& /*aScaleCompletionStatus*/)
       
  1328 	{
       
  1329 	SelfComplete(KErrNone);
       
  1330 	}
       
  1331 
       
  1332 /**
       
  1333 @publishedPartner
       
  1334 @released
       
  1335 
       
  1336 Enables getting set of options which has been passed by client during encoder object creation.
       
  1337 Plugins should ignore unknown options.
       
  1338 
       
  1339 @return Set of options which has been passed by client during encoder 
       
  1340 		object creation
       
  1341 */
       
  1342 EXPORT_C CImageEncoder::TOptions CImageEncoderPlugin::EncoderOptions() const
       
  1343 	{
       
  1344 	return iProperties->EncoderOptions();
       
  1345 	}
       
  1346 
       
  1347 /**
       
  1348 @internalComponent
       
  1349 
       
  1350 Intended for future proofing - will panic if called.
       
  1351 
       
  1352 @panic  EReservedCall
       
  1353 */
       
  1354 EXPORT_C void CImageEncoderPlugin::ReservedVirtual1()
       
  1355 	{
       
  1356 	Panic(EReservedCall);
       
  1357 	}
       
  1358 
       
  1359 /**
       
  1360 @internalComponent
       
  1361 
       
  1362 Intended for future proofing - will panic if called.
       
  1363 
       
  1364 @panic  EReservedCall
       
  1365 */
       
  1366 EXPORT_C void CImageEncoderPlugin::ReservedVirtual2()
       
  1367 	{
       
  1368 	Panic(EReservedCall);
       
  1369 	}
       
  1370 
       
  1371 /**
       
  1372 @internalComponent
       
  1373 
       
  1374 Intended for future proofing - will panic if called.
       
  1375 
       
  1376 @panic  EReservedCall
       
  1377 */
       
  1378 EXPORT_C void CImageEncoderPlugin::ReservedVirtual3()
       
  1379 	{
       
  1380 	Panic(EReservedCall);
       
  1381 	}
       
  1382 
       
  1383 EXPORT_C void CImageEncoderPlugin::GetExtensionL(TUid /*aExtUid*/, MImageConvExtension*& /*aExtPtr*/)
       
  1384 	{
       
  1385 	User::Leave(KErrNotSupported);
       
  1386 	}
       
  1387