IEBgps/inc/IETNGenerator.h
changeset 3 93fff7023be8
equal deleted inserted replaced
2:e1e28b0273b0 3:93fff7023be8
       
     1 /*
       
     2 * Copyright (c) 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: Juha Kauppinen, Mika Hokkanen
       
    13 * 
       
    14 * Description: Photo Browser
       
    15 *
       
    16 */
       
    17 
       
    18 #ifndef __IETNGENERATORAO_H__
       
    19 #define __IETNGENERATORAO_H__
       
    20 
       
    21 #include <e32base.h>
       
    22 #include <f32file.h>
       
    23 #include <BitmapTransforms.h>
       
    24 #include <ImageConversion.h>
       
    25 
       
    26 #include "IEBgpServerSession.h"
       
    27 #include <IEBgpsInfo.h>
       
    28 #include <ICLExif.h> 
       
    29 #include <exifmodify.h>
       
    30 #include <exifread.h>
       
    31 #include "debug.h"
       
    32 
       
    33 class CImageDecoder;
       
    34 class CFbsBitmap;
       
    35 
       
    36 //#define USE_EXT_JPEG_DEC
       
    37 
       
    38 #ifdef USE_EXT_JPEG_DEC
       
    39 class CExtJpegDecoder;
       
    40 #endif
       
    41 
       
    42 
       
    43 #define DECODE_FROM_BUFFER
       
    44 
       
    45 // CONSTANTS
       
    46 const TInt KMimeStringLength = 256;
       
    47 
       
    48 class  CIETNGeneratorAO : public CActive
       
    49 {
       
    50 public:
       
    51 	static CIETNGeneratorAO* NewL(RFs& aFileServer, MIEThumbNailObserver &aObserver);
       
    52 	virtual ~CIETNGeneratorAO();
       
    53 	
       
    54 private:
       
    55 	void ConstructL();
       
    56 	
       
    57 	CIETNGeneratorAO(RFs& aFileServer, MIEThumbNailObserver &aObserver);
       
    58 
       
    59 
       
    60 protected:  // Type declarations
       
    61     enum TIETNConvertStatus
       
    62     {
       
    63     	ENone = 0,
       
    64         EDecoding,
       
    65         EScaling,
       
    66         EEncoding,
       
    67         EReady
       
    68     };
       
    69 	
       
    70 public:
       
    71 
       
    72 	void SetImageArray(	RArray<CImageData*> aImageArray);
       
    73 	void CancelOutStaningRequests();
       
    74 	void DeleteObjects();
       
    75 	void CancelRequestsAndDeleteObjects();
       
    76 	
       
    77 public: // From CActive
       
    78 	void RunL();
       
    79 	void DoCancel();
       
    80 	TInt RunError(TInt aError);
       
    81 	
       
    82 public: // Other public functions
       
    83  
       
    84 	RArray<CImageData*> iImageArray;
       
    85 	void CreateThumbnailL(const TDes& aSourceFile, const TDes& aThumbnailFile, const TSize &aSize);
       
    86 	void CreateThumbnailL(const TDes& aSourceFile, const TDes& aThumbnailFile, const TSize &aSize, CFbsBitmap* a512x512TnBitmap);
       
    87 	
       
    88 	
       
    89 private:
       
    90 	void SetJpegImageDataL();
       
    91 	void WriteExifDataL(const TDes &aFilename, TSize aSize);
       
    92 	void DecodeL();
       
    93 	void EncodeL();
       
    94 	void ScaleL();
       
    95 	void TargetDecodingSize(const TSize aTgtSize, TSize& aSrcSize);
       
    96 	TBool IsLargeThumbnail(const TSize& aResolution) const;
       
    97 	TBool IsJPEG(const TSize& aResolution) const;
       
    98 	
       
    99 private:
       
   100   
       
   101     RFs&                  iFileServer;
       
   102 #ifdef USE_EXT_JPEG_DEC
       
   103     CExtJpegDecoder*      iImageDecoder;
       
   104 #else
       
   105     CImageDecoder*        iImageDecoder;
       
   106 #endif
       
   107     CImageEncoder*        iImageEncoder;
       
   108     CFbsBitmap*           iBitmap;
       
   109     CBitmapScaler*        iBitmapScaler;
       
   110     TIETNConvertStatus    iConvertStatus;   /** Convert status */
       
   111     MIEThumbNailObserver& iThumbnailObserver;
       
   112     TFileName             iSourceFileName;
       
   113     TFileName             iThumbnailFileName;
       
   114     TBuf8<KMimeStringLength> iMimeString;   /** The source file Mime-string */
       
   115     TSize                 iSourceSize;
       
   116     CFrameImageData*      iFrameImageData;
       
   117     TSize                 iThumbnailSize;
       
   118     TTime                 iSourceTime;      /** Source file time */
       
   119     TInt                  iError;  
       
   120     CFbsBitmap*           i512x512TnBitmap;
       
   121     TUid                  decoderUid;
       
   122 
       
   123 #ifdef DECODE_FROM_BUFFER
       
   124     HBufC8*               iSourceData;
       
   125 #endif
       
   126 
       
   127 };
       
   128 
       
   129 
       
   130 #endif