activityfw/activitydatabase/hsactivitydbserver/inc/activitygraphicfilescaling.h
author Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
Thu, 27 May 2010 13:11:12 +0300
changeset 80 397d00875918
parent 73 4bc7b118b3df
permissions -rw-r--r--
Revision: 201019 Kit: 2010121

/*
 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
 * All rights reserved.
 * This component and the accompanying materials are made available
 * under the terms of "Eclipse Public License v1.0"
 * which accompanies this distribution, and is available
 * at the URL "http://www.eclipse.org/legal/epl-v10.html".
 *
 * Initial Contributors:
 * Nokia Corporation - initial contribution.
 *
 * Contributors:
 *
 * Description :
 *
 */
#ifndef ACTIVITYGRAPHICFILESSCALING_H
#define ACTIVITYGRAPHICFILESSCALING_H

#ifndef __E32SVR_H__
#define __E32SVR_H__
#endif


#ifndef SYMBIAN_ENABLE_PUBLIC_PLATFORM_HEADER_SPLIT
#define SYMBIAN_ENABLE_PUBLIC_PLATFORM_HEADER_SPLIT
#endif

#include <bitmaptransforms.h>

class CImageDecoder;
class CFbsBitmap;

class MImageReadyCallBack
{
public:
    virtual void ImageReadyCallBack(TInt error, const CFbsBitmap *bitmap ) = 0;
};

class CGraphicsSalingHandler : public CActive
{
public:

enum TCurrentOperation{
        ENone = 0,
        EConvertBitmapFromFile = 1,
        EScale = 2
    };

enum TKindOfScaling
{
   EIgnoreAspectRatio = 0,
   EKeepAspectRatio = 1,
   EKeepAspectRatioByExpanding = 2,
};

    ~CGraphicsSalingHandler();

    static CGraphicsSalingHandler* NewL(MImageReadyCallBack &aNotify,
        RFs &aFs,
        const TDesC &aFileName,
        const TDesC8& aMimeType,
        const TSize &aNewSize,
        TKindOfScaling aKindOfScaling = CGraphicsSalingHandler::EIgnoreAspectRatio);
    static CGraphicsSalingHandler* NewLC(MImageReadyCallBack &aNotify,
        RFs &aFs,
        const TDesC &aFileName,
        const TDesC8& aMimeType,
        const TSize &aNewSize,
        TKindOfScaling aKindOfScaling = CGraphicsSalingHandler::EIgnoreAspectRatio);

protected:
    void DoCancel();
    void RunL();
    TInt RunError(TInt);

private:
    void ConstructL(RFs &aFs, const TDesC &aFileName, const TDesC8& aMimeType);
    CGraphicsSalingHandler(MImageReadyCallBack &aNotify,
        const TSize &aNewSize,
        TKindOfScaling aKindOfScaling = CGraphicsSalingHandler::EIgnoreAspectRatio);
    TSize Scaling();

private:
    MImageReadyCallBack &mNotify;
    CImageDecoder *mImageDecoder;
    CFbsBitmap *mBitmapFromFile;
    CFbsBitmap *mBitmapOutput;
    CBitmapScaler *mBitmapScaler;
    TSize mNewSize;
    TBool mKindOfScaling;

    TCurrentOperation mCurrentOperation;
};

#endif // ACTIVITYGRAPHICFILESSCALING_H