phonebookui/Phonebook2/ccapplication/ccapp/ccapputil/inc/ccappimagedecoding.h
branchRCL_3
changeset 3 04ab22b956c2
equal deleted inserted replaced
0:e686773b3f54 3:04ab22b956c2
       
     1 /*
       
     2 * Copyright (c) 2008-2010 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 #ifndef CCAPPIMAGEDECODING_H_
       
    20 #define CCAPPIMAGEDECODING_H_
       
    21 
       
    22 #include <e32base.h>
       
    23 
       
    24 class CBitmapScaler;
       
    25 class CImageDecoder;
       
    26 class CFbsBitmap;
       
    27 class RFs;
       
    28 
       
    29 class MCCAppImageDecodingObserver
       
    30 	{
       
    31 public:
       
    32 	/**
       
    33 	 * Bitmap is decoded.
       
    34 	 * @param aBitmap Decoded bitmap, ownership is transferred.
       
    35 	 */ 
       
    36 	virtual void BitmapReadyL( CFbsBitmap* aBitmap ) = 0;
       
    37 
       
    38 protected:
       
    39 	MCCAppImageDecodingObserver() {};
       
    40 	virtual ~MCCAppImageDecodingObserver() {};
       
    41 	};
       
    42 
       
    43 
       
    44 /**
       
    45  * Utility class for asynchronously decoding the header thumbnail image
       
    46  *
       
    47  *  @code
       
    48  *   ?good_class_usage_example(s)
       
    49  *  @endcode
       
    50  *
       
    51  *  @lib ccapputil.dll
       
    52  *  @since S60 v9.2
       
    53  */
       
    54 NONSHARABLE_CLASS( CCCAppImageDecoding ) : public CActive
       
    55     {
       
    56 public:
       
    57     /**
       
    58      * Two-phased constructor
       
    59      * 
       
    60      * @param aObserver 
       
    61      * @param aBitmapData Descriptor containing the bitmap data stream, takes ownership
       
    62      * @param aImageFile Descriptor containing image file name full path, takes ownership
       
    63      */
       
    64     IMPORT_C static CCCAppImageDecoding* NewL(
       
    65             MCCAppImageDecodingObserver& aObserver,
       
    66             RFs& aFs,
       
    67             HBufC8* aBitmapData, 
       
    68             HBufC* aImageFile );
       
    69     
       
    70     /**
       
    71      * Destructor
       
    72      */
       
    73     ~CCCAppImageDecoding();
       
    74     
       
    75     /**
       
    76      * Starts the decoding process
       
    77      * 
       
    78      * @param aImageSize defines image size
       
    79      */
       
    80     IMPORT_C void StartL( const TSize& aImageSize );
       
    81 
       
    82 private:
       
    83     /**
       
    84      * From CActive
       
    85      * (see details from baseclass )
       
    86      */
       
    87     void RunL();
       
    88     
       
    89     /**
       
    90      * From CActive
       
    91      * (see details from baseclass )
       
    92      */
       
    93     void DoCancel();
       
    94 private:
       
    95     /**
       
    96      * First-phase (C++) constructor
       
    97      */
       
    98     inline CCCAppImageDecoding(
       
    99             MCCAppImageDecodingObserver& aObserver,
       
   100             RFs& aFs,
       
   101             HBufC8* aBitmapData, 
       
   102             HBufC* aImageFile);
       
   103     
       
   104     /**
       
   105      * Second phase constructor
       
   106      */
       
   107     inline void ConstructL();
       
   108     
       
   109     /**
       
   110      * Scales bitmap
       
   111      *
       
   112      */
       
   113     void ScaleBitmapL();
       
   114 
       
   115     void CropBitmapL();
       
   116     
       
   117     /**
       
   118      * Create bitmap
       
   119      *
       
   120      */
       
   121     void CreateBitmapL();
       
   122     
       
   123     enum TCcaImageDecoderState
       
   124         {
       
   125         ECcaConvertThumbnailImage = 1,
       
   126         ECcaScaleThumbnail,
       
   127         ECcaReadImageFromFile,
       
   128         ECcaConvertImageFromFile,
       
   129         ECcaScaleImage
       
   130         };
       
   131     
       
   132     /**
       
   133      * The image scaler whose service is called to scale the image
       
   134      * Own.
       
   135      */
       
   136     CBitmapScaler* iBitmapScaler;
       
   137     
       
   138     /**
       
   139      * The image decoder whose service is called to decode the image
       
   140      * Own.
       
   141      */
       
   142     CImageDecoder* iImgDecoder;
       
   143     
       
   144     MCCAppImageDecodingObserver& iObserver;
       
   145     
       
   146     /**
       
   147      * Handle to the file server session for loading the bitmap
       
   148      */ 
       
   149     RFs& iFs;
       
   150     
       
   151     /**
       
   152      * The bitmap.
       
   153      * Owned until decoding is complete, then ownersip is transferred to header control.
       
   154      */
       
   155     CFbsBitmap* iBitmap; // owned until completion
       
   156     
       
   157     /**
       
   158      * Own.
       
   159      */
       
   160     HBufC8* iBitmapData;
       
   161 
       
   162     /**
       
   163      * Own.
       
   164      */
       
   165     HBufC* iImageFullName;
       
   166     
       
   167     /** 
       
   168       * Contact bitmap size 
       
   169       */ 
       
   170     TSize iBitmapSize;
       
   171     
       
   172     /** 
       
   173       * Decoder internal state
       
   174       */ 
       
   175     TInt iDecoderState;
       
   176     
       
   177     /** 
       
   178       * Timer used to delay image conversion
       
   179       */ 
       
   180     RTimer iTimer;
       
   181     };
       
   182 
       
   183 #endif /*CCAPPIMAGEDECODING_H_*/