mpxmusicplayer/commonui/inc/mpximageutil.h
changeset 0 ff3acec5bc43
equal deleted inserted replaced
-1:000000000000 0:ff3acec5bc43
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Class declaration of CMPXImageUtil.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef CMPXIMAGEUTIL_H
       
    20 #define CMPXIMAGEUTIL_H
       
    21 
       
    22 //  INCLUDES
       
    23 
       
    24 #include "mpxalbumartutilobserver.h"
       
    25 
       
    26 
       
    27 // FORWARD DECLARATIONS
       
    28 class CFbsBitmap;
       
    29 class CBitmapScaler;
       
    30 class CImageDecoder;
       
    31 
       
    32 // CLASS DECLARATION
       
    33 
       
    34 /**
       
    35 *  Image Conversion Class.
       
    36 **/
       
    37 class CMPXImageUtil : public CActive
       
    38     {
       
    39 public:
       
    40    
       
    41 	// states for this engine
       
    42   	enum TState 
       
    43 	    {
       
    44 	    EIdle = 0,
       
    45 	    EDecoding,
       
    46 	    EScaling
       
    47 	    };
       
    48 
       
    49 public:  // Constructors and destructor
       
    50         
       
    51     /**
       
    52     * Two-phased constructor.
       
    53     * @param aObserver ablum art observer
       
    54     * @return A pointer to a newly created object
       
    55     */
       
    56     static CMPXImageUtil* NewL(MMPXAlbumArtUtilObserver& aObserver);
       
    57 
       
    58     /**
       
    59     * Destructor.
       
    60     */
       
    61     ~CMPXImageUtil();
       
    62 
       
    63 private:
       
    64 
       
    65     /**
       
    66     * C++ default constructor.
       
    67     */
       
    68     CMPXImageUtil(MMPXAlbumArtUtilObserver& aObserver); 
       
    69 
       
    70     /**
       
    71     * By default Symbian 2nd phase constructor is private.
       
    72     */
       
    73     void ConstructL();  
       
    74 
       
    75 public: // New functions
       
    76         
       
    77     /*
       
    78     * Starts to decode an image from a file. 
       
    79     * @param aFileName Full path and filename of the image to be decoded.
       
    80     * @param aSize The size of the required destination BMP.
       
    81     * @param aDisplayMode the display mode of the destination BMP
       
    82     */
       
    83     void StartToDecodeL(const TDesC& aFileName, 
       
    84                         const TSize& aSize, 
       
    85                         TDisplayMode aDisplayMode = EColor64K);
       
    86   
       
    87     /*
       
    88     * Starts to decode an image from JPG buffer
       
    89     * @param aSize The size of the required destination JPG
       
    90     * @param aAlbumArt The pointer to the JPG buffer
       
    91     * @param aDisplayMode the display mode of the destination JPG
       
    92     */
       
    93     void StartToDecodeL(const TSize& aSize, 
       
    94                         HBufC8* aAlbumArt, 
       
    95                         TDisplayMode aDisplayMode = EColor64K);
       
    96 
       
    97     /*
       
    98     * Cancel outstanding asynch requests
       
    99     */
       
   100     void CancelRequest();
       
   101     
       
   102 private: // New functions
       
   103 
       
   104     /**
       
   105     * Scales iBitmap to iSize 
       
   106     **/
       
   107     void ScaleL();
       
   108     TSize CalculateDecodeSize(const TSize& aSize);
       
   109 
       
   110 private: // Functions from base classes
       
   111 
       
   112     /**
       
   113     * Cancellation of an outstanding request.
       
   114     */
       
   115     void DoCancel();
       
   116 
       
   117     /**
       
   118     * Handles an active object’s request completion event.
       
   119     */
       
   120     void RunL();
       
   121       
       
   122 private:    // Data
       
   123 
       
   124     MMPXAlbumArtUtilObserver&       iObserver;      // Album art util observer
       
   125     CFbsBitmap*                     iBitmap;        // decoded image
       
   126     CImageDecoder*                  iImageDecoder;  // decoder
       
   127     CBitmapScaler*                  iScaler;        // bitmap scaler
       
   128     TSize                           iSize;          // desired size of the bitmap
       
   129     TState                          iState;         // engine state
       
   130     RFs                             iFs;            // for opening/saving images from/to files
       
   131     HBufC8*                         iImageData;     // Album art image data (owned)
       
   132     TBool                           iScaleRquired;
       
   133     };
       
   134 
       
   135 #endif // CMPXIMAGEUTIL_H   
       
   136             
       
   137 // End of File