contentstorage/caclient/s60/src/camenuiconmifutility.cpp
changeset 112 dbfb5e38438b
parent 107 b34d53f6acdf
child 116 305818acdca4
equal deleted inserted replaced
107:b34d53f6acdf 112:dbfb5e38438b
     1 /*
       
     2  * Copyright (c)2008 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:  ?Description
       
    15  *
       
    16  */
       
    17 
       
    18 #include <e32std.h>
       
    19 #include <e32base.h>
       
    20 #include <QBitmap>
       
    21 #include <QDebug>
       
    22 #include <AknIconUtils.h> // avkon
       
    23 #include <apgicnfl.h> // fbsbitmap
       
    24 
       
    25 #include "cabitmapadapter.h"
       
    26 #include "camenuiconmifutility.h"
       
    27 
       
    28 
       
    29 void CaMenuIconMifUtility::GetPixmapByFilenameL(TDesC& fileName,
       
    30         const QSize &size, QPixmap& pixmap)
       
    31 {
       
    32     CFbsBitmap *bitamp(0);
       
    33     CFbsBitmap *mask(0);
       
    34 
       
    35     TInt bitmapIndex = 0;
       
    36     TInt maskIndex = 1;    
       
    37     // it will change bitmap ids if it is mif (checking inside)
       
    38     AknIconUtils::ValidateLogicalAppIconId( fileName,
       
    39                 bitmapIndex, maskIndex );
       
    40     AknIconUtils::CreateIconLC( bitamp, mask, fileName,
       
    41             bitmapIndex, maskIndex );
       
    42 
       
    43     if (AknIconUtils::IsMifFile(fileName)) {
       
    44         AknIconUtils::DisableCompression(bitamp);
       
    45         AknIconUtils::SetSize(bitamp, TSize(size.width(), size.height()),
       
    46                         EAspectRatioPreservedAndUnusedSpaceRemoved);
       
    47     
       
    48         CaBitmapAdapter::fromBitmapAndMaskToPixmapL(bitamp, mask, pixmap);
       
    49     } else {
       
    50         CaBitmapAdapter::fromBitmapAndMaskToPixmapL(bitamp, mask, pixmap);
       
    51         pixmap.scaled(size);
       
    52     }
       
    53     
       
    54     // bitmap and icon, AknsUtils::CreateIconLC doesn't specify the order
       
    55     CleanupStack::Pop(2);
       
    56 }