mobilemessaging/msgmedia/src/MsgImageInfo.cpp
changeset 0 72b543305e3a
equal deleted inserted replaced
-1:000000000000 0:72b543305e3a
       
     1 /*
       
     2 * Copyright (c) 2005 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:  
       
    15 *           Messaging Image Info class.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // ========== INCLUDE FILES ================================
       
    22 
       
    23 #include <e32std.h>
       
    24 
       
    25 #include <imageconversion.h> // CImageDecoder
       
    26 #include <icl/imagedata.h>   // TFrameInfo
       
    27 
       
    28 #include "MsgImageInfo.h"
       
    29 #include "MsgMediaInfo.h"
       
    30 #include "MsgMedia.hrh"
       
    31 
       
    32 // ========== EXTERNAL DATA STRUCTURES =====================
       
    33 
       
    34 // ========== EXTERNAL FUNCTION PROTOTYPES =================
       
    35 
       
    36 // ========== CONSTANTS ====================================
       
    37 
       
    38 // ========== MACROS =======================================
       
    39 
       
    40 // ========== LOCAL CONSTANTS AND MACROS ===================
       
    41 
       
    42 // ========== MODULE DATA STRUCTURES =======================
       
    43 
       
    44 // ========== LOCAL FUNCTION PROTOTYPES ====================
       
    45 
       
    46 // ========== LOCAL FUNCTIONS ==============================
       
    47 
       
    48 // ========== MEMBER FUNCTIONS =============================
       
    49 
       
    50 // ---------------------------------------------------------
       
    51 // CMsgImageInfo::NewL
       
    52 //
       
    53 // Factory method.
       
    54 // ---------------------------------------------------------
       
    55 //
       
    56 EXPORT_C CMsgImageInfo* CMsgImageInfo::NewL( RFile& aFile, TDataType& aMimeType )
       
    57     {
       
    58     CMsgImageInfo* self = new ( ELeave ) CMsgImageInfo( aMimeType );
       
    59     CleanupStack::PushL( self );
       
    60     self->ConstructL( aFile );
       
    61     CleanupStack::Pop( self );
       
    62     return self;
       
    63     }
       
    64 
       
    65 // ---------------------------------------------------------
       
    66 // CMsgImageInfo::CMsgImageInfo
       
    67 //
       
    68 // Constructor.
       
    69 // ---------------------------------------------------------
       
    70 //
       
    71 CMsgImageInfo::CMsgImageInfo( TDataType& aMimeType ) :
       
    72     CMsgMediaInfo( aMimeType, EMsgMediaImage ),
       
    73     iDelay( 0 ),
       
    74     iFrames( 0 ),
       
    75     iBitsPerPixel( 0 ),
       
    76     iOverallSizeInPixels( 0, 0 ),
       
    77     iFrameFlags( 0 )
       
    78     {
       
    79     }
       
    80 
       
    81 
       
    82 // ---------------------------------------------------------
       
    83 // CMsgImageInfo::CMsgImageInfo
       
    84 //
       
    85 // Destructor.
       
    86 // ---------------------------------------------------------
       
    87 //
       
    88 CMsgImageInfo::~CMsgImageInfo()
       
    89     {
       
    90     }
       
    91 
       
    92 // ---------------------------------------------------------
       
    93 // CMsgImageInfo::ConstructL
       
    94 //
       
    95 // 2nd phase constructor.
       
    96 // ---------------------------------------------------------
       
    97 //
       
    98 void CMsgImageInfo::ConstructL( RFile& aFile )
       
    99     {
       
   100     CMsgMediaInfo::ConstructL( aFile );
       
   101     }
       
   102 
       
   103 // -----------------------------------------------------------------------------
       
   104 // CMsgImageInfo::DoCancel
       
   105 // 
       
   106 // -----------------------------------------------------------------------------
       
   107 //
       
   108 void CMsgImageInfo::DoCancel()
       
   109     {
       
   110     CMsgMediaInfo::DoCancel();
       
   111     }
       
   112         
       
   113 // -----------------------------------------------------------------------------
       
   114 // CMsgImageInfo::RunL
       
   115 // 
       
   116 // -----------------------------------------------------------------------------
       
   117 //
       
   118 void CMsgImageInfo::RunL()
       
   119     {
       
   120     iParseError = iStatus.Int();
       
   121     if ( !iParseError )
       
   122         {
       
   123         FreezeRights();
       
   124         ResolveImageInfoL( iFile );
       
   125         iParsed = ETrue;
       
   126         }
       
   127     CompleteObserver();
       
   128     }
       
   129 
       
   130 // ---------------------------------------------------------
       
   131 // CMsgImageInfo::ResolveImageInfoL
       
   132 //
       
   133 // ---------------------------------------------------------
       
   134 //
       
   135 void CMsgImageInfo::ResolveImageInfoL( RFile& aFile )
       
   136     {
       
   137     CImageDecoder* imageDecoder
       
   138         = CImageDecoder::FileNewL( aFile, ContentAccess::EPeek );
       
   139     
       
   140     // If we survive from this we have legal imagefile. Thus no need to further checking.
       
   141     
       
   142     // Information of first (or only) frame
       
   143     TFrameInfo frameInfo = imageDecoder->FrameInfo();
       
   144 
       
   145     iFrames = imageDecoder->FrameCount();
       
   146 
       
   147     iBitsPerPixel = frameInfo.iBitsPerPixel;
       
   148     iOverallSizeInPixels = frameInfo.iOverallSizeInPixels;
       
   149 
       
   150     //iFrameFlags = frameInfo.iFlags;
       
   151     if ( frameInfo.iFlags & TFrameInfo::EFullyScaleable )
       
   152         {
       
   153         iFrameFlags |= EFullyScalable;
       
   154         }
       
   155     if ( frameInfo.iFlags & TFrameInfo::ETransparencyPossible )
       
   156         {
       
   157         iFrameFlags |= ETransparent;
       
   158         }
       
   159 
       
   160     if ( iFrames > 1 )
       
   161         {
       
   162         iDelay = I64INT( frameInfo.iDelay.Int64() / 1000 );
       
   163         for ( TInt frame = 0;  frame < iFrames ; frame++ )
       
   164             {
       
   165             frameInfo = imageDecoder->FrameInfo( frame );
       
   166             TInt delay = I64INT( frameInfo.iDelay.Int64() / 1000 );
       
   167             iDuration += delay;
       
   168             }
       
   169         }
       
   170     else
       
   171         {
       
   172         iDelay = 0;
       
   173         iDuration = 0;
       
   174         }
       
   175     delete imageDecoder;
       
   176     }