webengine/wmlengine/src/image/include/Epoc32ImageDecoder.h
branchRCL_3
changeset 94 919f36ff910f
equal deleted inserted replaced
93:79859ed3eea9 94:919f36ff910f
       
     1 /*
       
     2 * Copyright (c) 2000 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 the License "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 *
       
    16 */
       
    17 
       
    18 
       
    19 /* CEpoc32ImageDecoder class
       
    20  *
       
    21  * Every non-canned image has an image decoder associated with it. This is opened
       
    22  * when the image is created in order to get the size. This is an asynchronous
       
    23  * operation; "MiuoOpenComplete" is called when the opening is complete.
       
    24  *
       
    25  * The first time an image is displayed, "Decode" is called, which starts the
       
    26  * asynchrounous decoding process. When this completes, the image object is
       
    27  * updated with the decoded image, which then causes the new image to be
       
    28  * displayed.
       
    29  *
       
    30  * A decode is also done every time the frame number of an animated image is
       
    31  * changed.
       
    32  */
       
    33 
       
    34 #ifndef EPOC32IMAGEDECODER_H
       
    35 #define EPOC32IMAGEDECODER_H
       
    36 
       
    37 // INCLUDES
       
    38 
       
    39 #include <e32base.h>
       
    40 #include <ImageConversion.h>
       
    41 
       
    42 #include "nw_image_epoc32simpleimage.h"
       
    43    
       
    44 // FORWARD DECLARATIONS
       
    45 // #define INCREMENTAL_IMAGE_ON
       
    46 
       
    47 class CFbsBitmap;
       
    48 
       
    49 // CLASS DECLARATION
       
    50 
       
    51 class CEpoc32ImageDecoder : public CActive
       
    52     {
       
    53     public:
       
    54         static CEpoc32ImageDecoder* NewL(NW_Image_Epoc32Simple_t* aImage);
       
    55         void ConstructL();
       
    56         void RunL();
       
    57         void DoCancel() {iImageConverter->Cancel();}
       
    58 
       
    59         virtual ~CEpoc32ImageDecoder();
       
    60 
       
    61         /*!
       
    62          @function Decode
       
    63          @discussion Opens data into fbsBitmap. 
       
    64          */
       
    65         void Open();
       
    66 
       
    67         /*!
       
    68          @function Decode
       
    69          @discussion Converts data into fbsBitmap. 
       
    70          */
       
    71         TInt Decode(); 
       
    72 
       
    73         NW_Bool IncrementImage(NW_Bool& startingFrameSequenceOver);
       
    74 
       
    75         /*!
       
    76          @function PartialNextChunkL
       
    77          @discussion new chunk of raw data
       
    78          */
       
    79         void PartialNextChunkL( NW_Buffer_t* aNextChunk );
       
    80 
       
    81         /*!
       
    82          @function ImageDataComplete
       
    83          @discussion end of raw data
       
    84          */
       
    85         void ImageDataComplete();
       
    86 
       
    87 
       
    88         /*!
       
    89          @function ResetImage
       
    90          @discussion display the last frame of an animated image
       
    91          */
       
    92 		void ResetImage();
       
    93 
       
    94         /*!
       
    95          @function Finished
       
    96          @discussion Finished animating image. 
       
    97          */
       
    98 		TBool Finished();
       
    99 
       
   100 
       
   101         inline void SetImageHasNotBeenOpened (NW_Bool aImageHasNotBeenOpened) { iImageHasNotBeenOpened = aImageHasNotBeenOpened; }
       
   102     
       
   103         enum TDecoderState   
       
   104         {  
       
   105         ID_IDLE = 0,  
       
   106         ID_INITIALIZING,  
       
   107         ID_DECODING,  
       
   108         // state added to check if the decoding is already complete  
       
   109         ID_DECODE_COMPLETE  
       
   110         };     
       
   111         /*  
       
   112         @function getDecoderState  
       
   113         @discussion Return the current state of the decoder   
       
   114         */  
       
   115         
       
   116         inline TDecoderState getDecoderState() { return iState; }  
       
   117 
       
   118     private:
       
   119 
       
   120         void DoDecodeL(); 
       
   121 
       
   122         CEpoc32ImageDecoder(NW_Image_Epoc32Simple_t* aImage);
       
   123 
       
   124         /*!
       
   125         @function OpenComplete
       
   126 
       
   127         @discussion Called when the image file has been opened
       
   128         */
       
   129         void OpenComplete();
       
   130 
       
   131         /*!
       
   132         @function ConvertComplete
       
   133 
       
   134         @discussion Called when conversion process performed on the bitmap is complete
       
   135         */
       
   136         void ConvertComplete();
       
   137 
       
   138         /*!
       
   139         @function CreateComplete
       
   140 
       
   141         @discussion Called when the file in which the bitmap is to be saved has been created 
       
   142         */
       
   143         void CreateComplete( TInt aError );
       
   144 
       
   145         TDisplayMode GetDisplayMode( TFrameInfo& aFrameInfo );
       
   146 
       
   147         void CheckAnimation();
       
   148         void DeleteImageConverterBitmapMask();
       
   149         TInt16 GetLoopCount();
       
   150 
       
   151         /*
       
   152          * imageSizeCheck: This compares the original image size with
       
   153          * that specified in the <img src = ".." width="" height="">. Then
       
   154          * creates bit map accordingly. The value is return true if the 
       
   155          * <img> tag attribute values need to be used.
       
   156          */
       
   157 
       
   158          NW_Bool ImageSizeCheck(TSize iFrameInfoOverallSize, TSize* sizeSet);
       
   159          TInt ImgAttrInfo();
       
   160 		 TInt CheckForDRMImage();
       
   161 
       
   162     private:
       
   163         enum TDecoderState iState; // Current decoder operation 
       
   164 
       
   165         CBufferedImageDecoder* iImageConverter;  // Connection to media server
       
   166         
       
   167         NW_Image_Epoc32Simple_t* iImage;// OOC image
       
   168         TPtrC8 iImageDataPtr;           // Raw unconverted image data
       
   169         TFrameInfo iFrameInfo;          // Info about image from media server
       
   170         NW_Bool iIsAnimated;            // NW_TRUE if more than one frame in image
       
   171         TUint iCurrentFrame;            // Number of current frame displayed
       
   172         CFbsBitmap* iBitmap;            // Decoded bitmap
       
   173         CFbsBitmap* iMask;              // Decoded bitmap mask
       
   174         NW_Bool iImageHasNotBeenOpened; // NW_TRUE the first time an image is opened
       
   175         TBool  iMoreData;               // iMoreData
       
   176         TBool  iFirstFrameComplete;     // first frame complete
       
   177         TBool  iRawDataComplete;        // we've got all the raw data
       
   178         RFs iRfs;                       // A dummy parameter required by the Symbian API
       
   179 		TUint8 *iDRMOutBuf;             //Outputput buffer for the DRM decryption.
       
   180         TBool iFinished;				// Finished animating image.
       
   181     };
       
   182 
       
   183 #endif