uiservicetab/vimpstdetailsviewplugin/src/cvimpstdetailsimagedecoder.cpp
changeset 0 5e5d6b214f4f
child 3 3aab497fdbb7
equal deleted inserted replaced
-1:000000000000 0:5e5d6b214f4f
       
     1 /*
       
     2 * Copyright (c) 2008 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:  Utility class for asynchronously decoding the header thumbnail image
       
    15  *
       
    16 */
       
    17 
       
    18  
       
    19 #include "cvimpstdetailsimagedecoder.h"
       
    20 
       
    21 #include "cvimpstdetailsheadercontrol.h"
       
    22 
       
    23 #include <cbsbitmap.h>
       
    24 #include <imageconversion.h> 
       
    25 
       
    26 // ---------------------------------------------------------------------------
       
    27 // CVIMPSTDetailsImageDecoder::NewL
       
    28 // Two-phase construction
       
    29 // ---------------------------------------------------------------------------
       
    30 //
       
    31 CVIMPSTDetailsImageDecoder* CVIMPSTDetailsImageDecoder::NewL(CVIMPSTDetailsHeaderControl& aHeader, const TDesC8& aBitmapData)
       
    32     {
       
    33     CVIMPSTDetailsImageDecoder* self = new (ELeave) CVIMPSTDetailsImageDecoder(aHeader);
       
    34     CleanupStack::PushL(self);
       
    35     self->ConstructL(aBitmapData);
       
    36     CleanupStack::Pop(self);
       
    37     return self;
       
    38     }
       
    39 
       
    40 // ---------------------------------------------------------------------------
       
    41 // CVIMPSTDetailsImageDecoder::CVIMPSTDetailsImageDecoder
       
    42 // First phase (C++) constructor
       
    43 // ---------------------------------------------------------------------------
       
    44 //
       
    45 CVIMPSTDetailsImageDecoder::CVIMPSTDetailsImageDecoder(CVIMPSTDetailsHeaderControl& aHeader) : 
       
    46 	CActive( CActive::EPriorityStandard ), iHeader(aHeader)
       
    47     { 
       
    48     CActiveScheduler::Add(this); 
       
    49     }
       
    50 
       
    51 // ---------------------------------------------------------------------------
       
    52 // CVIMPSTDetailsImageDecoder::ConstructL
       
    53 // ConstructL, second phase constructor
       
    54 // ---------------------------------------------------------------------------
       
    55 //
       
    56 void CVIMPSTDetailsImageDecoder::ConstructL(const TDesC8& aBitmapData)
       
    57     {
       
    58     iBitmapData = aBitmapData.AllocL();
       
    59     User::LeaveIfError( iFs.Connect() );
       
    60     iImgDecoder = CImageDecoder::DataNewL( iFs, *iBitmapData );
       
    61     TFrameInfo info = iImgDecoder->FrameInfo();
       
    62     iBitmap = new ( ELeave ) CFbsBitmap;
       
    63     User::LeaveIfError( iBitmap->Create( info.iOverallSizeInPixels, info.iFrameDisplayMode ));
       
    64     }
       
    65 
       
    66 // ---------------------------------------------------------------------------
       
    67 // CVIMPSTDetailsImageDecoder::~CVIMPSTDetailsImageDecoder
       
    68 // ---------------------------------------------------------------------------
       
    69 //
       
    70 CVIMPSTDetailsImageDecoder::~CVIMPSTDetailsImageDecoder()
       
    71     {
       
    72     DoCancel();
       
    73     if (iImgDecoder)
       
    74         {
       
    75         delete iImgDecoder;
       
    76         iImgDecoder = NULL;
       
    77         }
       
    78     if (iBitmap)
       
    79         {
       
    80         delete iBitmap;
       
    81         iBitmap = NULL;
       
    82         }
       
    83     if (iBitmapData)
       
    84         {
       
    85         delete iBitmapData;
       
    86         iBitmapData = NULL;
       
    87         }
       
    88     iFs.Close();
       
    89     }
       
    90 
       
    91 // ---------------------------------------------------------------------------
       
    92 // CVIMPSTDetailsImageDecoder::Start
       
    93 // Starts the decoding process
       
    94 // ---------------------------------------------------------------------------
       
    95 //
       
    96 void CVIMPSTDetailsImageDecoder::Start()
       
    97     {
       
    98     iStatus = KRequestPending;
       
    99     iImgDecoder->Convert( &iStatus, *iBitmap );
       
   100     SetActive();
       
   101     }
       
   102 
       
   103 // ---------------------------------------------------------------------------
       
   104 // CVIMPSTDetailsImageDecoder::RunL
       
   105 // Called by the active object framework when the decoding (request) is
       
   106 // completed.
       
   107 // ---------------------------------------------------------------------------
       
   108 //
       
   109 void CVIMPSTDetailsImageDecoder::RunL() 
       
   110 	{
       
   111 	User::LeaveIfError( iStatus.Int() );
       
   112 	// Ownership of the bitmap is transferred
       
   113 	iHeader.SetBitmap(iBitmap, NULL );
       
   114 	iBitmap = NULL;
       
   115    }
       
   116 
       
   117 // ---------------------------------------------------------------------------
       
   118 // CVIMPSTDetailsImageDecoder::DoCancel
       
   119 // Called when the decoding (request) is cancelled for some reason.
       
   120 // ---------------------------------------------------------------------------
       
   121 //
       
   122 void CVIMPSTDetailsImageDecoder::DoCancel()
       
   123     { 
       
   124     iImgDecoder->Cancel(); 
       
   125     }
       
   126 
       
   127 // end of file