uigraphics/AknIcon/src/AknNGAFormatHandler.cpp
changeset 0 05e9090e2422
child 33 e2effe28d8cc
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:  Format Handler for NGA(will create an extended bitmap)
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <e32math.h>
       
    22 #include <fbs.h>
       
    23 #include <mifconvdefs.h> // For definition of EIconFormatSVG
       
    24 #include "AknNGAFormatHandler.h"
       
    25 #include "AknIconObserver.h"
       
    26 #include "AknIconSrvPanic.h"
       
    27 #include "AknIconTraces.h"
       
    28 #include "AknBitmap.h"
       
    29 #include "AknIconManager.h"
       
    30 #include "AknIconHeader.h"
       
    31 #include <SVGRendererId.h>
       
    32 
       
    33 // CONSTANTS
       
    34 
       
    35 
       
    36 // ============================ MEMBER FUNCTIONS ===============================
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // CAknNGAFormatHandler::CAknNGAFormatHandler
       
    40 // C++ default constructor can NOT contain any code, that
       
    41 // might leave.
       
    42 // -----------------------------------------------------------------------------
       
    43 //
       
    44 CAknNGAFormatHandler::CAknNGAFormatHandler(TSize aBitmapSize,TDisplayMode aBitmapDspMode,TDisplayMode aMaskDspMode):iBitmapSize(aBitmapSize),
       
    45 iBitmapDspMode(aBitmapDspMode),
       
    46 iMaskDspMode(aMaskDspMode)	    
       
    47 	        {       
       
    48 	        iData = 0;
       
    49 	        }
       
    50 
       
    51 // -----------------------------------------------------------------------------
       
    52 // CAknNGAFormatHandler::ConstructL
       
    53 // Symbian 2nd phase constructor can leave.
       
    54 // -----------------------------------------------------------------------------
       
    55 //
       
    56 void CAknNGAFormatHandler::ConstructL(TInt /*aType*/)
       
    57     {
       
    58 #ifdef __AKNICON_TRACES
       
    59     RDebug::Print( _L("AknIcon: %x Calling ConstructL - iSvgEngine: %x"), this, iSvgEngine);
       
    60 #endif            
       
    61     }
       
    62 
       
    63 CAknNGAFormatHandler* CAknNGAFormatHandler::NewL(TInt aType,TSize aBitmapSize,TDisplayMode aBitmapDspMode,TDisplayMode aMaskDspMode)
       
    64     {
       
    65     CAknNGAFormatHandler* self = new( ELeave ) CAknNGAFormatHandler(aBitmapSize,aBitmapDspMode,aMaskDspMode);
       
    66     CleanupStack::PushL( self );
       
    67     self->ConstructL(aType);
       
    68     CleanupStack::Pop();
       
    69     return self;
       
    70     }
       
    71 
       
    72 // Destructor
       
    73 CAknNGAFormatHandler::~CAknNGAFormatHandler()
       
    74     {
       
    75 #ifdef __AKNICON_TRACES
       
    76     RDebug::Print( _L("AknIcon: %x Calling ~CAknNGAFormatHandler - iSvgEngine: %x"), this, iSvgEngine);
       
    77 #endif        
       
    78     delete iSvgEngine;
       
    79     delete iDummyBitmap;
       
    80     delete iData;
       
    81     }
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CAknNGAFormatHandler::SetScaleMode
       
    85 // -----------------------------------------------------------------------------
       
    86 //
       
    87 void CAknNGAFormatHandler::SetScaleMode( TScaleMode aMode )
       
    88     {
       
    89     iMode = aMode;
       
    90     }
       
    91 
       
    92 // -----------------------------------------------------------------------------
       
    93 // CAknNGAFormatHandler::SetRotation
       
    94 // -----------------------------------------------------------------------------
       
    95 //
       
    96 void CAknNGAFormatHandler::SetRotation( TInt aAngle )
       
    97     {
       
    98     iAngle = aAngle;
       
    99     }
       
   100 
       
   101 // -----------------------------------------------------------------------------
       
   102 // CAknNGAFormatHandler::GetContentDimensionsL
       
   103 // -----------------------------------------------------------------------------
       
   104 //
       
   105 void CAknNGAFormatHandler::GetContentDimensionsL( TAknContentDimensions& aContentDimensions )
       
   106     {
       
   107     __ASSERT_DEBUG( iSvgEngine, 
       
   108             User::Panic( KAknIconSrvPanicCategory, ESrvPanicSvgEngineMissing ) );
       
   109     
       
   110     CheckHandleActivatedL( NULL, NULL );
       
   111     
       
   112     iSvgEngine->ContentDimensions(aContentDimensions.iWidth,aContentDimensions.iHeight);
       
   113     
       
   114     if ( aContentDimensions.iWidth <= 0 || aContentDimensions.iHeight <= 0 )
       
   115         {
       
   116         User::Leave( KErrNotFound );
       
   117         }
       
   118     }
       
   119 
       
   120 // -----------------------------------------------------------------------------
       
   121 // CAknNGAFormatHandler::InitializeEngineL
       
   122 // -----------------------------------------------------------------------------
       
   123 //
       
   124 void CAknNGAFormatHandler::InitializeEngineL()
       
   125     {
       
   126 #ifdef __AKNICON_TRACES
       
   127     RDebug::Print( _L("AknIcon: %x Calling InitializeEngineL - iSvgEngine: %x"), this, iSvgEngine);
       
   128 #endif    
       
   129     if ( !iSvgEngine )
       
   130         {
       
   131         TFontSpec spec;
       
   132         
       
   133         if ( !iDummyBitmap )
       
   134             {
       
   135             // Have to give some bitmap to the engine in the constructor.
       
   136             iDummyBitmap = new( ELeave ) CFbsBitmap;
       
   137             }
       
   138 #ifdef __AKNICON_TRACES
       
   139         RDebug::Print( _L("AknIcon: %x In InitializeEngineL - iDummyBitmap: %x"), this, iDummyBitmap);
       
   140 #endif    
       
   141         iSvgEngine = CSvgEngineInterfaceImpl::NewL( iDummyBitmap, this, spec,ESVGRendererTLV );
       
   142         iSvgEngine->SetBackgroundColor( 0xFFFFFFFF );
       
   143         // No DRM check needed.
       
   144         iSvgEngine->SetDRMMode( EFalse );
       
   145         }
       
   146 #ifdef __AKNICON_TRACES
       
   147     RDebug::Print( _L("AknIcon: %x InitializeEngineL called - iSvgEngine: %x"), this, iSvgEngine);
       
   148 #endif                            
       
   149     }
       
   150 
       
   151 // -----------------------------------------------------------------------------
       
   152 // CAknNGAFormatHandler::PrepareIconL
       
   153 // -----------------------------------------------------------------------------
       
   154 //
       
   155 void CAknNGAFormatHandler::PrepareIconL( const TDesC8& aIconData, TInt& aHandle )
       
   156     {
       
   157     InitializeEngineL();
       
   158 
       
   159     TInt handle = -1;
       
   160     
       
   161 #ifdef __AKNICON_TRACES
       
   162     RDebug::Print( _L("AknIcon: %x Calling PrepareDom"), this );
       
   163 #endif
       
   164     
       
   165     LeaveIfErrorL( iSvgEngine->PrepareDom( aIconData, handle ) );
       
   166     
       
   167 #ifdef __AKNICON_TRACES
       
   168     RDebug::Print( _L("AknIcon: %x PrepareDom called - handle = %d"), this, handle );
       
   169 #endif
       
   170 
       
   171     aHandle = handle;
       
   172     }
       
   173 
       
   174 // -----------------------------------------------------------------------------
       
   175 // CAknNGAFormatHandler::UsePreparedIconL
       
   176 // -----------------------------------------------------------------------------
       
   177 //
       
   178 void CAknNGAFormatHandler::UsePreparedIconL( TInt aHandle )
       
   179     {
       
   180     __ASSERT_DEBUG( iSvgEngine, 
       
   181             User::Panic( KAknIconSrvPanicCategory, ESrvPanicSvgEngineMissing ) );
       
   182     
       
   183     if ( aHandle != iHandle )
       
   184         {
       
   185         iHandle = aHandle;
       
   186         iHandleActivationStatus = ENotActivated;
       
   187         }
       
   188     }
       
   189 
       
   190 // -----------------------------------------------------------------------------
       
   191 // CAknNGAFormatHandler::RenderPreparedIconL
       
   192 // -----------------------------------------------------------------------------
       
   193 //
       
   194 void CAknNGAFormatHandler::RenderPreparedIconL(
       
   195         CFbsBitmap* aBitmap,
       
   196         CFbsBitmap* aMask,TSize Bitmapsize,TDisplayMode Bitmapdepth,TDisplayMode Maskdepth, TRgb aColor, TBool aMarginFlag )
       
   197     {
       
   198     __ASSERT_DEBUG( iSvgEngine,
       
   199             User::Panic( KAknIconSrvPanicCategory, ESrvPanicSvgEngineMissing ) );
       
   200     
       
   201     iMask = aMask;
       
   202     
       
   203     iBitmapSize=Bitmapsize;
       
   204     iBitmapDspMode=Bitmapdepth;
       
   205     iMaskDspMode=Maskdepth;        
       
   206     // Make sure iMask is NULL'ed if a leave occurs so that an invalid pointer
       
   207     // is not left there.
       
   208     CleanupStack::PushL( TCleanupItem( CleanupNullMaskPointer, this ) );
       
   209     
       
   210     CheckHandleActivatedL( aBitmap, aMask );
       
   211     
       
   212     TReal32 angle = 0;
       
   213     TSize size;
       
   214     
       
   215     if ( iAngle && !iAnimated )
       
   216         {
       
   217         // SVG engine wants rotation angle as TReal32 and in radians.
       
   218         angle = (TReal32)iAngle / (TReal32)(360 / 2 / (TReal32)KPi);        
       
   219         iSvgEngine->Rotate(angle, Bitmapsize.iWidth / 2, Bitmapsize.iHeight / 2);
       
   220         }
       
   221     else
       
   222         {
       
   223         iSvgEngine->Rotate(0.0f, Bitmapsize.iWidth / 2, Bitmapsize.iHeight / 2);
       
   224         }
       
   225     
       
   226     
       
   227     SetEngineScaleMode();
       
   228     MSvgError* aError = NULL;
       
   229     iSvgEngine->ChooseViewBoxIfNotSet( iHandle );
       
   230     
       
   231     FormCommonHeader(aBitmap, EFalse, aColor, aMarginFlag);
       
   232 
       
   233     TPtr8 lPtr( iData->Des() );
       
   234     iSvgEngine->Start(aError,&lPtr);
       
   235     TRAPD(err,LeaveIfErrorL(aError));
       
   236     if ( err != KErrNone || !iAnimated )
       
   237         {
       
   238         // SVG engine cannot handle the situation, where the bitmap given in UseDom
       
   239         // is deleted before next UseDom call, this is a workaround for it.
       
   240         LeaveIfErrorL( iSvgEngine->UseDom( iHandle,aBitmap,aMask,iBitmapSize,iBitmapDspMode,iMaskDspMode) );
       
   241         iHandleActivationStatus = EActivated;
       
   242         
       
   243         // Undo any rotation, so that the situation is resetted for the
       
   244         // next request with different parameters.
       
   245         if ( iAngle )
       
   246             {
       
   247             iSvgEngine->Rotate( -angle, size.iWidth / 2, size.iHeight / 2 );
       
   248             }
       
   249         
       
   250         User::LeaveIfError(err);
       
   251         
       
   252         CleanupStack::PopAndDestroy(); // CleanupNullMaskPointer
       
   253         }
       
   254     else
       
   255         {
       
   256         CleanupStack::Pop(); // Keep mask pointer if animated.
       
   257         }        
       
   258     }
       
   259 
       
   260 // -----------------------------------------------------------------------------
       
   261 // CAknNGAFormatHandler::UnprepareIcon
       
   262 // -----------------------------------------------------------------------------
       
   263 //
       
   264 void CAknNGAFormatHandler::UnprepareIcon( TInt aHandle )
       
   265     {
       
   266     __ASSERT_DEBUG( iSvgEngine, 
       
   267             User::Panic( KAknIconSrvPanicCategory, ESrvPanicSvgEngineMissing ) );
       
   268     
       
   269 #ifdef __AKNICON_TRACES
       
   270     RDebug::Print( _L("AknIcon: %x Calling DeleteDom - handle = %d"), this, aHandle );
       
   271 #endif
       
   272     
       
   273     iSvgEngine->DeleteDom( aHandle );
       
   274     
       
   275     if ( aHandle == iHandle )
       
   276         {
       
   277         iHandleActivationStatus = ENotActivated;
       
   278         }
       
   279     }
       
   280 
       
   281 // -----------------------------------------------------------------------------
       
   282 // CAknNGAFormatHandler::SetAnimated
       
   283 // -----------------------------------------------------------------------------
       
   284 //
       
   285 void CAknNGAFormatHandler::SetAnimated( TBool aAnimated )
       
   286     {
       
   287     iAnimated = aAnimated;
       
   288     }
       
   289 
       
   290 // -----------------------------------------------------------------------------
       
   291 // CAknNGAFormatHandler::IconFormatType
       
   292 // -----------------------------------------------------------------------------
       
   293 //
       
   294 TInt CAknNGAFormatHandler::IconFormatType()
       
   295     {
       
   296     return EIconFormatNGA;
       
   297     }
       
   298 
       
   299 // -----------------------------------------------------------------------------
       
   300 // CAknNGAFormatHandler::SetObserver
       
   301 // -----------------------------------------------------------------------------
       
   302 //
       
   303 void CAknNGAFormatHandler::SetObserver( MAknIconChangeObserver* aObserver )
       
   304     {
       
   305 #ifdef __AKNICON_TRACES
       
   306     RDebug::Print( _L("AknIcon: %x Calling SetObserver - aObserver: %x"), this, aObserver);
       
   307 #endif        
       
   308     iObserver = aObserver;
       
   309     }
       
   310 
       
   311 
       
   312 // -----------------------------------------------------------------------------
       
   313 // CAknNGAFormatHandler::CheckHandleActivatedL
       
   314 // -----------------------------------------------------------------------------
       
   315 //
       
   316 
       
   317 void CAknNGAFormatHandler::CheckHandleActivatedL( CFbsBitmap* aBitmap, CFbsBitmap* aMask )
       
   318     {
       
   319     if ( !aBitmap )
       
   320         {
       
   321         if ( iHandleActivationStatus == ENotActivated )
       
   322             {
       
   323 #ifdef __AKNICON_TRACES
       
   324             RDebug::Print(
       
   325                     _L("AknIcon: %x Calling UseDom - Handle = %d, Bitmap ptr = %x, Mask ptr = %x"),
       
   326                     this, iHandle, aBitmap, aMask );
       
   327 #endif
       
   328             LeaveIfErrorL( iSvgEngine->UseDom( iHandle,aBitmap,aMask,iBitmapSize,iBitmapDspMode,iMaskDspMode ) );
       
   329             
       
   330 #ifdef __AKNICON_TRACES
       
   331             RDebug::Print(
       
   332                     _L("AknIcon: %x UseDom called - Handle = %d, Bitmap ptr = %x, Mask ptr = %x"),
       
   333                     this, iHandle, aBitmap, aMask );
       
   334 #endif
       
   335             
       
   336             iHandleActivationStatus = EActivated;
       
   337             }
       
   338         }
       
   339     else
       
   340         {
       
   341         if ( iHandleActivationStatus != EActivatedWithFrameBuffer || iAnimated )
       
   342             {
       
   343 #ifdef __AKNICON_TRACES
       
   344             RDebug::Print(
       
   345                     _L("AknIcon: %x Calling UseDom - Handle = %d, Bitmap ptr = %x, Mask ptr = %x"),
       
   346                     this, iHandle, aBitmap, aMask );
       
   347 #endif
       
   348             
       
   349             LeaveIfErrorL( iSvgEngine->UseDom( iHandle,aBitmap,aMask,iBitmapSize,iBitmapDspMode,iMaskDspMode ) );
       
   350             
       
   351 #ifdef __AKNICON_TRACES
       
   352             RDebug::Print(
       
   353                     _L("AknIcon: %x UseDom called - Handle = %d, Bitmap ptr = %x, Mask ptr = %x"),
       
   354                     this, iHandle, aBitmap, aMask );
       
   355 #endif
       
   356             
       
   357             iHandleActivationStatus = EActivatedWithFrameBuffer;
       
   358             }
       
   359         }
       
   360     }
       
   361 
       
   362 
       
   363 // -----------------------------------------------------------------------------
       
   364 // CAknNGAFormatHandler::SupportedDisplayMode
       
   365 // -----------------------------------------------------------------------------
       
   366 //
       
   367 void CAknNGAFormatHandler::SupportedDisplayMode(
       
   368         TDisplayMode& aMode, TDisplayMode aPreferredMode )
       
   369     {
       
   370     // Modes currently supported by SVG engine are:
       
   371     // EGray2, EColor4K, EColor64K, EColor16M
       
   372     if ( aMode != EGray2 )
       
   373         {
       
   374         aMode = aPreferredMode;
       
   375         }
       
   376     }
       
   377 
       
   378 // -----------------------------------------------------------------------------
       
   379 // CAknNGAFormatHandler::UpdateScreen
       
   380 // -----------------------------------------------------------------------------
       
   381 //
       
   382 void CAknNGAFormatHandler::UpdateScreen()
       
   383     {
       
   384     if ( iObserver )
       
   385         {
       
   386         iObserver->BitmapChanged();
       
   387         }
       
   388     else if (iAnimated)
       
   389         {
       
   390         iSvgEngine->Stop();
       
   391         }
       
   392     else
       
   393         {
       
   394         // skip
       
   395         }
       
   396     }
       
   397 
       
   398 // -----------------------------------------------------------------------------
       
   399 // CAknNGAFormatHandler::ScriptCall
       
   400 // -----------------------------------------------------------------------------
       
   401 //
       
   402 TBool CAknNGAFormatHandler::ScriptCall(
       
   403         const TDesC& /*aScript*/,
       
   404         CSvgElementImpl* /*aCallerElement*/ )
       
   405     {
       
   406     return EFalse;
       
   407     }
       
   408 
       
   409 // -----------------------------------------------------------------------------
       
   410 // CAknNGAFormatHandler::FetchImage
       
   411 // -----------------------------------------------------------------------------
       
   412 //
       
   413 
       
   414 TInt CAknNGAFormatHandler::FetchImage(
       
   415         const TDesC& /*aUri*/, RFs& /*aSession*/, RFile& /*aFileHandle*/ )
       
   416     {
       
   417     return KErrNotSupported;
       
   418     }
       
   419 
       
   420 
       
   421 // -----------------------------------------------------------------------------
       
   422 // CAknNGAFormatHandler::SetEngineScaleMode
       
   423 // -----------------------------------------------------------------------------
       
   424 //
       
   425 
       
   426 void CAknNGAFormatHandler::SetEngineScaleMode()
       
   427     {
       
   428     TSvgPreserveAspectAlignType alignTypeValue = ESvgPreserveAspectRatio_XmidYmid;
       
   429     TSvgMeetOrSliceType meetOrSliceTypeValue = ESvgMeetOrSlice_Meet;
       
   430     switch ( iMode )
       
   431         {
       
   432         case EAspectRatioPreserved: // fall through
       
   433             {
       
   434             // use default
       
   435             break;
       
   436             }
       
   437             // Ensures SVG content fully covers            
       
   438             // the area of the icon whilst preserving aspect ratio.
       
   439         case EAspectRatioPreservedSlice:
       
   440             {
       
   441             // alignTypeValue use default
       
   442             meetOrSliceTypeValue = ESvgMeetOrSlice_Slice;
       
   443             break;
       
   444             } 
       
   445             // EAspectRatioPreservedAndUnusedSpaceRemoved is mapped to
       
   446             // the same values as EAspectRatioNotPreserved
       
   447             // because we already have a frame buffer
       
   448             // with the dimensions that preserves the aspect ratio.
       
   449             // This mapping ensures that SVG engine does not calculate aspect
       
   450             // ratio twice and potentially resulting in precision loss.
       
   451         case EAspectRatioPreservedAndUnusedSpaceRemoved:                        
       
   452         case EAspectRatioNotPreserved:
       
   453             {            
       
   454             alignTypeValue = ESvgPreserveAspectRatio_None;
       
   455             // meetOrSliceTypeValue use default
       
   456             break;
       
   457             }
       
   458         default:
       
   459             {
       
   460             __ASSERT_DEBUG( 0, User::Invariant() );
       
   461             }
       
   462         }        
       
   463     iSvgEngine->SetPreserveAspectRatio( NULL, alignTypeValue, meetOrSliceTypeValue, ETrue);        
       
   464     }
       
   465 
       
   466 // -----------------------------------------------------------------------------
       
   467 // CAknNGAFormatHandler::UpdatePresentation
       
   468 // -----------------------------------------------------------------------------
       
   469 //
       
   470 void CAknNGAFormatHandler::UpdatePresentation(
       
   471         const TInt32& /*aNoOfAnimation*/ )
       
   472     {
       
   473     }
       
   474 
       
   475 // -----------------------------------------------------------------------------
       
   476 // CAknNGAFormatHandler::UpdatePresentation
       
   477 // -----------------------------------------------------------------------------
       
   478 //    
       
   479 TInt CAknNGAFormatHandler::FetchFont( const TDesC& /*aUri*/, RFs& /*aSession*/, RFile& /*aFileHandle*/ )
       
   480     {
       
   481     return KErrNotSupported;
       
   482     }
       
   483 
       
   484 // -----------------------------------------------------------------------------
       
   485 // CAknNGAFormatHandler::LeaveIfErrorL
       
   486 // -----------------------------------------------------------------------------
       
   487 //
       
   488 void CAknNGAFormatHandler::LeaveIfErrorL( MSvgError* aError )
       
   489     {
       
   490     User::LeaveIfNull( aError );
       
   491     if ( aError->HasError() && !aError->IsWarning() )
       
   492         {
       
   493         User::LeaveIfError( SvgErrorToSymbianError( aError->ErrorCode() ) );
       
   494         }
       
   495     }
       
   496 
       
   497 // -----------------------------------------------------------------------------
       
   498 // CAknNGAFormatHandler::SvgErrorToSymbianError
       
   499 // -----------------------------------------------------------------------------
       
   500 //
       
   501 TInt CAknNGAFormatHandler::SvgErrorToSymbianError( const TSvgErrorCode aError )
       
   502     {
       
   503     // most common mapping...
       
   504     TInt ret = KErrGeneral;
       
   505     
       
   506     switch ( aError )
       
   507         {
       
   508         case ESvgNoError:
       
   509             ret = KErrNone;
       
   510             break;
       
   511         case ESvgFileNotFound:
       
   512             ret = KErrNotFound;
       
   513             break;
       
   514         case ESvgDocumentNotValid: // fall through
       
   515         case ESvgDocumentNotAvailable:
       
   516             break;
       
   517         case ESvgNoMemory:
       
   518             ret = KErrNoMemory;
       
   519             break;
       
   520         case ESvgDiskFull:
       
   521             ret = KErrDiskFull;
       
   522             break;
       
   523         case ESvgUnknown: // fall through
       
   524         case ESvgMissingRequiredAttribute: // fall through
       
   525         case ESvgInvalidAttributeValue: // fall through
       
   526         default:
       
   527             break;
       
   528         }
       
   529 
       
   530     return ret;
       
   531     }
       
   532 
       
   533 // -----------------------------------------------------------------------------
       
   534 // CAknNGAFormatHandler::CleanupNullMaskPointer
       
   535 // -----------------------------------------------------------------------------
       
   536 //
       
   537 void CAknNGAFormatHandler::CleanupNullMaskPointer( TAny* aParam )
       
   538     {
       
   539     static_cast<CAknNGAFormatHandler*>( aParam )->iMask = NULL;
       
   540     }
       
   541 
       
   542 void CAknNGAFormatHandler::FormCommonHeader(const CFbsBitmap *aBitmap, TBool isMask,TRgb aColor, TBool aMarginFlag)
       
   543     {
       
   544     if(!iData)
       
   545         iData = HBufC8::New(KIconHeaderLength);
       
   546     
       
   547     TPtr8 tmpBufPtr (iData->Des());
       
   548     tmpBufPtr.SetLength(KIconHeaderLength);
       
   549     TAknIconHeader iconheader(tmpBufPtr);
       
   550     iconheader.Initialize(); 
       
   551     
       
   552     iconheader.SetRotation(iAngle);
       
   553     
       
   554     iconheader.SetIconColor(aColor.Value());
       
   555  
       
   556     iconheader.SetScaleMode(iMode);
       
   557    
       
   558     if(aMarginFlag)
       
   559     iconheader.SetMarginCorrection(ETrue);
       
   560     
       
   561     iconheader.SetIsMask(isMask);
       
   562     
       
   563     iconheader.SetBitmapId(aBitmap->Handle());
       
   564     }
       
   565 
       
   566 //  End of File