diff -r e1e28b0273b0 -r 93fff7023be8 IEBgps/inc/IEFaceBrowser.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/IEBgps/inc/IEFaceBrowser.h Fri Oct 15 10:18:29 2010 +0900 @@ -0,0 +1,205 @@ +/* +* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). +* All rights reserved. +* This component and the accompanying materials are made available +* under the terms of "Eclipse Public License v1.0" +* which accompanies this distribution, and is available +* at the URL "http://www.eclipse.org/legal/epl-v10.html". +* +* Initial Contributors: +* Nokia Corporation - initial contribution. +* +* Contributors: Juha Kauppinen, Mika Hokkanen +* +* Description: Photo Browser +* +*/ + +#ifndef __IEFACEBROWSER_H__ +#define __IEFACEBROWSER_H__ + +#include +#include +#include +//#include +#include +//#include + +#include "IEBgpsInfo.h" +#include "IEImageData.h" +#include "IEImageEncoder.h" +#include "IEImageDecoder.h" +#include "IEEngineUtils.h" + +// Foraward class declaration +class CIEImageDecoder; +class CIEImageEncoder; + +// Class declaration +class MIEFaceBrowserObserver +{ +public: + virtual void FaceBrowsingComplete() = 0; + virtual void FaceBrowsingError(TInt aError) = 0; + virtual void FaceSingleFaceBrowsingComplete() = 0; + +}; + +class CFaceBrowser : public CActive, + public MDecodingObserver, + public MEncodingObserver +#ifdef IDL_BGPS + , public MIDLObserver +#endif +{ +private: + enum TFaceBrowsingState + { + EStateIdle = 0, + EFaceBrowsingRunning, + ESingleFaceBrowsingRunning, + EFaceBrowsingPaused, + EFaceBrowsingStopped, + EFaceBrowsingCompleted, + EFaceCroppingRunning, + EEncodingFaces, + EFaceCroppingCompleted, + ESingleFaceBrowsingComplete, + ECreatingBitmap + }; +/* + enum TFaceBrowsingMode + { + EBrowseModeNone = 0, + EBrowseModeSingleImage, + EBrowseModeBulkImages, + EModeCroppingFaces + }; +*/ + class TCroppedFaces + { + public: + HBufC8* iYuvdata; + TFileName iFileName; + TSize iCroppedSize; + }; +public: // First phase constructor and destructor + static CFaceBrowser* NewLC(RFs& aFileServer, MIEFaceBrowserObserver& aFaceBrowserObserver); + virtual ~CFaceBrowser(); + +private: // Second phase constuctor and C++ default constructor + void ConstructL(); + CFaceBrowser(RFs& aFileServer, MIEFaceBrowserObserver& aFaceBrowserObserver); + +protected: // From CActive + void RunL(); + void DoCancel(); + TInt RunError(TInt aError); + +public: // From MDecodingObserver + void YuvImageReady(TInt aError); + void BitmapReady(TInt aError); + +public: // From MEncodingObserver + void JpegImageReady(TInt aError); + +public: // From MIDLObserver + inline void ProcessingComplete(TDesC8& /*aData*/){}; + inline void HandleError(TInt /*aError*/){}; + +public: // New public functions + void StartFaceBrowsing(RArray aImageDataArray); + void StartSingleFaceBrowsing(TInt aIndex, RArray* aImageCoordArray, CImageData* aImageData); + void CancelFaceBrowsing(); + TInt FindFaces(const TFileName a128x128TNFileName, RArray& aCordArray); + TInt GetNumberOfFaces(const TFileName aFile); + void StartFaceCropping(RArray aImageDataArray, RArray* aCroppedFilenames); + void CancelFaceCropping(); + TInt AddFaceCoordinate(const TFileName a128x128TNFileName, RArray& aCordArray); + TInt RemoveFaceCoordinate(const TFileName a128x128TNFileName, RArray& aCordArray); + HBufC8* ReadExifMakerNoteL(const TDes &aFileName, TInt& aSize); + + +private: // Internal functions + + // Common functions +#ifdef IDL_BGPS + void InitializeL(const TIDLFeatures aIDLFeature, const TSize aInSize, const TSize aOutSize, TAny* aValue, TBool aInBufferCreate); +#endif + void PrepareInOutBuffersL(TBool aInBufferCreate, const TInt aInBufSize, TBool aOutBufferCreate, const TInt aOutBufSize); + TFileName MakeTNFileName(const TFileName aImageFileName, TBool a128TNFile, TBool a320TNFileName); + void Cleanup(); + void Cleanup2(); + void ContinueLoop(); + TBool CheckOddSize(const TSize aSize); + + //New function to handle RGB conversion + void ContinueFBAfterImageConversionL(); + void ConvertRgb2Yuv(CFbsBitmap* aSourceBitmap, TUint8* aYuv, TInt aBytesPerPixel, const TSize aSize); + + // Face browsing related functions + void BrowseFacesL(CImageData* aImageData); +#ifdef IDL_BGPS + void BrowseFacesL(TFileName a128x128TNFileName, RArray& aFaceCoordinates); +#endif + void GetFaceCoordinates(TInt& aNumberOfFaces, RArray& aCordArray); + //void WriteFaceCoordinatesToExifDataL(const TFileName a128x128TNFileName, RArray& aCordArray); + //void IsCoordinateExistsL(const TFileName a128x128TNFileName, TBool& aBool); + //void ReadFaceCoordinatesL(const TFileName a128x128TNFileName, RArray& aCordArray); + + // Face cropping related functions + void CropFacesL(CImageData* aImageData); + void CropFacesL(const TFileName aImageFileName, RArray& aFaceCoordinates); + TInt MakeFacesDir(const TFileName aImageName); + TRect GetFaceRect(const TSize aOrgImageSize, const TSize aRelImageSize, const TRect aFaceRect); + void EncodeFaceL(const TCroppedFaces aCroppedFace); + void CheckCroppedFaceFileNames(); + + // Face detection + void WriteFaceCoordToExif(TInt numOfFaces, RArray faceCoordinates); + +private: // Data members + RFs& iFileServer; + MIEFaceBrowserObserver& iFaceBrowserObserver; + + RArray iImageDataArray; + RArray iFaceYuvDataArray; + RArray iFaceCoordinates; + RArray* iTempFaceCoordinates; + + CIEImageDecoder* iImageDecoder; + CIEImageEncoder* iImageEncoder; + CImageDecoder* iSymbianImageDecoder; + +#ifdef IDL_BGPS + CIDLImageProcessing* iIDLImageProcessor; +#endif + + HBufC8* iInputBuffer; + HBufC8* iOutputBuffer; + + CImageData* iCurrentImageData; + + TFaceBrowsingState iBrowsingState; + TFaceBrowsingState iPrevBrowsingState; +// TFaceBrowsingMode iBrowseMode; + + TSize iSize; + + TInt iNumberOfImages; + TInt iNumberOfImagesBrowsed; + TInt iSingleFaceBrowsingIndex; + TInt iNumberOfFacesCropped; + TInt iNumberOfFaces; + + TFileName iCurrentImageFileName; + TFileName iCurrent512x512TNFileName; + TInt iTotalNumberOfFaces; + CIEEngineUtils iUtils; + + RArray* iCroppedFilenames; + //RArray iImageCoordArray; + CFbsBitmap* iBitmap; +}; + +#endif // __IEFACEBROWSER_H__