uigraphics/AknIcon/src/AknSourceBitmapIconManager.cpp
changeset 0 05e9090e2422
equal deleted inserted replaced
-1:000000000000 0:05e9090e2422
       
     1 /*
       
     2 * Copyright (c) 2002 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:   Implementation of class CAknSourceBitmapIconManager.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "AknSourceBitmapIconManager.h"
       
    23 #include "AknBitmap.h"
       
    24 #include "AknIconSrvUtils.h"
       
    25 #include "AknIconSrvTlsData.h"
       
    26 #include "akniconconfig.h"
       
    27 // ============================ MEMBER FUNCTIONS ===============================
       
    28 
       
    29 // Constructor
       
    30 CAknSourceBitmapIconManager::CAknSourceBitmapIconManager( CAknIcon* aSourceIcon ) :
       
    31     iSourceBitmap( aSourceIcon->Bitmap() ),
       
    32     iSourceMask( aSourceIcon->Mask() )
       
    33     {
       
    34     aSourceIcon->SetBitmap( NULL );
       
    35     aSourceIcon->SetMask( NULL );
       
    36     delete aSourceIcon;
       
    37     }
       
    38 
       
    39 // Destructor
       
    40 CAknSourceBitmapIconManager::~CAknSourceBitmapIconManager()
       
    41     {
       
    42     delete iSourceBitmap;
       
    43     delete iSourceMask;
       
    44     }
       
    45 
       
    46 // -----------------------------------------------------------------------------
       
    47 // CAknSourceBitmapIconManager::LoadBitmapIconL
       
    48 // -----------------------------------------------------------------------------
       
    49 //
       
    50 void CAknSourceBitmapIconManager::LoadBitmapIconL()
       
    51     {
       
    52     User::LeaveIfError( iBitmap->Duplicate( iSourceBitmap->Handle() ) );
       
    53     if ( iMask )
       
    54         {
       
    55         User::LeaveIfError( iMask->Duplicate( iSourceMask->Handle() ) );
       
    56         }
       
    57     }
       
    58 
       
    59 // -----------------------------------------------------------------------------
       
    60 // CAknSourceBitmapIconManager::DoInitializeIconL
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 void CAknSourceBitmapIconManager::DoInitializeIconL(
       
    64     const TSize& aSize,
       
    65     TScaleMode aMode,
       
    66     TInt aAngle )
       
    67     {
       
    68     if ( iInitializedMode == aMode && iInitializedSize == aSize && 
       
    69     	 iInitializedAngle == aAngle )
       
    70     	{
       
    71     	return;
       
    72     	}
       
    73        
       
    74     iBitmap->Reset();
       
    75     if ( iMask )
       
    76         {
       
    77         iMask->Reset();
       
    78         }
       
    79     
       
    80     AknIconSrvUtils::ScaleBitmapIconL(
       
    81         aSize,
       
    82         aMode,
       
    83         aAngle,
       
    84         iColor,
       
    85         iSourceBitmap,
       
    86         iSourceMask,
       
    87         iBitmap,
       
    88         iMask );
       
    89     if ( IsAppIcon() )
       
    90     	{
       
    91     	AknIconSrvUtils::EnsureValidSizeL(iBitmap, iMask);	
       
    92    	 	}
       
    93     
       
    94     if (!IsCompressionDisabled())
       
    95         {
       
    96         AknIconConfig::CompressIfPreferred(iBitmap, iMask);    
       
    97         }    
       
    98     iInitializedMode = aMode;
       
    99     iInitializedSize = aSize;
       
   100     iInitializedAngle = aAngle;
       
   101        
       
   102         
       
   103     }
       
   104 
       
   105 //  End of File