phonebookui/Phonebook2/Presentation/src/CPbk2ImageReader.cpp
branchRCL_3
changeset 63 f4a778e096c2
child 64 c1e8ba0c2b16
equal deleted inserted replaced
62:5b6f26637ad3 63:f4a778e096c2
       
     1 /*
       
     2 * Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
       
     3 * All rights reserved.
       
     4 * This component and the accompanying materials are made available
       
     5 * under the terms of "Eclipse Public License v1.0"
       
     6 * which accompanies this distribution, and is available
       
     7 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     8 *
       
     9 * Initial Contributors:
       
    10 * Nokia Corporation - initial contribution.
       
    11 *
       
    12 * Contributors:
       
    13 *
       
    14 * Description: 
       
    15 *           Provides Phonebook2 image reader class methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include "CPbk2ImageReader.h"
       
    22 
       
    23 // From Phonebook2
       
    24 #include "MPbk2ImageReaderObserver.h"
       
    25 #include "TPbk2ImageManagerParams.h"
       
    26 #include "Pbk2PresentationUtils.h"
       
    27 
       
    28 // From Virtual Phonebook
       
    29 
       
    30 // From System
       
    31 #include <imageconversion.h>
       
    32 #include <bitmaptransforms.h>
       
    33 #include <JP2KUids.hrh>
       
    34 #include <aknnotewrappers.h>
       
    35 #include <StringLoader.h>
       
    36 #include <AknIconUtils.h>
       
    37 
       
    38 /// Unnamed namespace for local defintions
       
    39 namespace {
       
    40 
       
    41 // ============== LOCAL CONSTANTS AND MACROS ===============
       
    42 
       
    43 enum TReaderState
       
    44     {
       
    45     EStateIntialize = 0,
       
    46     EStateOpenImage,
       
    47     EStateConvertImageToBitmap,
       
    48     EStateScaleBitmap,
       
    49     EStateComplete,
       
    50     EStateCancelled
       
    51     };
       
    52 
       
    53 // Definition for max mime type length
       
    54 const TInt KMaxMimeTypeLength(256);
       
    55 
       
    56 #ifdef _DEBUG
       
    57 enum TPanicCode
       
    58     {
       
    59     EPanicPreCond_ConvertImageToBitmapL = 1,
       
    60     EPanicPreCond_ScaleBitmapL,
       
    61     EPanicPreCond_Complete,
       
    62     EPanicPostCond_Complete,
       
    63     EPanicPostCond_OptimalLoadingSize
       
    64     };
       
    65 #endif // _DEBUG
       
    66 
       
    67 
       
    68 // ==================== LOCAL FUNCTIONS ====================
       
    69 
       
    70 #ifdef _DEBUG
       
    71 void Panic(TPanicCode aPanicCode)
       
    72     {
       
    73     _LIT(KPanicText, "CPbk2ImageReader");
       
    74     User::Panic(KPanicText, aPanicCode);
       
    75     }
       
    76 #endif  // _DEBUG
       
    77 
       
    78 // --------------------------------------------------------------------------
       
    79 
       
    80 /**
       
    81  * Comparison operator for TSize objects. Compares width and height members.
       
    82  *
       
    83  * @param aLhs Reference to left hand side TSize
       
    84  * @param aRhs Reference to right hand side TSize
       
    85  * @return ETrue if lhs's width and height are less or equal to rhs's
       
    86  *         width and height. Otherwise returns EFalse.
       
    87  */
       
    88 inline TBool operator<=(const TSize& aLhs, const TSize& aRhs)
       
    89     {
       
    90     return (aLhs.iWidth<=aRhs.iWidth && aLhs.iHeight<=aRhs.iHeight);
       
    91     }
       
    92 
       
    93 /**
       
    94  * Ceils division result based on modulus.
       
    95  *
       
    96  * @param aVal Divident. 
       
    97  * @param aDiv Divider.
       
    98  * @return If modulus is zero, returns the result of aVal / aDiv. Otherwise
       
    99  *         returns returns the result of aVal / aDiv increased by one. 
       
   100  *
       
   101  * NOTE: Copied from CPalbBitmap, remove when possible
       
   102  */
       
   103 TInt Ceil(const TInt aVal, const TInt aDiv)
       
   104     {
       
   105     return (((aVal%aDiv)>0) ? (TInt)((aVal/aDiv)+1):(TInt)(aVal/aDiv));
       
   106     }
       
   107 
       
   108 /**
       
   109  * Calculates the the size based on divider. Uses Ceil function for ceiling
       
   110  * the calculated size.
       
   111  *
       
   112  * @param aSize Orginal size.
       
   113  * @param aDiv Divider.
       
   114  * @return Calculated size. The result's width and height might be adjusted
       
   115  *         according to the results of calling Ceil function.
       
   116  *
       
   117  * @see Ceil
       
   118  *
       
   119  * NOTE: Copied from CPalbBitmap, remove when possible
       
   120  */
       
   121  TSize SizeDividedByValueAndCeil(const TSize& aSize, const TInt aDiv)
       
   122     {
       
   123     return TSize(
       
   124         Ceil( aSize.iWidth, aDiv), 
       
   125         Ceil( aSize.iHeight, aDiv) );
       
   126     }
       
   127 
       
   128 /**
       
   129  * Calculates the optimal loading size. If optimal loading size cannot be
       
   130  * calculated, function panics with 
       
   131  * CPbk2ImageReader:EPanicPostCond_OptimalLoadingSize panic code.
       
   132  *
       
   133  * @param aOriginalSize Orginal size.
       
   134  * @param aNeededSize Needed size.
       
   135  * @return Calculated optimal size.
       
   136  *
       
   137  * @see SizeDividedByValueAndCeil
       
   138  * @see Ceil
       
   139  *
       
   140  * NOTE: Copied from CPalbBitmap, remove when possible
       
   141  */
       
   142 TSize OptimalLoadingSize(const TSize& aOriginalSize, const TSize& aNeededSize)
       
   143     {
       
   144     TSize resSize = SizeDividedByValueAndCeil( aOriginalSize, 8 );
       
   145     if( !(aNeededSize <= resSize) )
       
   146         {
       
   147         resSize = SizeDividedByValueAndCeil( aOriginalSize, 4 );
       
   148         if( !(aNeededSize <= resSize) )
       
   149             {
       
   150             resSize = SizeDividedByValueAndCeil( aOriginalSize, 2 );
       
   151             if( !(aNeededSize <= resSize) )
       
   152                 {
       
   153                 resSize = aOriginalSize;
       
   154                 }
       
   155             }
       
   156         }
       
   157 
       
   158     // if the resulting size is not the original size,
       
   159     // it has to be between needed size and original size
       
   160     __ASSERT_DEBUG(resSize == aOriginalSize
       
   161                    || (aNeededSize <= resSize && resSize <= aOriginalSize),
       
   162                    Panic(EPanicPostCond_OptimalLoadingSize));
       
   163 
       
   164     return resSize;
       
   165     }
       
   166 }  // namespace
       
   167 
       
   168 
       
   169 // ================= MEMBER FUNCTIONS =======================
       
   170 
       
   171 // --------------------------------------------------------------------------
       
   172 // CPbk2ImageReader::CPbk2ImageReader
       
   173 // --------------------------------------------------------------------------
       
   174 //
       
   175 inline CPbk2ImageReader::CPbk2ImageReader
       
   176         (MPbk2ImageReaderObserver& aObserver) :
       
   177     CActive(CActive::EPriorityStandard),
       
   178     iObserver(aObserver)
       
   179     {
       
   180     CActiveScheduler::Add(this);
       
   181     }
       
   182 
       
   183 // --------------------------------------------------------------------------
       
   184 // CPbk2ImageReader::~CPbk2ImageReader
       
   185 // --------------------------------------------------------------------------
       
   186 //
       
   187 CPbk2ImageReader::~CPbk2ImageReader()
       
   188     {
       
   189     Cancel();
       
   190     delete iBitmapScaler;
       
   191     delete iImageDecoder;
       
   192     delete iMimeString;
       
   193     delete iBitmap;
       
   194     iFsSession.Close();
       
   195     }
       
   196     
       
   197 // --------------------------------------------------------------------------
       
   198 // CPbk2ImageReader::NewL
       
   199 // --------------------------------------------------------------------------
       
   200 //
       
   201 CPbk2ImageReader* CPbk2ImageReader::NewL
       
   202         (MPbk2ImageReaderObserver& aObserver)
       
   203     {
       
   204     CPbk2ImageReader* self = new(ELeave) CPbk2ImageReader(aObserver);
       
   205     CleanupStack::PushL(self);
       
   206     self->ConstructL();
       
   207     CleanupStack::Pop(self);
       
   208     return self;
       
   209     }
       
   210 
       
   211 // --------------------------------------------------------------------------
       
   212 // CPbk2ImageReader::ConstructL
       
   213 // --------------------------------------------------------------------------
       
   214 //
       
   215 void CPbk2ImageReader::ConstructL()
       
   216     {
       
   217     User::LeaveIfError(iFsSession.Connect());
       
   218     }
       
   219 
       
   220 // --------------------------------------------------------------------------
       
   221 // CPbk2ImageReader::ReadFromFileL
       
   222 // --------------------------------------------------------------------------
       
   223 //
       
   224 void CPbk2ImageReader::ReadFromFileL
       
   225         (const TDesC& aFileName, const TPbk2ImageManagerParams* aParams)
       
   226     {
       
   227     InitReadL(aParams);
       
   228     delete iImageDecoder;
       
   229     iImageDecoder = NULL;
       
   230                
       
   231     TRAPD( err, iImageDecoder = CImageDecoder::FileNewL( iFsSession, aFileName ) );
       
   232 
       
   233     // Make the open phase asynchronous as well by signaling own iStatus
       
   234     iState = EStateOpenImage;
       
   235     TRequestStatus* status = &iStatus;
       
   236     User::RequestComplete( status, err );            
       
   237     SetActive();
       
   238     }
       
   239 
       
   240 // --------------------------------------------------------------------------
       
   241 // CPbk2ImageReader::ReadFromBufferL
       
   242 // --------------------------------------------------------------------------
       
   243 //
       
   244 void CPbk2ImageReader::ReadFromBufferL
       
   245         (const TDesC8& aBuffer, const TPbk2ImageManagerParams* aParams/*=NULL*/)
       
   246     {
       
   247     InitReadL(aParams);
       
   248     delete iImageDecoder;
       
   249     iImageDecoder = NULL;
       
   250     TRAPD( err, iImageDecoder = CImageDecoder::DataNewL( iFsSession, aBuffer ) );
       
   251     
       
   252     // Make the open phase asynchronous as well by signaling own iStatus
       
   253     iState = EStateOpenImage;
       
   254     TRequestStatus* status = &iStatus;
       
   255     User::RequestComplete( status, err );
       
   256     SetActive();
       
   257     }
       
   258 
       
   259 // --------------------------------------------------------------------------
       
   260 // CPbk2ImageReader::MimeString
       
   261 // --------------------------------------------------------------------------
       
   262 //
       
   263 const TDesC8& CPbk2ImageReader::MimeString() const
       
   264     {
       
   265     if (iMimeString)
       
   266         {
       
   267         return *iMimeString;
       
   268         }
       
   269     else
       
   270         {
       
   271         return KNullDesC8;
       
   272         }
       
   273     }
       
   274 
       
   275 // --------------------------------------------------------------------------
       
   276 // CPbk2ImageReader::RecognizeFormatFromFileL
       
   277 // --------------------------------------------------------------------------
       
   278 //
       
   279 void CPbk2ImageReader::RecognizeFormatFromFileL(const TDesC& aFileName)
       
   280     {
       
   281     delete iMimeString;
       
   282     iMimeString = NULL;
       
   283     iMimeString = HBufC8::NewL(KMaxMimeTypeLength);
       
   284     TPtr8 mimePtr = iMimeString->Des();
       
   285     
       
   286     TRAPD( err, CImageDecoder::GetMimeTypeFileL( iFsSession, aFileName, mimePtr ) );
       
   287     	    
       
   288     if( err != KErrNone )
       
   289         {
       
   290         iObserver.ImageReadFailed( *this, err );           
       
   291         }    
       
   292     }
       
   293 
       
   294 // --------------------------------------------------------------------------
       
   295 // CPbk2ImageReader::RecognizeFormatFromBufferL
       
   296 // --------------------------------------------------------------------------
       
   297 //
       
   298 void CPbk2ImageReader::RecognizeFormatFromBufferL(const TDesC8& aBuffer)
       
   299     {
       
   300     delete iMimeString;
       
   301     iMimeString = NULL;
       
   302     iMimeString = HBufC8::NewL(KMaxMimeTypeLength);
       
   303     TPtr8 mimePtr = iMimeString->Des();
       
   304     TRAPD( err, CImageDecoder::GetMimeTypeDataL( aBuffer, mimePtr ) );
       
   305         
       
   306     if( err != KErrNone )
       
   307         {
       
   308         iObserver.ImageReadFailed( *this, err );           
       
   309         }    
       
   310     }
       
   311 
       
   312 // --------------------------------------------------------------------------
       
   313 // CPbk2ImageReader::FrameInfo
       
   314 // --------------------------------------------------------------------------
       
   315 //
       
   316 void CPbk2ImageReader::FrameInfo(TInt aFrame, TFrameInfo& aInfo) const
       
   317     {
       
   318     aInfo = iImageDecoder->FrameInfo(aFrame);
       
   319     }
       
   320 
       
   321 // --------------------------------------------------------------------------
       
   322 // CPbk2ImageReader::FrameCount
       
   323 // --------------------------------------------------------------------------
       
   324 //
       
   325 TInt CPbk2ImageReader::FrameCount() const
       
   326     {
       
   327     return iImageDecoder->FrameCount();
       
   328     }
       
   329 
       
   330 // --------------------------------------------------------------------------
       
   331 // CPbk2ImageReader::NextStateL
       
   332 // --------------------------------------------------------------------------
       
   333 //
       
   334 void CPbk2ImageReader::NextStateL()
       
   335     {
       
   336     ++iState;
       
   337 
       
   338     switch (iState)
       
   339         {
       
   340         case EStateConvertImageToBitmap:
       
   341             {
       
   342             ConvertImageToBitmapL();
       
   343             break;
       
   344             }
       
   345         case EStateScaleBitmap:
       
   346             {
       
   347             CropImageToSquareL();
       
   348             ScaleBitmapL();
       
   349             break;
       
   350             }
       
   351         case EStateComplete:
       
   352             {
       
   353             Complete();
       
   354             break;
       
   355             }
       
   356         default:
       
   357             {
       
   358             // iImageReader might sometimes complete although it has been canceled.
       
   359             // Catch those cases here.
       
   360             break;
       
   361             }
       
   362         }
       
   363     }
       
   364 
       
   365 // --------------------------------------------------------------------------
       
   366 // CPbk2ImageReader::ConvertImageToBitmapL
       
   367 // --------------------------------------------------------------------------
       
   368 //
       
   369 void CPbk2ImageReader::ConvertImageToBitmapL()
       
   370     {
       
   371     __ASSERT_DEBUG(iImageDecoder && !iBitmap, 
       
   372         Panic(EPanicPreCond_ConvertImageToBitmapL));
       
   373 
       
   374     // Get image size
       
   375     const TFrameInfo& frameInfo = 
       
   376         iImageDecoder->FrameInfo(iParams.iFrameNumber);
       
   377     TSize bitmapSize = frameInfo.iOverallSizeInPixels;
       
   378     if (iParams.iFlags & TPbk2ImageManagerParams::EScaleImage)
       
   379         {
       
   380         // Get optimal loading size >= desired size
       
   381         bitmapSize = OptimalLoadingSize(bitmapSize,iParams.iSize);
       
   382         }
       
   383 
       
   384     // Create bitmap
       
   385     delete iBitmap;
       
   386 	iBitmap = NULL;
       
   387     iBitmap = new(ELeave) CFbsBitmap;
       
   388     User::LeaveIfError(iBitmap->Create(bitmapSize, iParams.iDisplayMode));
       
   389 
       
   390     // Convert image to bitmap
       
   391     iImageDecoder->Convert(&iStatus, *iBitmap, iParams.iFrameNumber);
       
   392     SetActive();
       
   393     }
       
   394 
       
   395 // --------------------------------------------------------------------------
       
   396 // CPbk2ImageReader::CropImageToSquareL
       
   397 // --------------------------------------------------------------------------
       
   398 //
       
   399 void CPbk2ImageReader::CropImageToSquareL()
       
   400 	{
       
   401 	// if cropping is wanted
       
   402 	if( iParams.iFlags & TPbk2ImageManagerParams::ECropImage )	
       
   403 		{
       
   404         Pbk2PresentationImageUtils::CropImageL( 
       
   405                 *iBitmap, 
       
   406                 Pbk2PresentationImageUtils::EOptimizedCropping, 
       
   407                 iParams.iSize );
       
   408 		}
       
   409 	}
       
   410 
       
   411 // --------------------------------------------------------------------------
       
   412 // CPbk2ImageReader::ScaleBitmapL
       
   413 // --------------------------------------------------------------------------
       
   414 //
       
   415 void CPbk2ImageReader::ScaleBitmapL()
       
   416     {
       
   417     __ASSERT_DEBUG(iBitmap, Panic(EPanicPreCond_ScaleBitmapL));
       
   418 
       
   419     const TSize bitmapSize = iBitmap->SizeInPixels();
       
   420     if ((iParams.iFlags & TPbk2ImageManagerParams::EScaleImage) && 
       
   421          !(iParams.iFlags & TPbk2ImageManagerParams::EUseFastScaling) &&
       
   422          (iParams.iFlags & TPbk2ImageManagerParams::EUseSpeedOptimizedScaling) &&
       
   423          ( bitmapSize.iHeight == bitmapSize.iWidth ) )
       
   424         {
       
   425         if( bitmapSize.iWidth > iParams.iSize.iWidth || 
       
   426             bitmapSize.iHeight > iParams.iSize.iHeight )
       
   427             {
       
   428             // Use avkon scaler
       
   429             TRect targetRect(TPoint(0,0), 
       
   430                     TSize( ( iParams.iSize.iWidth ), 
       
   431                            ( iParams.iSize.iHeight ) ) );
       
   432             
       
   433             CFbsBitmap* target = new( ELeave ) CFbsBitmap;
       
   434             CleanupStack::PushL( target );
       
   435             User::LeaveIfError( target->Create( 
       
   436                     targetRect.Size(), iBitmap->DisplayMode() ) );
       
   437             
       
   438             AknIconUtils::ScaleBitmapL( targetRect, target, iBitmap );
       
   439             
       
   440             iBitmap->Reset();
       
   441             User::LeaveIfError( iBitmap->Duplicate( target->Handle() ) );
       
   442             CleanupStack::PopAndDestroy( target );
       
   443             
       
   444             NextStateL();
       
   445             return;
       
   446             }
       
   447         }
       
   448     else if ((iParams.iFlags & TPbk2ImageManagerParams::EScaleImage) && 
       
   449              !(iParams.iFlags & TPbk2ImageManagerParams::EUseFastScaling) )
       
   450         {
       
   451         if (bitmapSize.iWidth > iParams.iSize.iWidth || 
       
   452             bitmapSize.iHeight > iParams.iSize.iHeight)
       
   453             {
       
   454             if (!iBitmapScaler)
       
   455                 {
       
   456                 iBitmapScaler = CBitmapScaler::NewL();
       
   457                 }
       
   458             iBitmapScaler->Scale(&iStatus, *iBitmap, iParams.iSize);
       
   459             SetActive();
       
   460             return;
       
   461             }
       
   462         }
       
   463     
       
   464     // No scaling requested or needed, go directly to next state
       
   465     NextStateL();
       
   466     }
       
   467 
       
   468 // --------------------------------------------------------------------------
       
   469 // CPbk2ImageReader::Complete
       
   470 // --------------------------------------------------------------------------
       
   471 //
       
   472 void CPbk2ImageReader::Complete()
       
   473     {
       
   474     __ASSERT_DEBUG(iImageDecoder && iBitmap, Panic(EPanicPreCond_Complete));
       
   475 
       
   476     // End state machine
       
   477     ++iState;
       
   478 
       
   479     // Close the image source
       
   480     CloseImage();
       
   481 
       
   482     // Release ownership of iBitmap
       
   483     CFbsBitmap* bitmap = iBitmap;
       
   484     iBitmap = NULL;
       
   485 
       
   486     __ASSERT_DEBUG(!iImageDecoder && !iBitmap, 
       
   487         Panic(EPanicPostCond_Complete));
       
   488 
       
   489     // Notify observer about completion
       
   490     iObserver.ImageReadComplete(*this,bitmap);
       
   491     }
       
   492 
       
   493 // --------------------------------------------------------------------------
       
   494 // CPbk2ImageReader::InitReadL
       
   495 // --------------------------------------------------------------------------
       
   496 //
       
   497 void CPbk2ImageReader::InitReadL(const TPbk2ImageManagerParams* aParams)
       
   498     {
       
   499     Cancel();
       
   500     if (aParams)
       
   501         {
       
   502         iParams = *aParams;
       
   503         }
       
   504     iState = EStateOpenImage;
       
   505     }
       
   506 
       
   507 // --------------------------------------------------------------------------
       
   508 // CPbk2ImageReader::CloseImage
       
   509 // --------------------------------------------------------------------------
       
   510 //
       
   511 void CPbk2ImageReader::CloseImage()
       
   512     {
       
   513     delete iImageDecoder;
       
   514     iImageDecoder = NULL;
       
   515     }
       
   516 
       
   517 // --------------------------------------------------------------------------
       
   518 // CPbk2ImageReader::RunL
       
   519 // --------------------------------------------------------------------------
       
   520 //
       
   521 void CPbk2ImageReader::RunL()
       
   522     {
       
   523     TInt status = iStatus.Int();
       
   524         
       
   525     switch (status)
       
   526         {
       
   527         case KErrNone:
       
   528             {
       
   529             if (iState == EStateOpenImage)
       
   530                 {
       
   531                 iObserver.ImageOpenComplete(*this);
       
   532                 }
       
   533             NextStateL();
       
   534             break;
       
   535             }
       
   536         case KErrCancel:
       
   537             {
       
   538             // In case of cancel the observer is not signaled
       
   539             break;
       
   540             }
       
   541         default:
       
   542             {                              
       
   543             // Jpeg2000 decoder might need more heap than Phonebook can 
       
   544             // provide, the situation is handled so, that "Feature not 
       
   545             // supported" -note is shown if memory runs out when decoding 
       
   546             // Jpeg2000 image instead of "Out of memory" -note.
       
   547             //
       
   548             // Small jp2 images (e.g. 50*50 pixels) can be decoded, but
       
   549             // heap runs out when decoding e.g. 1 mega pixel image. 
       
   550             //
       
   551             // Increasing phonebook heap size doesn't help on this issue,
       
   552             // since jp2 decoder heap usage is increased linearly when a bigger
       
   553             // image is tried to be decoded.
       
   554             if ( status == KErrNoMemory )            
       
   555                 {
       
   556                 
       
   557                 TUid imageType;
       
   558                 TUid imageSubType;
       
   559                 iImageDecoder->ImageType(iParams.iFrameNumber, 
       
   560                                          imageType, 
       
   561                                          imageSubType);
       
   562 
       
   563                 if ( imageType.iUid == KImageTypeJ2KUid )
       
   564                     {
       
   565                     status = KErrNotSupported;
       
   566                     }
       
   567                 }                   
       
   568             
       
   569             iObserver.ImageReadFailed(*this, status);
       
   570             break;
       
   571             }
       
   572         }
       
   573     }
       
   574 
       
   575 // --------------------------------------------------------------------------
       
   576 // CPbk2ImageReader::Cancel
       
   577 // --------------------------------------------------------------------------
       
   578 //
       
   579 void CPbk2ImageReader::Cancel()
       
   580     {
       
   581     if (!IsActive())
       
   582         {
       
   583         DoCancel();
       
   584         }
       
   585     else
       
   586         {
       
   587         CActive::Cancel();
       
   588         }
       
   589     }
       
   590 
       
   591 // --------------------------------------------------------------------------
       
   592 // CPbk2ImageReader::RunError
       
   593 // --------------------------------------------------------------------------
       
   594 //
       
   595 TInt CPbk2ImageReader::RunError(TInt aError)
       
   596     {
       
   597     iObserver.ImageReadFailed(*this, aError);
       
   598     return KErrNone;
       
   599     }
       
   600 
       
   601 // --------------------------------------------------------------------------
       
   602 // CPbk2ImageReader::DoCancel
       
   603 // --------------------------------------------------------------------------
       
   604 //
       
   605 void CPbk2ImageReader::DoCancel()
       
   606     {
       
   607     if (iImageDecoder)
       
   608         {
       
   609         iImageDecoder->Cancel();
       
   610         }
       
   611     if (iBitmapScaler)
       
   612         {
       
   613         iBitmapScaler->Cancel();
       
   614         }
       
   615     CloseImage();
       
   616     delete iBitmap;
       
   617     iBitmap = NULL;
       
   618     iState = EStateCancelled;
       
   619     }
       
   620 
       
   621 //  End of File