activityfw/tsutils/inc/tsgraphicfilescalinghandler.h
changeset 80 397d00875918
child 83 156f692b1687
equal deleted inserted replaced
73:4bc7b118b3df 80:397d00875918
       
     1 /*
       
     2  * Copyright (c) 2009 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 :
       
    15  *
       
    16  */
       
    17 #ifndef TSGRAPHICFILESCALINGHANDLER_H
       
    18 #define TSGRAPHICFILESCALINGHANDLER_H
       
    19 
       
    20 #ifndef __E32SVR_H__
       
    21 #define __E32SVR_H__
       
    22 #endif
       
    23 
       
    24 
       
    25 #ifndef SYMBIAN_ENABLE_PUBLIC_PLATFORM_HEADER_SPLIT
       
    26 #define SYMBIAN_ENABLE_PUBLIC_PLATFORM_HEADER_SPLIT
       
    27 #endif
       
    28 
       
    29 #include <bitmaptransforms.h>
       
    30 
       
    31 class CImageDecoder;
       
    32 class CFbsBitmap;
       
    33 
       
    34 class MImageReadyCallBack
       
    35 {
       
    36 public:
       
    37     virtual void ImageReadyCallBack(TInt error, const CFbsBitmap *bitmap ) = 0;
       
    38 };
       
    39 
       
    40 class CTsGraphicFileScalingHandler : public CActive
       
    41 {
       
    42 public:
       
    43 
       
    44 enum TCurrentOperation{
       
    45         ENone = 0,
       
    46         EConvertBitmapFromFile = 1,
       
    47         EScale = 2
       
    48     };
       
    49 
       
    50 enum TKindOfScaling
       
    51 {
       
    52    EIgnoreAspectRatio = 0,
       
    53    EKeepAspectRatio = 1,
       
    54    EKeepAspectRatioByExpanding = 2,
       
    55 };
       
    56 
       
    57     IMPORT_C ~CTsGraphicFileScalingHandler();
       
    58 
       
    59     IMPORT_C static CTsGraphicFileScalingHandler* NewL(MImageReadyCallBack &aNotify,
       
    60         RFs &aFs,
       
    61         const TDesC &aFileName,
       
    62         const TDesC8& aMimeType,
       
    63         const TSize &aNewSize,
       
    64         TKindOfScaling aKindOfScaling = CTsGraphicFileScalingHandler::EIgnoreAspectRatio);
       
    65     IMPORT_C static CTsGraphicFileScalingHandler* NewLC(MImageReadyCallBack &aNotify,
       
    66         RFs &aFs,
       
    67         const TDesC &aFileName,
       
    68         const TDesC8& aMimeType,
       
    69         const TSize &aNewSize,
       
    70         TKindOfScaling aKindOfScaling = CTsGraphicFileScalingHandler::EIgnoreAspectRatio);
       
    71 
       
    72 protected:
       
    73     void DoCancel();
       
    74     void RunL();
       
    75     TInt RunError(TInt);
       
    76 
       
    77 private:
       
    78     void ConstructL(RFs &aFs, const TDesC &aFileName, const TDesC8& aMimeType);
       
    79     CTsGraphicFileScalingHandler(MImageReadyCallBack &aNotify,
       
    80         const TSize &aNewSize,
       
    81         TKindOfScaling aKindOfScaling = CTsGraphicFileScalingHandler::EIgnoreAspectRatio);
       
    82     TSize Scaling();
       
    83 
       
    84 private:
       
    85     MImageReadyCallBack &mNotify;
       
    86     CImageDecoder *mImageDecoder;
       
    87     CFbsBitmap *mBitmapFromFile;
       
    88     CFbsBitmap *mBitmapOutput;
       
    89     CBitmapScaler *mBitmapScaler;
       
    90     TSize mNewSize;
       
    91     TBool mKindOfScaling;
       
    92 
       
    93     TCurrentOperation mCurrentOperation;
       
    94 };
       
    95 
       
    96 #endif // TSGRAPHICFILESCALINGHANDLER_H