satui/satplugin/aisatpluginsrc/caisatengine.cpp
branchRCL_3
changeset 6 1b9ee3c7442d
parent 0 ff3b6d0fd310
child 9 71e7b994dff4
equal deleted inserted replaced
5:7237db0d9fca 6:1b9ee3c7442d
   312 TInt CAiSatEngine::DuplicateBitmap( const CFbsBitmap* aDestBmp,
   312 TInt CAiSatEngine::DuplicateBitmap( const CFbsBitmap* aDestBmp,
   313                                     const CFbsBitmap* aSrcBmp )
   313                                     const CFbsBitmap* aSrcBmp )
   314     {
   314     {
   315     TFLOGSTRING( "CAiSatPlugin::DuplicateBitmap() called" )
   315     TFLOGSTRING( "CAiSatPlugin::DuplicateBitmap() called" )
   316 
   316 
       
   317     TInt error( KErrGeneral );
       
   318 
       
   319     // Get display mode about bitmap
       
   320     TDisplayMode bmpDisplayMode = aSrcBmp->DisplayMode();
       
   321 
   317     // Get size and scan line length of the source bitmap.
   322     // Get size and scan line length of the source bitmap.
   318     TSize size = aSrcBmp->SizeInPixels();
   323     TSize size = aSrcBmp->SizeInPixels();
   319     TInt scanLineLength = CFbsBitmap::ScanLineLength( 
   324     TInt scanLineLength = CFbsBitmap::ScanLineLength( 
   320                             size.iWidth, aSrcBmp->DisplayMode() );
   325                             size.iWidth, bmpDisplayMode );
   321     TInt error( KErrNone );
   326     TInt bitmapHeight = size.iHeight;
   322     // Copy the data area of the source bimap to the dest bitmap.
   327 
   323     if ( aSrcBmp && aSrcBmp->DataAddress() )
   328     TUint* bufUint = new TUint[ scanLineLength ];
   324         {
   329     if ( bufUint )
   325         TAny* bitmapData( NULL );
   330         {
   326         
   331         TPtr8 bufPtr ( ( TUint8* )bufUint, scanLineLength, scanLineLength );
   327         bitmapData = memcpy(
   332         // Initialize the pixel data for destination bitmap
   328             (TAny*)aDestBmp->DataAddress(), 
   333         for ( TInt pixelIndex = 0; pixelIndex < bitmapHeight; ++pixelIndex )
   329             (TAny*)aSrcBmp->DataAddress(), 
   334             {
   330             scanLineLength * size.iHeight );
   335             TPoint pixelPoint( 0, pixelIndex );
   331         
   336             aSrcBmp->GetScanLine( bufPtr, pixelPoint,
   332         if ( NULL == bitmapData )
   337             scanLineLength, bmpDisplayMode );
   333             {
   338             aDestBmp->SetScanLine( bufPtr, pixelIndex );
   334             TFLOGSTRING( "CAiSatPlugin::DuplicateBitmap() \
   339             }
   335                 Failed to copy memory data of bitmap." )
   340         error = KErrNone;
   336             error = KErrBadHandle;
   341         TFLOGSTRING3( "CAiSatPlugin::DuplicateBitmap() \
   337             }
   342         scanLineLength = %d bitmapHeight = %d", scanLineLength, bitmapHeight )
   338         }
   343         }
   339 
   344 
       
   345     delete bufUint;
       
   346     bufUint = NULL;
       
   347 
   340     TFLOGSTRING( "CAiSatPlugin::DuplicateBitmap() exits" )
   348     TFLOGSTRING( "CAiSatPlugin::DuplicateBitmap() exits" )
   341 
       
   342     return error;
   349     return error;
   343     }  
   350     }