mmplugins/imagingplugins/codecs/JPEGCodec/Exif/ExifEditUtility.h
changeset 0 40261b775718
equal deleted inserted replaced
-1:000000000000 0:40261b775718
       
     1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #ifndef EXIFEDITUTILITY_H
       
    17 #define EXIFEDITUTILITY_H
       
    18 
       
    19 #include <e32base.h>
       
    20 #include <icl/imagecodec.h>
       
    21 
       
    22 const TUint KBlockIdLength = 2;		// jpeg block id is two bytes long
       
    23 const TUint KBlockSizeLength = 2;	// jpeg block size is two bytes long
       
    24 const TUint KBlockIdAndSizeLength = KBlockIdLength + KBlockSizeLength;
       
    25 
       
    26 enum TConvertState
       
    27 	{
       
    28 	EEmpty,			// nothing has been done on the file
       
    29 	EReadComplete,	// use to say that the file has been read and can be written
       
    30 	
       
    31 	// write enums
       
    32 	EStartWrite,
       
    33 	EWriteReadHeader,
       
    34 	EWriteWriteHeader,
       
    35 	EReadThumbnail,
       
    36 	EWriteReadThumbnail,
       
    37 	EWriteConvertExif,
       
    38 	EWriteWriteExif,
       
    39 	EWriteTrailer,
       
    40 	EWriteReadMainImage,
       
    41 	ECancelled,
       
    42 	ECopying
       
    43 	};
       
    44 
       
    45 enum TCopyState
       
    46 	{
       
    47 	ERead,
       
    48 	EWrite,
       
    49 	EReadJpegBlockInfo
       
    50 	};
       
    51 
       
    52 //ExifTag class defines the Tags found in the Exif specification.
       
    53 class CExifData;
       
    54 class CScaledJpegGenerator;
       
    55 class MExifSource;
       
    56 class MExifDest;
       
    57 
       
    58 class CExifEditUtility : public CActive
       
    59 	{
       
    60 public:
       
    61 	static CExifEditUtility* NewL(MExifSource* aSource, MExifDest* aDest, TBool aIgnoreExifMetadataProcessing = EFalse);
       
    62 	~CExifEditUtility();
       
    63 
       
    64 	void ReadSourceL();
       
    65 	void WriteDestL(TBool aEncodeThumbnail, const TSize& aSize, TBool aPreserveImage, TBool aMaintainAspectRatio, TRequestStatus* aNotifier);
       
    66 	
       
    67 	MExifMetadata* ExifMetadata();
       
    68 
       
    69 protected:
       
    70 	CExifEditUtility(TBool aIgnoreExifMetadataProcessing);
       
    71 
       
    72 	void ProcessCommandL();
       
    73 	void DoCancel();
       
    74 
       
    75 private:
       
    76 	void ConstructL(MExifSource* aSource, MExifDest* aDest);
       
    77 
       
    78 	void InitReadL();
       
    79 
       
    80 	// asynchronous notification methods
       
    81 
       
    82 	TBool DoWriteConvertExifL();
       
    83 	TBool DoWriteReadThumbnailL();
       
    84 	TBool DoReadThumbnailL();
       
    85 	TBool DoWriteComplete();
       
    86 	TBool DoCreateMainImageL();
       
    87 	TConvertState DoCopyNextBlockL();
       
    88 
       
    89 	TBool DoCopyBlockL(TUint aStart, TInt aLength, TConvertState aNextStep, TBool aCombineTables = EFalse);
       
    90 	TBool DoWriteScaledImageL();
       
    91 
       
    92 	TBool DoWriteDestBufferL();
       
    93 
       
    94 	void RunL();
       
    95 	TInt RunError(TInt aError);
       
    96 	
       
    97 	void DoReadL();
       
    98 	void SetUpTablesL();	
       
    99 	void AppendTableDataL(RBuf8& aTables, const TDesC8& aData);
       
   100 	void HandleJpegBlockL(const TDesC8& aPrependedData);
       
   101 	void UpdateImageSizeTagsL();
       
   102 	
       
   103 private:
       
   104 	// configuration data
       
   105 	MExifSource* iSource;		/**< The source that will be read*/
       
   106 	MExifDest* iDest;			/**< The destination */
       
   107 	TSize iSize;				/**< size of the image in the destination */
       
   108 	TBool iPreserveImage; 		/**< ETrue if the image should not be changed*/
       
   109 	TBool iMaintainAspectRatio; 		/**< ETrue if the aspect ratio should be maintained*/
       
   110 	TBool iEncodeThumbnail;		/**< ETrue if the destination file should embed a thumbnail*/
       
   111 	TRequestStatus* iNotifier;	/**< the Active object to notify when the transform is performed*/
       
   112 
       
   113 	CExifTransform* iExifData;
       
   114 	CScaledJpegGenerator* iScaledJpegGenerator;
       
   115 
       
   116 	TUint iExifBlockSize;		// size of the exif block in the source	
       
   117 	TUint iHeaderBlockSize;		// size of the chunk of data that is before the exif data
       
   118 	TInt iTrailerBlockSize;		// size of the chunk of data that is after the exif data
       
   119 	TUint iTrailerOffset;		// offset to the trailing data in the source
       
   120 	
       
   121 	TBufPtr8 iIOBufferPtr;
       
   122 
       
   123 	TConvertState iState;
       
   124 
       
   125 	TCopyState iCurCopyState;
       
   126 	TConvertState iNextStep;
       
   127 	TInt iCopyLength;
       
   128 	TUint iCurrentWriteBufferIndex;
       
   129 	
       
   130 	RBuf8 iDHTTables;			// stores the DHT tables that must be combined into one for exif
       
   131 	RBuf8 iDQTTables;			// stores the DQT tables that must be combined into one for exif
       
   132 	
       
   133 	TInt iCurrentJpegBlockType;
       
   134 	TUint iCurrentJpegBlockSize;
       
   135 	TBool iDestIsExif;
       
   136 	TBuf8<KBlockIdAndSizeLength> iLookupSlackBuff; // for holding of block id slack when copying main image
       
   137 	RBuf8 iTempCopyBuffer;  // this buffer is used when we need to combine possibly incorrect block data
       
   138 	TBool iIgnoreExifMetadataProcessing; //don't parse any EXIF data if this flag is set, and writes transparently from src to dest.
       
   139 	TBool iConvertToJfif; //Source is to be converted to a JFIF by the transform (usually because source Exif block is corrupt).
       
   140 	};
       
   141 
       
   142 #endif //EXIFEDITUTILITY_H