widgets/widgetinstaller/inc/IconConverter.h
changeset 0 dd21522fd290
equal deleted inserted replaced
-1:000000000000 0:dd21522fd290
       
     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 the License "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:  Icon convert to convert icon for png to mbm format
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef __ICONCONVERTER_H__
       
    20 #define __ICONCONVERTER_H__
       
    21 
       
    22 // INCLUDES
       
    23 #include <e32std.h>
       
    24 #include <e32base.h>
       
    25 #include <f32file.h>
       
    26 
       
    27 // FORWARD DECLARATION
       
    28 class CFbsBitmap;
       
    29 class CBitmapScaler;
       
    30 class CImageDecoder;
       
    31 
       
    32 namespace SwiUI
       
    33 {
       
    34 class MConverterController;
       
    35 /*
       
    36 * Inherited CActive, performs a asynchronous conversion operation
       
    37 *
       
    38 * @lib WidgetInstallerUI.lib
       
    39 * @since 3.1
       
    40 */
       
    41 class CIconConverter : public CActive
       
    42     {
       
    43     // states for this engine
       
    44     enum TState
       
    45         {
       
    46         EIdle = 0,
       
    47         EDecoding,
       
    48         EConvertingFile,
       
    49         EScalingIcon,
       
    50         EScalingMask,
       
    51         EStoringIcon,
       
    52         EFinalize
       
    53         };
       
    54 
       
    55     public:
       
    56 
       
    57         public: // contructors/destructors
       
    58 
       
    59         /*
       
    60         * NewL
       
    61         *
       
    62         * Create a CIconConverter object and return a pointer to it.
       
    63         *
       
    64         * Params:
       
    65         *      aController Pointer to a MConverterController interface.
       
    66         *      The engine uses NotifyCompletionL callback from this interface
       
    67         *      to notify the controller about completions of coding or
       
    68         *      encoding requests.
       
    69         *
       
    70         * Returns:
       
    71         *       A pointer to the created engine
       
    72         *
       
    73         */
       
    74         static CIconConverter* NewL( MConverterController* aController , RFs& aFs );
       
    75 
       
    76         /*
       
    77         * ~CIconConverter
       
    78         *
       
    79         * Destructor
       
    80         *
       
    81         */
       
    82         ~CIconConverter();
       
    83 
       
    84     public: // interface methods
       
    85 
       
    86         /*
       
    87         * StartToDecodeL
       
    88         *
       
    89         * Starts to decode an image from a file. When completed calls
       
    90         * NotifyCompletionL, from iController.
       
    91         *
       
    92         * @Params:
       
    93         *       aFileName Full path and filename of the image to be decoded.
       
    94         *
       
    95         * @Returns:
       
    96         *       Nothing
       
    97         */
       
    98         void StartToDecodeL( const TDesC& aInputFileName, const TDesC& aOutputFileName );
       
    99 
       
   100 
       
   101     protected: // implementation of CActive
       
   102 
       
   103         /*
       
   104         * From CActive
       
   105         *
       
   106         * Handle the cancel operation
       
   107         *
       
   108         */
       
   109         void DoCancel();
       
   110 
       
   111         /*
       
   112         * From CActive
       
   113         *
       
   114         * Handle the conversion process
       
   115         *
       
   116         */
       
   117         void RunL();
       
   118 
       
   119         /*
       
   120         * From CActive
       
   121         * Handle the error situations
       
   122         */
       
   123         TInt RunError( TInt aError );
       
   124 
       
   125     private: // internal methods, constructors
       
   126 
       
   127         /*
       
   128         * CIconConverter
       
   129         *
       
   130         * C++ Constructor
       
   131         *
       
   132         */
       
   133         CIconConverter( MConverterController* aController, RFs& aFs );
       
   134 
       
   135         /*
       
   136         * ConstructL
       
   137         *
       
   138         * 2-phase constructor
       
   139         *
       
   140         * @Returns:
       
   141         *       Nothing
       
   142         */
       
   143         void ConstructL();
       
   144 
       
   145         /*
       
   146         * GetTempIconName
       
   147         *
       
   148         * Get temporary icon name
       
   149         *
       
   150         * @Returns:
       
   151         *       Nothing
       
   152         */
       
   153         void GetTempIconName( TInt aIndex, TFileName& aIconName );
       
   154 
       
   155         /*
       
   156         * DoCreateFinalIconL
       
   157         *
       
   158         * Create the final icon
       
   159         *
       
   160         * @Returns:
       
   161         *       Nothing
       
   162         */
       
   163         void DoCreateFinalIconL();
       
   164 
       
   165         /*
       
   166         * DoIconStoreL
       
   167         *
       
   168         * Store icon and mask files
       
   169         *
       
   170         * @Returns:
       
   171         *       Nothing
       
   172         */
       
   173         void DoIconStoreL();
       
   174 
       
   175         /*
       
   176         * ScalerL
       
   177         *
       
   178         * Create bitmap scalar
       
   179         *
       
   180         * @Returns:
       
   181         *       CBitmapScaler
       
   182         */
       
   183         CBitmapScaler& ScalerL();
       
   184 
       
   185         /*
       
   186         * DoScalingL
       
   187         *
       
   188         * Scale
       
   189         *
       
   190         * @Returns:
       
   191         *       Nothing
       
   192         */
       
   193         void DoScalingL( CFbsBitmap& aBitmapSource, CFbsBitmap& aBitmapTarget );
       
   194 
       
   195         /*
       
   196         * DoMaskScalingL
       
   197         *
       
   198         * Scale the mask
       
   199         *
       
   200         * @Returns:
       
   201         *       Nothing
       
   202         */
       
   203         void DoMaskScalingL();
       
   204 
       
   205         /*
       
   206         * DoIconScalingL
       
   207         *
       
   208         * Scale the bitmap
       
   209         *
       
   210         * @Returns:
       
   211         *       Nothing
       
   212         */
       
   213         void DoIconScalingL();
       
   214 
       
   215         /*
       
   216         * DoProcessMaskL
       
   217         *
       
   218         * Process the mask for the bitmap
       
   219         *
       
   220         * @Returns:
       
   221         *       Nothing
       
   222         */
       
   223         void DoProcessMaskL();
       
   224 
       
   225     private: // internal data
       
   226 
       
   227         // The client's pending status
       
   228         TRequestStatus*         iClientStatus;
       
   229         MConverterController*   iController; // ui controller, owned
       
   230         RFs&                     iFs; // for opening/saving images from/to files, not owned
       
   231         CImageDecoder*          iImageDecoder; // decoder from ICL API, owned
       
   232         HBufC*                  iOutputFileName; // the resulted file name, owned
       
   233         TState                  iState; // state of the conversion
       
   234         CArrayFixFlat<TSize>*   iIconSizes;
       
   235         // Original bitmap pointers garnered from the PNG in the midlet
       
   236         CFbsBitmap*             iOriginalBitmap;
       
   237         CFbsBitmap*             iOriginalBitmapMask;
       
   238         // Scaled target bitmaps
       
   239         CFbsBitmap*             iTempBitmap;
       
   240         CFbsBitmap*             iTempBitmapMask;
       
   241         // Bitmap scaler
       
   242         CBitmapScaler*          iScaler;
       
   243         // The current size icon being converted
       
   244         TInt                    iCurrentSizeIndex;
       
   245         // Icon file
       
   246         RFile                   iIconFile;
       
   247         RFile                   iIconPngFile;
       
   248         // Path to create Temp icons
       
   249         const HBufC*            iTempPath;
       
   250 
       
   251     };
       
   252 }
       
   253 #endif // #ifndef __ICONCONVERTER_H__