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