mtpdataproviders/mtpimagedp/inc/cmtpimagedpthumbnailcreator.h
changeset 0 d0791faffa3f
child 2 4843bb5893b6
equal deleted inserted replaced
-1:000000000000 0:d0791faffa3f
       
     1 // Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 /**
       
    17  @file
       
    18  @internalTechnology
       
    19 */
       
    20 
       
    21 #ifndef CMTPIMAGEDPTHUMBNAILCREATOR_H
       
    22 #define CMTPIMAGEDPTHUMBNAILCREATOR_H
       
    23 
       
    24 // INCLUDES
       
    25 #include <e32base.h>
       
    26 
       
    27 #include <thumbnailmanager.h>
       
    28 #include <thumbnailmanagerobserver.h>
       
    29 #include <thumbnailobjectsource.h>
       
    30 #include <thumbnaildata.h>
       
    31 #include <imageconversion.h>
       
    32 #include <bitmaptransforms.h>
       
    33 
       
    34 class CMTPTypeOpaqueData;
       
    35 
       
    36 #include "mtpdebug.h"
       
    37 
       
    38 #define MTPTHUMBSCALING
       
    39 
       
    40 // CLASS DECLARATION
       
    41 /**
       
    42 *  A class for reading image related info and creating a thumbnail from 
       
    43 *  an image.
       
    44 *
       
    45 *  @lib ptpstack.lib
       
    46 *  @since S60 3.2
       
    47 */
       
    48 class CMTPImageDpThumbnailCreator : public CActive, public MThumbnailManagerObserver
       
    49     {
       
    50 public:
       
    51 
       
    52     /**
       
    53      * Two-phased constructor.
       
    54      * @param None.
       
    55      * @return An instance of CMTPImageDpThumbnailCreator.
       
    56      */
       
    57     static CMTPImageDpThumbnailCreator* NewL();
       
    58 
       
    59     /**
       
    60      * C++ destructor.
       
    61      */
       
    62     ~CMTPImageDpThumbnailCreator();
       
    63     
       
    64 public:
       
    65 
       
    66     /**
       
    67      * Gets a thumbnail from the image.
       
    68      * @since S60 3.2
       
    69      * @param aSession, Reference to file server.
       
    70      * @param aFileName, Name of the image file. Caller must ensure that the referenced object exists until the asynchronous call is completed.
       
    71      * @param aThumbName, Name of the thumbnail file to be created. Caller must ensure that the referenced object exists until the asynchronous call is completed.
       
    72      * @param aGetThumbnailStatus, status when 
       
    73      */
       
    74     void GetThumbnailL(const TDesC& aFileName, CMTPTypeOpaqueData& aThumbName, TInt& result);
       
    75 
       
    76 
       
    77     void ClearThumbnailData();
       
    78     CThumbnailManager*  GetThumbMgr() { return iThumbMgr;}
       
    79 
       
    80 private: // From MThumbnailManagerObserver
       
    81     void ThumbnailReady( TInt aError, MThumbnailData& aThumbnail, TThumbnailRequestId aId );
       
    82     void ThumbnailPreviewReady( MThumbnailData& aThumbnail, TThumbnailRequestId aId );
       
    83 
       
    84 private: // From CActive
       
    85     void DoCancel();
       
    86     void RunL();
       
    87     TInt RunError(TInt aError);    
       
    88  
       
    89 private:
       
    90     void EncodeImageL();    
       
    91     /**
       
    92      * Scales the image as a thumbnail size.
       
    93      * @since S60 3.2
       
    94      * @param None.
       
    95      * @return None.
       
    96      */
       
    97 #ifdef MTPTHUMBSCALING
       
    98     void ScaleBitmap();
       
    99 #endif
       
   100     void QueueThumbCreationL( const TDesC& aFileName );
       
   101     void CreateThumbL(const TDesC& aFileName );
       
   102     void GetThumbL(const TDesC& aFileName);
       
   103 
       
   104 private:
       
   105     /**
       
   106      * Default C++ constructor. Not used.
       
   107      */
       
   108     CMTPImageDpThumbnailCreator();
       
   109 
       
   110     /**
       
   111      * 2nd phase constructor.
       
   112      */
       
   113     void ConstructL();
       
   114 
       
   115 private:
       
   116     /**
       
   117     FLOGGER debug trace member variable.
       
   118     **/
       
   119     __FLOG_DECLARATION_MEMBER_MUTABLE;
       
   120     
       
   121     enum{
       
   122         EIdle,
       
   123         EGetting,
       
   124         EGetted,
       
   125         EScaling,
       
   126         EEncoding}          iState;
       
   127     TThumbnailRequestId     iCurrentReq;
       
   128     TInt*                   iCreationErr;
       
   129     CFbsBitmap*             iBitmap;
       
   130     CImageEncoder*          iImgEnc;
       
   131 #ifdef MTPTHUMBSCALING
       
   132     CBitmapScaler*          iScaler;
       
   133 #endif
       
   134     HBufC8*                 iData;
       
   135     CThumbnailManager*      iThumbMgr;
       
   136     CThumbnailObjectSource* iObjectSource;
       
   137     CMTPTypeOpaqueData*     iBuffer;             //not owned
       
   138     CActiveSchedulerWait*   iActiveSchedulerWait;
       
   139     };
       
   140 
       
   141 #endif // CMTPIMAGEDPTHUMBNAILCREATOR_H