|
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 __IEFACEBROWSER_H__ |
|
19 #define __IEFACEBROWSER_H__ |
|
20 |
|
21 #include <e32base.h> |
|
22 #include <f32file.h> |
|
23 #include <f32file.h> |
|
24 //#include <IDLImageProcessing.h> |
|
25 #include <ImageConversion.h> |
|
26 //#include <IclExtJpegApi.h> |
|
27 |
|
28 #include "IEBgpsInfo.h" |
|
29 #include "IEImageData.h" |
|
30 #include "IEImageEncoder.h" |
|
31 #include "IEImageDecoder.h" |
|
32 #include "IEEngineUtils.h" |
|
33 |
|
34 // Foraward class declaration |
|
35 class CIEImageDecoder; |
|
36 class CIEImageEncoder; |
|
37 |
|
38 // Class declaration |
|
39 class MIEFaceBrowserObserver |
|
40 { |
|
41 public: |
|
42 virtual void FaceBrowsingComplete() = 0; |
|
43 virtual void FaceBrowsingError(TInt aError) = 0; |
|
44 virtual void FaceSingleFaceBrowsingComplete() = 0; |
|
45 |
|
46 }; |
|
47 |
|
48 class CFaceBrowser : public CActive, |
|
49 public MDecodingObserver, |
|
50 public MEncodingObserver |
|
51 #ifdef IDL_BGPS |
|
52 , public MIDLObserver |
|
53 #endif |
|
54 { |
|
55 private: |
|
56 enum TFaceBrowsingState |
|
57 { |
|
58 EStateIdle = 0, |
|
59 EFaceBrowsingRunning, |
|
60 ESingleFaceBrowsingRunning, |
|
61 EFaceBrowsingPaused, |
|
62 EFaceBrowsingStopped, |
|
63 EFaceBrowsingCompleted, |
|
64 EFaceCroppingRunning, |
|
65 EEncodingFaces, |
|
66 EFaceCroppingCompleted, |
|
67 ESingleFaceBrowsingComplete, |
|
68 ECreatingBitmap |
|
69 }; |
|
70 /* |
|
71 enum TFaceBrowsingMode |
|
72 { |
|
73 EBrowseModeNone = 0, |
|
74 EBrowseModeSingleImage, |
|
75 EBrowseModeBulkImages, |
|
76 EModeCroppingFaces |
|
77 }; |
|
78 */ |
|
79 class TCroppedFaces |
|
80 { |
|
81 public: |
|
82 HBufC8* iYuvdata; |
|
83 TFileName iFileName; |
|
84 TSize iCroppedSize; |
|
85 }; |
|
86 public: // First phase constructor and destructor |
|
87 static CFaceBrowser* NewLC(RFs& aFileServer, MIEFaceBrowserObserver& aFaceBrowserObserver); |
|
88 virtual ~CFaceBrowser(); |
|
89 |
|
90 private: // Second phase constuctor and C++ default constructor |
|
91 void ConstructL(); |
|
92 CFaceBrowser(RFs& aFileServer, MIEFaceBrowserObserver& aFaceBrowserObserver); |
|
93 |
|
94 protected: // From CActive |
|
95 void RunL(); |
|
96 void DoCancel(); |
|
97 TInt RunError(TInt aError); |
|
98 |
|
99 public: // From MDecodingObserver |
|
100 void YuvImageReady(TInt aError); |
|
101 void BitmapReady(TInt aError); |
|
102 |
|
103 public: // From MEncodingObserver |
|
104 void JpegImageReady(TInt aError); |
|
105 |
|
106 public: // From MIDLObserver |
|
107 inline void ProcessingComplete(TDesC8& /*aData*/){}; |
|
108 inline void HandleError(TInt /*aError*/){}; |
|
109 |
|
110 public: // New public functions |
|
111 void StartFaceBrowsing(RArray<CImageData*> aImageDataArray); |
|
112 void StartSingleFaceBrowsing(TInt aIndex, RArray<TRect>* aImageCoordArray, CImageData* aImageData); |
|
113 void CancelFaceBrowsing(); |
|
114 TInt FindFaces(const TFileName a128x128TNFileName, RArray<TRect>& aCordArray); |
|
115 TInt GetNumberOfFaces(const TFileName aFile); |
|
116 void StartFaceCropping(RArray<CImageData*> aImageDataArray, RArray<TFileName>* aCroppedFilenames); |
|
117 void CancelFaceCropping(); |
|
118 TInt AddFaceCoordinate(const TFileName a128x128TNFileName, RArray<TRect>& aCordArray); |
|
119 TInt RemoveFaceCoordinate(const TFileName a128x128TNFileName, RArray<TRect>& aCordArray); |
|
120 HBufC8* ReadExifMakerNoteL(const TDes &aFileName, TInt& aSize); |
|
121 |
|
122 |
|
123 private: // Internal functions |
|
124 |
|
125 // Common functions |
|
126 #ifdef IDL_BGPS |
|
127 void InitializeL(const TIDLFeatures aIDLFeature, const TSize aInSize, const TSize aOutSize, TAny* aValue, TBool aInBufferCreate); |
|
128 #endif |
|
129 void PrepareInOutBuffersL(TBool aInBufferCreate, const TInt aInBufSize, TBool aOutBufferCreate, const TInt aOutBufSize); |
|
130 TFileName MakeTNFileName(const TFileName aImageFileName, TBool a128TNFile, TBool a320TNFileName); |
|
131 void Cleanup(); |
|
132 void Cleanup2(); |
|
133 void ContinueLoop(); |
|
134 TBool CheckOddSize(const TSize aSize); |
|
135 |
|
136 //New function to handle RGB conversion |
|
137 void ContinueFBAfterImageConversionL(); |
|
138 void ConvertRgb2Yuv(CFbsBitmap* aSourceBitmap, TUint8* aYuv, TInt aBytesPerPixel, const TSize aSize); |
|
139 |
|
140 // Face browsing related functions |
|
141 void BrowseFacesL(CImageData* aImageData); |
|
142 #ifdef IDL_BGPS |
|
143 void BrowseFacesL(TFileName a128x128TNFileName, RArray<TRect>& aFaceCoordinates); |
|
144 #endif |
|
145 void GetFaceCoordinates(TInt& aNumberOfFaces, RArray<TRect>& aCordArray); |
|
146 //void WriteFaceCoordinatesToExifDataL(const TFileName a128x128TNFileName, RArray<TRect>& aCordArray); |
|
147 //void IsCoordinateExistsL(const TFileName a128x128TNFileName, TBool& aBool); |
|
148 //void ReadFaceCoordinatesL(const TFileName a128x128TNFileName, RArray<TRect>& aCordArray); |
|
149 |
|
150 // Face cropping related functions |
|
151 void CropFacesL(CImageData* aImageData); |
|
152 void CropFacesL(const TFileName aImageFileName, RArray<TRect>& aFaceCoordinates); |
|
153 TInt MakeFacesDir(const TFileName aImageName); |
|
154 TRect GetFaceRect(const TSize aOrgImageSize, const TSize aRelImageSize, const TRect aFaceRect); |
|
155 void EncodeFaceL(const TCroppedFaces aCroppedFace); |
|
156 void CheckCroppedFaceFileNames(); |
|
157 |
|
158 // Face detection |
|
159 void WriteFaceCoordToExif(TInt numOfFaces, RArray<TRect> faceCoordinates); |
|
160 |
|
161 private: // Data members |
|
162 RFs& iFileServer; |
|
163 MIEFaceBrowserObserver& iFaceBrowserObserver; |
|
164 |
|
165 RArray<CImageData*> iImageDataArray; |
|
166 RArray<TCroppedFaces> iFaceYuvDataArray; |
|
167 RArray<TRect> iFaceCoordinates; |
|
168 RArray<TRect>* iTempFaceCoordinates; |
|
169 |
|
170 CIEImageDecoder* iImageDecoder; |
|
171 CIEImageEncoder* iImageEncoder; |
|
172 CImageDecoder* iSymbianImageDecoder; |
|
173 |
|
174 #ifdef IDL_BGPS |
|
175 CIDLImageProcessing* iIDLImageProcessor; |
|
176 #endif |
|
177 |
|
178 HBufC8* iInputBuffer; |
|
179 HBufC8* iOutputBuffer; |
|
180 |
|
181 CImageData* iCurrentImageData; |
|
182 |
|
183 TFaceBrowsingState iBrowsingState; |
|
184 TFaceBrowsingState iPrevBrowsingState; |
|
185 // TFaceBrowsingMode iBrowseMode; |
|
186 |
|
187 TSize iSize; |
|
188 |
|
189 TInt iNumberOfImages; |
|
190 TInt iNumberOfImagesBrowsed; |
|
191 TInt iSingleFaceBrowsingIndex; |
|
192 TInt iNumberOfFacesCropped; |
|
193 TInt iNumberOfFaces; |
|
194 |
|
195 TFileName iCurrentImageFileName; |
|
196 TFileName iCurrent512x512TNFileName; |
|
197 TInt iTotalNumberOfFaces; |
|
198 CIEEngineUtils iUtils; |
|
199 |
|
200 RArray<TFileName>* iCroppedFilenames; |
|
201 //RArray<TRect> iImageCoordArray; |
|
202 CFbsBitmap* iBitmap; |
|
203 }; |
|
204 |
|
205 #endif // __IEFACEBROWSER_H__ |