uiservicetab/vimpstutils/src/cvimpstimageprocessor.cpp
branchRCL_3
changeset 14 9fdee5e1da30
parent 0 5e5d6b214f4f
equal deleted inserted replaced
13:796276a1bdcc 14:9fdee5e1da30
    20 #include "tvimpstconsts.h"
    20 #include "tvimpstconsts.h"
    21 #include <imageconversion.h>
    21 #include <imageconversion.h>
    22 #include <bitmaptransforms.h>
    22 #include <bitmaptransforms.h>
    23 #include <s32file.h>
    23 #include <s32file.h>
    24 #include <e32cmn.h>
    24 #include <e32cmn.h>
    25 #include "vimpstdebugprint.h"
    25 #include "uiservicetabtracer.h"
    26 // CONSTANTS
    26 // CONSTANTS
    27 const TInt KChatCustomBitmapWidth =  65;
    27 const TInt KChatCustomBitmapWidth =  65;
    28 const TInt KChatCustomBitmapHeight = 65;
    28 const TInt KChatCustomBitmapHeight = 65;
    29 const TInt KMaxImageSize = 1800; //2k
    29 const TInt KMaxImageSize = 1800; //2k
    30 const TInt KMimeLength = 16;
    30 const TInt KMimeLength = 16;
    62 // CVimpstImageProcessor::NewL
    62 // CVimpstImageProcessor::NewL
    63 // ( Other items commented in header )
    63 // ( Other items commented in header )
    64 //-----------------------------------------------------------------------------
    64 //-----------------------------------------------------------------------------
    65 CVimpstImageProcessor* CVimpstImageProcessor::NewL( MCAImageProcessObserver* aObserver)
    65 CVimpstImageProcessor* CVimpstImageProcessor::NewL( MCAImageProcessObserver* aObserver)
    66     {
    66     {
       
    67 	TRACER_AUTO;
    67     CVimpstImageProcessor* self =
    68     CVimpstImageProcessor* self =
    68     new ( ELeave ) CVimpstImageProcessor(aObserver);
    69     new ( ELeave ) CVimpstImageProcessor(aObserver);
    69     CleanupStack::PushL( self );
    70     CleanupStack::PushL( self );
    70     self->ConstructL();
    71     self->ConstructL();
    71     CleanupStack::Pop( self );
    72     CleanupStack::Pop( self );
    86 // CVimpstImageProcessor::RunL
    87 // CVimpstImageProcessor::RunL
    87 // ( Other items commented in header )
    88 // ( Other items commented in header )
    88 //-----------------------------------------------------------------------------
    89 //-----------------------------------------------------------------------------
    89 void CVimpstImageProcessor::RunL()
    90 void CVimpstImageProcessor::RunL()
    90     {
    91     {
       
    92 	TRACER_AUTO;
    91     TInt status = iStatus.Int();    
    93     TInt status = iStatus.Int();    
    92 
    94 
    93     if(!status)
    95     if(!status)
    94         {
    96         {
    95         switch(iProcessingState)
    97         switch(iProcessingState)
   122                     iScaleSize += KScaleSize;
   124                     iScaleSize += KScaleSize;
   123                     ScaleBitmapL();
   125                     ScaleBitmapL();
   124                     }
   126                     }
   125                 else
   127                 else
   126                     {
   128                     {
   127                     CHAT_DP_FUNC_ENTER("CVimpstImageProcessor::RunL completed ");
   129                     TRACE("RunL completed ");
   128                     CompleteRequestL();
   130                     CompleteRequestL();
   129                     }
   131                     }
   130                 break;
   132                 break;
   131                 }  
   133                 }  
   132             default:
   134             default:
   136             }
   138             }
   137 
   139 
   138         }
   140         }
   139     else
   141     else
   140         {
   142         {
   141         CHAT_DP_FUNC_ENTER("CVimpstImageProcessor::RunL completed ");
   143         TRACE("RunL completed ");
   142         CompleteRequestL();
   144         CompleteRequestL();
   143         }
   145         }
   144 
   146 
   145     }
   147     }
   146 //-----------------------------------------------------------------------------
   148 //-----------------------------------------------------------------------------
   147 // CVimpstImageProcessor::ConvertImageToBitmapL()
   149 // CVimpstImageProcessor::ConvertImageToBitmapL()
   148 // ( Other items commented in header )
   150 // ( Other items commented in header )
   149 //-----------------------------------------------------------------------------
   151 //-----------------------------------------------------------------------------
   150 void CVimpstImageProcessor::ConvertImageToBitmapL()
   152 void CVimpstImageProcessor::ConvertImageToBitmapL()
   151     {
   153     {
       
   154 	TRACER_AUTO;
   152     TSize origSize( iImageDecoder->FrameInfo().iOverallSizeInPixels );
   155     TSize origSize( iImageDecoder->FrameInfo().iOverallSizeInPixels );
   153     ScaleSize( origSize, iTargetSize );
   156     ScaleSize( origSize, iTargetSize );
   154     TBool fullyScaleable( iImageDecoder->FrameInfo().iFlags & TFrameInfo::EFullyScaleable );
   157     TBool fullyScaleable( iImageDecoder->FrameInfo().iFlags & TFrameInfo::EFullyScaleable );
   155     TSize decodeSize( DecodeSize( origSize, iTargetSize, fullyScaleable ) );
   158     TSize decodeSize( DecodeSize( origSize, iTargetSize, fullyScaleable ) );
   156 
   159 
   168 // CVimpstImageProcessor::ScaleBitmapL()
   171 // CVimpstImageProcessor::ScaleBitmapL()
   169 // ( Other items commented in header )
   172 // ( Other items commented in header )
   170 //-----------------------------------------------------------------------------
   173 //-----------------------------------------------------------------------------
   171 void CVimpstImageProcessor::ScaleBitmapL()
   174 void CVimpstImageProcessor::ScaleBitmapL()
   172     {
   175     {
       
   176 	TRACER_AUTO;
   173     TSize currentSize( iBitmap ? iBitmap->SizeInPixels() : iTargetSize );
   177     TSize currentSize( iBitmap ? iBitmap->SizeInPixels() : iTargetSize );
   174 
   178 
   175     if( currentSize != iTargetSize )
   179     if( currentSize != iTargetSize )
   176         {
   180         {
   177         // bitmap exists and the size is wrong,
   181         // bitmap exists and the size is wrong,
   244 // CVimpstImageProcessor::StartProcessingFromDataL
   248 // CVimpstImageProcessor::StartProcessingFromDataL
   245 // ( Other items commented in header )
   249 // ( Other items commented in header )
   246 //-----------------------------------------------------------------------------
   250 //-----------------------------------------------------------------------------
   247 TInt CVimpstImageProcessor::ProcessFromDataL( const TDesC8& aImageData , const TDesC8& aMimeType)
   251 TInt CVimpstImageProcessor::ProcessFromDataL( const TDesC8& aImageData , const TDesC8& aMimeType)
   248     {
   252     {
       
   253 	TRACER_AUTO;
   249     TInt err = KErrNone;
   254     TInt err = KErrNone;
   250     if ( aMimeType.Length())
   255     if ( aMimeType.Length())
   251         {
   256         {
   252         // if the mimetype is passed then allocate the memory
   257         // if the mimetype is passed then allocate the memory
   253         iMimeType = aMimeType.AllocL();
   258         iMimeType = aMimeType.AllocL();
   276 // CVimpstImageProcessor::ProcessFromFileL
   281 // CVimpstImageProcessor::ProcessFromFileL
   277 // ( Other items commented in header )
   282 // ( Other items commented in header )
   278 //-----------------------------------------------------------------------------
   283 //-----------------------------------------------------------------------------
   279 void CVimpstImageProcessor::ProcessFromFileL( const TDesC& aFileName , const TDesC8& aMimeType)
   284 void CVimpstImageProcessor::ProcessFromFileL( const TDesC& aFileName , const TDesC8& aMimeType)
   280     {
   285     {
   281     CHAT_DP_FUNC_ENTER("CVimpstImageProcessor::ProcessFromFileL start");
   286 	TRACER_AUTO;
   282     iMimeType = aMimeType.AllocL();
   287     iMimeType = aMimeType.AllocL();
   283     iImageDecoder = NULL;
   288     iImageDecoder = NULL;
   284     iImageDecoder = CImageDecoder::FileNewL(iFs, aFileName, *iMimeType );
   289     iImageDecoder = CImageDecoder::FileNewL(iFs, aFileName, *iMimeType );
   285     iProcessingState = EConvertImageDatatoBitmap;
   290     iProcessingState = EConvertImageDatatoBitmap;
   286     RunL();
   291     RunL();
   287     CHAT_DP_FUNC_ENTER("CVimpstImageProcessor::ProcessFromFileL end ");
   292     
   288     }
   293     }
   289 
   294 
   290 //-----------------------------------------------------------------------------
   295 //-----------------------------------------------------------------------------
   291 // CVimpstImageProcessor::CancelProcessing
   296 // CVimpstImageProcessor::CancelProcessing
   292 // ( Other items commented in header )
   297 // ( Other items commented in header )
   330 // Scale to nearest (larger or equal) size with ratio 1:1, 1:2, 1:4 or 1:8
   335 // Scale to nearest (larger or equal) size with ratio 1:1, 1:2, 1:4 or 1:8
   331 //-----------------------------------------------------------------------------    
   336 //-----------------------------------------------------------------------------    
   332 TSize CVimpstImageProcessor::DecodeSize( const TSize& aSize, const TSize& aTargetSize,
   337 TSize CVimpstImageProcessor::DecodeSize( const TSize& aSize, const TSize& aTargetSize,
   333         TBool aAnyRatio )
   338         TBool aAnyRatio )
   334     {
   339     {
       
   340 	TRACER_AUTO;
   335     if( aAnyRatio || aSize == aTargetSize )
   341     if( aAnyRatio || aSize == aTargetSize )
   336         {
   342         {
   337         // decoder can scale to any ratio or the size is already correct
   343         // decoder can scale to any ratio or the size is already correct
   338         return aTargetSize;
   344         return aTargetSize;
   339         }
   345         }