imagehandlingutilities/thumbnailmanager/thumbnailserver/inc/thumbnailscaletask.h
changeset 0 2014ca87e772
child 7 2eb74cf6572e
equal deleted inserted replaced
-1:000000000000 0:2014ca87e772
       
     1 /*
       
     2 * Copyright (c) 2006-2007 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:  Task for scaling thumbnails
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef THUMBNAILSCALETASK_H
       
    20 #define THUMBNAILSCALETASK_H
       
    21 
       
    22 #include "thumbnailtask.h"
       
    23 #include "thumbnailprovider.h"
       
    24 #include "thumbnailstore.h" // TThumbnailPersistentSize
       
    25 
       
    26 class CThumbnailServer;
       
    27 
       
    28 /**
       
    29  *  Task for scaling thumbnails.
       
    30  *
       
    31  *  @since S60 v5.0
       
    32  */
       
    33 class CThumbnailScaleTask: public CThumbnailTask
       
    34     {
       
    35 public:
       
    36 
       
    37     /**
       
    38      * Two-phased constructor
       
    39      *
       
    40      * @since S60 v5.0
       
    41      * @param aProcessor Processor object for running tasks.
       
    42      * @param aServer Server to use.
       
    43      * @param aFilename Filename of file from which the thumbnail is to be
       
    44      *                  created.
       
    45      * @param aBitmap Bitmap image. Scale task assumes ownership.
       
    46      * @param aOriginalSize Original size of the image.
       
    47      * @param aTargetSize Target size of thumbnail image.
       
    48      * @param aCrop Enable or disable cropping.
       
    49      * @param aDisplayMode Display mode.
       
    50      * @param aPriority Priority of the request.
       
    51      * @param aThumbnailSize Prededined size of thumbnail.
       
    52      * @return New CThumbnailScaleTask object.
       
    53      * @param aEXIF is origin EXIF.
       
    54      */
       
    55     static CThumbnailScaleTask* NewL( CThumbnailTaskProcessor& aProcessor,
       
    56         CThumbnailServer& aServer, const TDesC& aFilename, CFbsBitmap* aBitmap,
       
    57         const TSize& aOriginalSize, const TSize& aTargetSize, TBool aCrop,
       
    58         TDisplayMode aDisplayMode, TInt aPriority, const TDesC& aTargetUri,
       
    59         const TThumbnailSize aThumbnailSize, const TThumbnailId aThumbnailId,
       
    60         const TBool aBitmapToPool, const TBool aEXIF);
       
    61 
       
    62     /**
       
    63      * Destructor
       
    64      *
       
    65      * @since S60 v5.0
       
    66      */
       
    67     virtual ~CThumbnailScaleTask();
       
    68 
       
    69     /**
       
    70      * StartL
       
    71      *
       
    72      * @since S60 v5.0
       
    73      */
       
    74     void StartL();
       
    75 
       
    76     /**
       
    77      * Handles an active object's request completion event.
       
    78      *
       
    79      * @since S60 v5.0
       
    80      */
       
    81     void RunL();
       
    82 
       
    83     /**
       
    84      * Implements cancellation of an outstanding request.
       
    85      *
       
    86      * @since S60 v5.0
       
    87      */
       
    88     void DoCancel();
       
    89 
       
    90     /**
       
    91      * Changes priority of the task.
       
    92      *
       
    93      * @since S60 v5.0
       
    94      */
       
    95     void ChangeTaskPriority( TInt aNewPriority );
       
    96 
       
    97     /**
       
    98      * Set whether the scaled image is to be stored or not.
       
    99      *
       
   100      * @since S60 v5.0
       
   101      * @param aDoStore Boolean value stating should the image be stored.
       
   102      */
       
   103     void SetDoStore( TBool aDoStore );
       
   104 
       
   105 private:
       
   106 
       
   107     /**
       
   108      * C++ default constructor
       
   109      *
       
   110      * @since S60 v5.0
       
   111      * @param aProcessor Processor object for running tasks.
       
   112      * @param aServer Server to use.
       
   113      * @param aFilename Filename of file from which the thumbnail is to be
       
   114      *                  created.
       
   115      * @param aBitmap Bitmap image. Scale task assumes ownership.
       
   116      * @param aOriginalSize Original size of the image.
       
   117      * @param aTargetSize Target size of thumbnail image.
       
   118      * @param aCrop Enable or disable cropping.
       
   119      * @param aDisplayMode Display mode.
       
   120      * @param aPriority Priority of the request.
       
   121      * @param aThumbnailSize Prededined size of thumbnail.
       
   122      * @return New CThumbnailScaleTask object.
       
   123      * @param aEXIF is origin EXIF.
       
   124      */
       
   125     CThumbnailScaleTask( CThumbnailTaskProcessor& aProcessor, CThumbnailServer&
       
   126         aServer, const TDesC& aFilename, CFbsBitmap* aBitmap, const TSize&
       
   127         aOriginalSize, const TSize& aTargetSize, TBool aCrop, TDisplayMode
       
   128         aDisplayMode, TInt aPriority, const TDesC& aTargetUri,
       
   129         const TThumbnailSize aThumbnailSize, const TThumbnailId aThumbnailId,
       
   130         const TBool aBitmapToPool, const TBool aEXIF);
       
   131 
       
   132     /**
       
   133      * Symbian 2nd phase constructor can leave.
       
   134      *
       
   135      * @since S60 v5.0
       
   136      */
       
   137     void ConstructL();
       
   138 
       
   139     /**
       
   140      * Calculates target size to be used for the thumbnail when cropping is
       
   141      * disabled. The target size may be smaller than requested if aspect
       
   142      * ratios do not match. Updates iTargetSize.
       
   143      *
       
   144      * @since S60 v5.0
       
   145      */
       
   146     void CalculateTargetSize();
       
   147 
       
   148     /**
       
   149      * Calculates cropping rectangle to be used for the thumbnail when
       
   150      * cropping is enabled. Target size will always be the same as requested
       
   151      * size and the cropping rectangle defines which area of the image will
       
   152      * be visible. Updates iCropRectangle.
       
   153      *
       
   154      * @since S60 v5.0
       
   155      */
       
   156     void CalculateCropRectangle();
       
   157 
       
   158     /**
       
   159      * StoreAndCompleteL
       
   160      *
       
   161      * @since S60 v5.0
       
   162      */
       
   163     void StoreAndCompleteL();
       
   164 
       
   165 private:
       
   166     // Data
       
   167 
       
   168     /**
       
   169      * Server.
       
   170      */
       
   171     CThumbnailServer& iServer;
       
   172 
       
   173     /**
       
   174      * Resides in bitmap pool.
       
   175      * Not own. But we do are responsible for decreasing the reference count
       
   176      * if iBitmapInPool is set.
       
   177      */
       
   178     CFbsBitmap* iBitmap;
       
   179 
       
   180     /**
       
   181      * Temporary place to store the original bitmap. This is set to NULL
       
   182      * after the bitmap has been successfully added to the bitmap pool.
       
   183      * Own.
       
   184      */
       
   185     CFbsBitmap* iOwnBitmap;
       
   186 
       
   187     /**
       
   188      * Bitmap pool.
       
   189      */
       
   190     TBool iBitmapInPool;
       
   191 
       
   192     /**
       
   193      * Original size of media object.
       
   194      */
       
   195     TSize iOriginalSize;
       
   196 
       
   197     /**
       
   198      * Target size of the thumbnail.
       
   199      */
       
   200     TSize iTargetSize;
       
   201 
       
   202     /**
       
   203      * Incidates if cropping is enabled.
       
   204      */
       
   205     TBool iCrop;
       
   206 
       
   207     /**
       
   208      * Defines the visible area of iBitmap which is to be included
       
   209      * in the thumbnail if cropping is enabled. Not used if cropping
       
   210      * is disabled.
       
   211      */
       
   212     TRect iCropRectangle;
       
   213 
       
   214     /**
       
   215      * Display mode.
       
   216      */
       
   217     TDisplayMode iDisplayMode;
       
   218 
       
   219     /**
       
   220      * Filename of the image to be used.
       
   221      */
       
   222     TFileName iFilename;
       
   223     
       
   224     /**
       
   225      * Uri of the target object
       
   226      */
       
   227     TFileName iTargetUri;
       
   228 
       
   229     /**
       
   230      * Scaled image.
       
   231      */
       
   232     CFbsBitmap* iScaledBitmap; // own
       
   233 
       
   234     /**
       
   235      * If set, scaled bitmap must be released from pool.
       
   236      */
       
   237     TInt iScaledBitmapHandle;
       
   238 
       
   239     /**
       
   240      * If set, thumbnail will be stored for later use.
       
   241      */
       
   242     TBool iDoStore;
       
   243 
       
   244     /**
       
   245      * Temporary buffer for client/server parameters
       
   246      */
       
   247     TThumbnailRequestParamsPckgBuf iParamsBuf;
       
   248 
       
   249      /**
       
   250      * Size of requested Thumbnail
       
   251      */
       
   252     TThumbnailSize iThumbnailSize;
       
   253     
       
   254 	 /**
       
   255      * MDS ID of requested Thumbnail
       
   256      */
       
   257     TThumbnailId iThumbnailId;
       
   258     
       
   259 	/**
       
   260      * Add bitmap to server's pool.
       
   261      */
       
   262     TBool iBitmapToPool;
       
   263  
       
   264 #ifdef _DEBUG
       
   265     TTime aStart, aStop;
       
   266 #endif
       
   267     
       
   268      /**
       
   269      * Is origin EXIF.
       
   270      */
       
   271     TBool iEXIF;
       
   272 };
       
   273 
       
   274 #endif // THUMBNAILSCALETASK_H