photosgallery/viewframework/texturemanager/inc/glxbitmapdecoderwrapper.h
branchRCL_3
changeset 60 5b3385a43d68
child 75 01504893d9cb
equal deleted inserted replaced
59:8e5f6eea9c9f 60:5b3385a43d68
       
     1 /*
       
     2 * Copyright (c) 2008-2009 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:    Texture Manager component/Decodes the Image in step for large images
       
    15  *
       
    16 */
       
    17 
       
    18 
       
    19 
       
    20 
       
    21 #ifndef C_GLXBITMAPDECODERWRAPPER_H
       
    22 #define C_GLXBITMAPDECODERWRAPPER_H
       
    23 
       
    24 // INCLUDE FILES
       
    25 #include<alf/alftimedvalue.h>
       
    26 #include <IclExtJpegApi.h>  // For CExtJpegDecoder
       
    27 
       
    28 /**
       
    29  * Observer interface used to be notified when texture bitmap   is completed.
       
    30  */
       
    31 NONSHARABLE_CLASS( MGlxBitmapDecoderObserver )
       
    32         {
       
    33         public:
       
    34             /**
       
    35              * Called when the content of the texture is changed.
       
    36              * @param aHasContent Whether the texture now has content.
       
    37              */
       
    38             virtual void HandleBitmapDecodedL(TInt aThumbnailIndex,CFbsBitmap* aBitmap) = 0;
       
    39         };
       
    40 /**
       
    41  * This class does the decoding of the images in steps depending on the size of the images .
       
    42  * this is a wrapper class, doesn't actually decode the images.
       
    43  */
       
    44 
       
    45 class CGlxBitmapDecoderWrapper: public CActive
       
    46     {
       
    47 public:
       
    48     /*This Enums specifies the state of the Decoding*/
       
    49     enum TDecoderState
       
    50         {
       
    51         ESTate0, ESTate1,ESTateFinal
       
    52         };  
       
    53     /*This Enums specifies the size of the images*/
       
    54     enum TImageLevel
       
    55         {
       
    56         ELevel0, ELevel1,ELevel2
       
    57         }; 
       
    58     /**
       
    59      * Two-phased constructor
       
    60      * @param aObserver:The Observer contains the CGlxTextureManagerImpl Object
       
    61      * @return Constructed object
       
    62      */
       
    63     static CGlxBitmapDecoderWrapper* NewL(MGlxBitmapDecoderObserver* aObserver);
       
    64 
       
    65     /**
       
    66      * Destructor
       
    67      */
       
    68     ~CGlxBitmapDecoderWrapper();
       
    69 
       
    70     /**
       
    71      * intiates the Decoding the Image and updates the no:of steps to decode
       
    72      * @param aSourceFileName :contains the file name
       
    73      * @param aindex:contains the index value
       
    74      */
       
    75     void DoDecodeImageL(const TDesC & aSourceFileName,TInt aIndex);
       
    76 
       
    77     /**
       
    78      * starts the decoding and updates the state of the decoding
       
    79      */
       
    80     void DecodeImageL();
       
    81     /**
       
    82      * Request free memory with Out of Memory Monitor
       
    83      * @param aBytesRequested : Request for free memory in Bytes
       
    84      */
       
    85     TInt OOMRequestFreeMemoryL( TInt aBytesRequested);
       
    86 
       
    87 public:    
       
    88     /**
       
    89      * Standard Active object functions
       
    90      */
       
    91     virtual void RunL();
       
    92     virtual void DoCancel();
       
    93 
       
    94 private:
       
    95     /**
       
    96      * Constructor
       
    97      */
       
    98     CGlxBitmapDecoderWrapper();
       
    99     
       
   100     /**
       
   101      * Second-phase constuction 
       
   102      */
       
   103     void ConstructL(MGlxBitmapDecoderObserver* aObserver);
       
   104     
       
   105     /**
       
   106      * If the image format is non jpeg, then we need to calculate as per
       
   107      * reduction factor and reduced size as what the decoder is going to return us
       
   108      * This function returns if that needs to be done. 
       
   109      */
       
   110     TBool DoesMimeTypeNeedsRecalculateL();
       
   111     
       
   112     /**
       
   113      * Recalculate the size for png/bmp as decoder fails to 
       
   114      * decode for desired size 
       
   115      */
       
   116     TSize ReCalculateSizeL();
       
   117 
       
   118 private:    
       
   119     /* Contains the TextureManagerImpl object,calls the HandleBitmapDecoded*/
       
   120     MGlxBitmapDecoderObserver* iObserver;
       
   121     /*Specifies the Decoder */
       
   122     CImageDecoder* iImageDecoder; // decoder from ICL API
       
   123     /*Contains the Thumbnail Index*/
       
   124     TInt iThumbnailIndex;
       
   125     /*Contains the Bitmap generated*/
       
   126     CFbsBitmap* iBitmap;
       
   127     /*contains the original size of the image*/
       
   128     TAlfRealSize iOriginalSize;
       
   129     /*A handle to a file server session.*/ 
       
   130     RFs iFs;
       
   131     /*To store the target image size*/
       
   132     TSize iTargetBitmapSize;
       
   133     /*To store the image uri path*/ 
       
   134     HBufC* iImagePath;                     
       
   135 #ifdef _DEBUG
       
   136     TTime iStartTime;
       
   137     TTime iStopTime;
       
   138 #endif
       
   139     };
       
   140 
       
   141 #endif //C_GLXBITMAPDECODERWRAPPER_H