contentstorage/caclient/s60/src/camenuiconmifutility.cpp
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)2008 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:  ?Description
 *
 */

#include <e32std.h>
#include <e32base.h>
#include <QBitmap>
#include <QDebug>
#include <AknIconUtils.h> // avkon
#include <apgicnfl.h> // fbsbitmap

#include "cabitmapadapter.h"
#include "camenuiconmifutility.h"


void CaMenuIconMifUtility::GetPixmapByFilenameL(TDesC& fileName,
        const QSize &size, QPixmap& pixmap)
{
    CFbsBitmap *bitamp(0);
    CFbsBitmap *mask(0);

    TInt bitmapIndex = 0;
    TInt maskIndex = 1;    
    // it will change bitmap ids if it is mif (checking inside)
    AknIconUtils::ValidateLogicalAppIconId( fileName,
                bitmapIndex, maskIndex );
    AknIconUtils::CreateIconLC( bitamp, mask, fileName,
            bitmapIndex, maskIndex );

    if (AknIconUtils::IsMifFile(fileName)) {
        AknIconUtils::DisableCompression(bitamp);
        AknIconUtils::SetSize(bitamp, TSize(size.width(), size.height()),
                        EAspectRatioPreservedAndUnusedSpaceRemoved);
    
        CaBitmapAdapter::fromBitmapAndMaskToPixmapL(bitamp, mask, pixmap);
    } else {
        CaBitmapAdapter::fromBitmapAndMaskToPixmapL(bitamp, mask, pixmap);
        pixmap.scaled(size);
    }
    
    // bitmap and icon, AknsUtils::CreateIconLC doesn't specify the order
    CleanupStack::Pop(2);
}