3
|
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 |
// Include files
|
|
19 |
#include <BAUTILS.H>
|
|
20 |
|
|
21 |
#include "IEBgpsController.h"
|
|
22 |
#include "debug.h"
|
|
23 |
#include "ImagicConsts.h"
|
|
24 |
|
|
25 |
// ====================== MEMBER FUNCTION ================================== //
|
|
26 |
|
|
27 |
CIEBgpsController* CIEBgpsController::NewL(RFs& aFileServer,
|
|
28 |
MIEBgpsControllerObserver& aIEBgpsControllerObserver,
|
|
29 |
CIEEngineUtils& aEngineUtils,
|
|
30 |
RCriticalSection* aCritical)
|
|
31 |
{
|
|
32 |
CIEBgpsController* self = new (ELeave) CIEBgpsController(aFileServer,
|
|
33 |
aIEBgpsControllerObserver,
|
|
34 |
aEngineUtils,
|
|
35 |
aCritical);
|
|
36 |
CleanupStack::PushL(self);
|
|
37 |
self->ConstructL();
|
|
38 |
CleanupStack::Pop();
|
|
39 |
return self;
|
|
40 |
}
|
|
41 |
|
|
42 |
CIEBgpsController::CIEBgpsController(RFs& aFileServer, MIEBgpsControllerObserver& aIEBgpsControllerObserver,
|
|
43 |
CIEEngineUtils& aEngineUtils, RCriticalSection* aCritical)
|
|
44 |
:iFileServer(aFileServer),
|
|
45 |
iIEBgpsControllerObserver(aIEBgpsControllerObserver),
|
|
46 |
iFileLoader(NULL),
|
|
47 |
iIEEngineUtils(aEngineUtils),
|
|
48 |
iCritical(aCritical)
|
|
49 |
{
|
|
50 |
|
|
51 |
}
|
|
52 |
|
|
53 |
CIEBgpsController::~CIEBgpsController()
|
|
54 |
{
|
|
55 |
DP0_IMAGIC(_L("CIEBgpsController::~CIEBgpsController++"));
|
|
56 |
|
|
57 |
if(iIEBgpsClient)
|
|
58 |
{
|
|
59 |
delete iIEBgpsClient;
|
|
60 |
iIEBgpsClient = NULL;
|
|
61 |
}
|
|
62 |
|
|
63 |
iFaceCropImageDataArray.Close();
|
|
64 |
iFBCoordinateArray.Close();
|
|
65 |
|
|
66 |
DP0_IMAGIC(_L("CIEBgpsController::~CIEBgpsController--"));
|
|
67 |
}
|
|
68 |
|
|
69 |
void CIEBgpsController::ConstructL()
|
|
70 |
{
|
|
71 |
DP0_IMAGIC(_L("CIEBgpsController::ConstructL++"));
|
|
72 |
|
|
73 |
iImageIndex = 0;
|
|
74 |
iSingleTNGeneration = EFalse;
|
|
75 |
iTnCreationCancelled = EFalse;
|
|
76 |
iAllTNsDone = EFalse;
|
|
77 |
|
|
78 |
//iIEBgpsClient = CIEImageProcessing::NewL(*this);
|
|
79 |
|
|
80 |
DP0_IMAGIC(_L("CIEBgpsController::ConstructL--"));
|
|
81 |
}
|
|
82 |
|
|
83 |
|
|
84 |
void CIEBgpsController::SetFileLoader(CIEFileLoader* aFileLoader)
|
|
85 |
{
|
|
86 |
DP0_IMAGIC(_L("CIEBgpsController::SetFileLoader"));
|
|
87 |
|
|
88 |
iFileLoader = aFileLoader;
|
|
89 |
}
|
|
90 |
|
|
91 |
|
|
92 |
void CIEBgpsController::CreateImageProcessing()
|
|
93 |
{
|
|
94 |
DP0_IMAGIC(_L("CIEBgpsController::CreateImageProcessing"));
|
|
95 |
|
|
96 |
iIEBgpsClient = CIEImageProcessing::NewL(*this);
|
|
97 |
|
|
98 |
}
|
|
99 |
|
|
100 |
|
|
101 |
void CIEBgpsController::ThumbnailGenerationCompleted(TInt aErrorCode)
|
|
102 |
{
|
|
103 |
DP0_IMAGIC(_L("CIEBgpsController::ThumbnailGenerationCompleted++"));
|
|
104 |
|
|
105 |
if (aErrorCode == KErrCancel)
|
|
106 |
return;
|
|
107 |
|
|
108 |
/*CImageData* imageData = iIEBgpsControllerObserver.GetImageData(iTnCreationIndex, EImages);
|
|
109 |
TFileName filename;
|
|
110 |
imageData->GetFileName(filename, ESize512x512);
|
|
111 |
DP1_IMAGIC(_L("CFaceBrowser::BrowseFacesL 512x512TNFile = %S ++"), &filename);*/
|
|
112 |
|
|
113 |
//Single TN generation ----------->
|
|
114 |
if(aErrorCode != KErrNone)
|
|
115 |
{
|
|
116 |
DP1_IMAGIC(_L("CIEBgpsController::ThumbnailGenerationCompleted - Error in TN creation: %d"), aErrorCode);
|
|
117 |
|
|
118 |
CImageData* imageData = iIEBgpsControllerObserver.GetImageData(iTnCreationIndex);
|
|
119 |
//Mark image as corrupted so we do not try to generate TN or load it
|
|
120 |
imageData->iGridData.iCorrupted = ETrue;
|
|
121 |
|
|
122 |
//In Error case any way delete the iCorrupted Thumbnail + file we were trying to generate TN(if it is not original)
|
|
123 |
if(!iSingleFaceDetectionOn)
|
|
124 |
{
|
|
125 |
DeleteCorruptedThumbNailFile(iTNFilename);
|
|
126 |
if(iJpegFilename.Find(KPAlbTNFilePath) != KErrNotFound)
|
|
127 |
{
|
|
128 |
DeleteCorruptedThumbNailFile(iJpegFilename);
|
|
129 |
}
|
|
130 |
}
|
|
131 |
}
|
|
132 |
|
|
133 |
iSingleFaceDetectionOn = EFalse;
|
|
134 |
|
|
135 |
//If no error mark that TN was created
|
|
136 |
if(aErrorCode == KErrNone)
|
|
137 |
{
|
|
138 |
if(i512x512TNCreationOn)
|
|
139 |
{
|
|
140 |
DP0_IMAGIC(_L("CIEBgpsController::ThumbnailGenerationCompleted - i512x512TNCreationOn"));
|
|
141 |
iImageDataArray[iTnCreationIndex]->iGridData.iCorrupted = EFalse;
|
|
142 |
iImageDataArray[iTnCreationIndex]->SetImageReady(ESize512x512, ETrue);
|
|
143 |
iIEBgpsControllerObserver.SingleTNGenerationComplete(iTnCreationIndex, ESize512x512);
|
|
144 |
|
|
145 |
/*#ifdef FACE_DETECTION
|
|
146 |
TInt count = iFBCoordinateArray.Count();
|
|
147 |
for(TInt i=0; i<count; i++)
|
|
148 |
iFBCoordinateArray.Remove(0);
|
|
149 |
|
|
150 |
iSingleFBCoordinateArray = &iFBCoordinateArray;
|
|
151 |
iImageData = iIEBgpsControllerObserver.GetImageData(iTnCreationIndex, EImages);
|
|
152 |
|
|
153 |
iIEBgpsClient->StartSingleFaceDetection(iTnCreationIndex, *iSingleFBCoordinateArray, iImageData);
|
|
154 |
iSingleFaceDetectionOn = ETrue;
|
|
155 |
#endif*/
|
|
156 |
}
|
|
157 |
if(i128x128TNCreationOn)
|
|
158 |
{
|
|
159 |
DP0_IMAGIC(_L("CIEBgpsController::ThumbnailGenerationCompleted - i128x128TNCreationOn"));
|
|
160 |
iImageDataArray[iTnCreationIndex]->SetImageReady(ESize128x128, ETrue);
|
|
161 |
iIEBgpsControllerObserver.SingleTNGenerationComplete(iTnCreationIndex, ESize128x128);
|
|
162 |
}
|
|
163 |
if(i32x32TNCreationOn)
|
|
164 |
{
|
|
165 |
DP0_IMAGIC(_L("CIEBgpsController::ThumbnailGenerationCompleted - i32x32TNCreationOn"));
|
|
166 |
iImageDataArray[iTnCreationIndex]->SetImageReady(ESize32x32, ETrue);
|
|
167 |
iIEBgpsControllerObserver.SingleTNGenerationComplete(iTnCreationIndex, ESize32x32);
|
|
168 |
|
|
169 |
#ifdef FACE_DETECTION
|
|
170 |
TInt count = iFBCoordinateArray.Count();
|
|
171 |
for(TInt i=0; i<count; i++)
|
|
172 |
iFBCoordinateArray.Remove(0);
|
|
173 |
|
|
174 |
iSingleFBCoordinateArray = &iFBCoordinateArray;
|
|
175 |
iImageData = iIEBgpsControllerObserver.GetImageData(iTnCreationIndex);
|
|
176 |
|
|
177 |
//iIEBgpsClient->StartSingleFaceDetection(iTnCreationIndex, *iSingleFBCoordinateArray, iImageData);
|
|
178 |
iSingleFaceDetectionOn = ETrue;
|
|
179 |
#endif
|
|
180 |
}
|
|
181 |
}
|
|
182 |
|
|
183 |
if(aErrorCode != KErrNone || !iSingleFaceDetectionOn)
|
|
184 |
{
|
|
185 |
TThumbSize res;
|
|
186 |
iTnCreationIndex = FindMissingTN(res);
|
|
187 |
|
|
188 |
iAllTNsDone = ETrue;
|
|
189 |
//Check if all TN images are done
|
|
190 |
for(TInt i=0; i<iImageDataArray.Count(); i++)
|
|
191 |
{
|
|
192 |
if((!iImageDataArray[i]->IsImageReady(ESize512x512) ||
|
|
193 |
!iImageDataArray[i]->IsImageReady(ESize128x128) ||
|
|
194 |
!iImageDataArray[i]->IsImageReady(ESize32x32)) &&
|
|
195 |
!iImageDataArray[i]->iGridData.iCorrupted )
|
|
196 |
{
|
|
197 |
iAllTNsDone = EFalse;
|
|
198 |
DP1_IMAGIC(_L("CIEBgpsController::ThumbnailGenerationCompleted - Continue TN creation from index: %d"), i);
|
|
199 |
break;
|
|
200 |
}
|
|
201 |
}
|
|
202 |
|
|
203 |
if(!iAllTNsDone && iTnCreationIndex >= 0)
|
|
204 |
{
|
|
205 |
//Start creating thumbnails by calling TN creator
|
|
206 |
if(res == ESize512x512)
|
|
207 |
{
|
|
208 |
DP1_IMAGIC(_L("CIEBgpsController::ThumbnailGenerationCompleted - Res: ESize512x512, Index: %d"),iTnCreationIndex);
|
|
209 |
i512x512TNCreationOn = ETrue;
|
|
210 |
i128x128TNCreationOn = EFalse;
|
|
211 |
i32x32TNCreationOn = EFalse;
|
|
212 |
Generate512x512Thumbnails(iTnCreationIndex);
|
|
213 |
}
|
|
214 |
else if(res == ESize128x128)
|
|
215 |
{
|
|
216 |
DP1_IMAGIC(_L("CIEBgpsController::ThumbnailGenerationCompleted - Res: ESize128x128, Index: %d"),iTnCreationIndex);
|
|
217 |
i128x128TNCreationOn = ETrue;
|
|
218 |
i512x512TNCreationOn = EFalse;
|
|
219 |
i32x32TNCreationOn = EFalse;
|
|
220 |
Generate128x128Thumbnails(iTnCreationIndex);
|
|
221 |
}
|
|
222 |
else if(res == ESize32x32)
|
|
223 |
{
|
|
224 |
DP1_IMAGIC(_L("CIEBgpsController::ThumbnailGenerationCompleted - Res: ESize32x32, Index: %d"),iTnCreationIndex);
|
|
225 |
i32x32TNCreationOn = ETrue;
|
|
226 |
i512x512TNCreationOn = EFalse;
|
|
227 |
i128x128TNCreationOn = EFalse;
|
|
228 |
Generate32x32Thumbnails(iTnCreationIndex);
|
|
229 |
}
|
|
230 |
}
|
|
231 |
|
|
232 |
// Callback after completion of all TNs
|
|
233 |
if(iAllTNsDone)
|
|
234 |
{
|
|
235 |
i32x32TNCreationOn = EFalse;
|
|
236 |
i128x128TNCreationOn = EFalse;
|
|
237 |
i512x512TNCreationOn = EFalse;
|
|
238 |
DP0_IMAGIC(_L("CIEBgpsController::ThumbnailGenerationCompleted - All thumbnails are created, start face Detection"));
|
|
239 |
//iIEBgpsClient->StartFaceDetection(iImageDataArray);
|
|
240 |
//iBackGroundFaceDetectionOn = ETrue;
|
|
241 |
iIEBgpsControllerObserver.TNGenerationComplete(ENotDefined);
|
|
242 |
}
|
|
243 |
}
|
|
244 |
|
|
245 |
DP0_IMAGIC(_L("CIEBgpsController::ThumbnailGenerationCompleted --"));
|
|
246 |
}
|
|
247 |
|
|
248 |
|
|
249 |
void CIEBgpsController::HandleError(TInt aError)
|
|
250 |
{
|
|
251 |
DP0_IMAGIC(_L("CIEBgpsController::HandleError"));
|
|
252 |
//Handle BGPS errors here
|
|
253 |
|
|
254 |
//Cancel UI frame blinking, we can not do anythign else if BGPS is jammed??
|
|
255 |
//iIEBgpsControllerObserver.TNGenerationComplete(ENotDefined);
|
|
256 |
if(i32x32TNCreationOn || i128x128TNCreationOn || i512x512TNCreationOn)
|
|
257 |
{
|
|
258 |
DP0_IMAGIC(_L("CIEBgpsController::HandleError - Error on TN generation, try to continue"));
|
|
259 |
ThumbnailGenerationCompleted(aError);
|
|
260 |
}
|
|
261 |
else
|
|
262 |
{
|
|
263 |
iIEBgpsControllerObserver.TNGenerationComplete(ENotDefined);
|
|
264 |
}
|
|
265 |
}
|
|
266 |
|
|
267 |
void CIEBgpsController::ThumbnailGenerationCancelled(TInt /*aErrorCode*/)
|
|
268 |
{
|
|
269 |
//Start TN generation again if it was stopped
|
|
270 |
if(iTnCreationCancelled)
|
|
271 |
;//StartSingleFaceDetection();
|
|
272 |
}
|
|
273 |
|
|
274 |
void CIEBgpsController::GenerateThumbNailL(const TDes &aOrgFile, TThumbSize /*aTNResolution*/)
|
|
275 |
{
|
|
276 |
DP0_IMAGIC(_L("CIEBgpsController::GenerateThumbNailL ++"));
|
|
277 |
|
|
278 |
iSavedFileName.Copy(aOrgFile);
|
|
279 |
|
|
280 |
/*Generating Thumbnail path for 320x320 */
|
|
281 |
iIEEngineUtils.GenerateThumbnailFileName(ESize32x32,iSavedFileName,iTNFilename);
|
|
282 |
|
|
283 |
/*Creating folder if not exists */
|
|
284 |
TParse parser;
|
|
285 |
parser.Set(iTNFilename, NULL, NULL );
|
|
286 |
TFileName name = parser.NameAndExt();//image file name
|
|
287 |
TFileName tnPath = parser.DriveAndPath();
|
|
288 |
|
|
289 |
CIEEngineUtils::CreateTNFolder(iFileServer, tnPath);
|
|
290 |
|
|
291 |
/*Generating TN file with absolute path */
|
|
292 |
tnPath.Append(name);
|
|
293 |
|
|
294 |
/* TN file name with absolute path*/
|
|
295 |
iTNFilename.Copy(tnPath);
|
|
296 |
|
|
297 |
/*Set Single Thumbnail generation flag on */
|
|
298 |
iSingleTNGeneration = ETrue;
|
|
299 |
|
|
300 |
/*Generate TN for 320x320 resolution */
|
|
301 |
iLatestCreatedTNSize = ESize32x32;
|
|
302 |
iTmpImageData = CImageData::NewL();
|
|
303 |
|
|
304 |
TSize originalSize;
|
|
305 |
iIEEngineUtils.GetImageSizeL(iSavedFileName, originalSize);
|
|
306 |
|
|
307 |
DP1_IMAGIC(_L("iTNFilename: %S"), &iTNFilename);
|
|
308 |
|
|
309 |
TSize size(320, 320);
|
|
310 |
if (originalSize.iWidth && originalSize.iHeight)
|
|
311 |
{
|
|
312 |
if(originalSize.iWidth > originalSize.iHeight)
|
|
313 |
{ // Landscape
|
|
314 |
size.iHeight = 320 * originalSize.iHeight / originalSize.iWidth;
|
|
315 |
if(size.iHeight%2 != 0)
|
|
316 |
size.iHeight++;
|
|
317 |
}
|
|
318 |
else // Portrait
|
|
319 |
{
|
|
320 |
size.iWidth = 320 * originalSize.iWidth / originalSize.iHeight;
|
|
321 |
if(size.iWidth%2 != 0)
|
|
322 |
size.iWidth++;
|
|
323 |
}
|
|
324 |
}
|
|
325 |
|
|
326 |
iTmpImageData->SetSize(size);
|
|
327 |
iIEBgpsClient->GenerateTN(iSavedFileName, iTNFilename, size);
|
|
328 |
|
|
329 |
|
|
330 |
DP0_IMAGIC(_L("CIEBgpsController::GenerateThumbNailL--"));
|
|
331 |
}
|
|
332 |
|
|
333 |
|
|
334 |
//Filename array has been filled(completetely) when this function is called
|
|
335 |
void CIEBgpsController::AllFilesAddedToFilenameArrayL()
|
|
336 |
{
|
|
337 |
DP0_IMAGIC(_L("CIEBgpsController::AllFilesAddedToFilenameArrayL++"));
|
|
338 |
|
|
339 |
//Get filename array
|
|
340 |
iImageDataArray = iFileLoader->GetFileNameArray();
|
|
341 |
|
|
342 |
// Start TN generation
|
|
343 |
if(iImageDataArray.Count() > 0)
|
|
344 |
{
|
|
345 |
StartTNCreatorL();
|
|
346 |
}
|
|
347 |
|
|
348 |
DP0_IMAGIC(_L("CIEBgpsController::AllFilesAddedToFilenameArrayL--"));
|
|
349 |
}
|
|
350 |
|
|
351 |
TReal CIEBgpsController::GetAspectRatio(TInt aIndex)
|
|
352 |
{
|
|
353 |
DP0_IMAGIC(_L("CIEBgpsController::GetAspectRatio"));
|
|
354 |
|
|
355 |
iImageDataArray = iFileLoader->GetFileNameArray();
|
|
356 |
|
|
357 |
if(aIndex < iImageDataArray.Count())
|
|
358 |
{
|
|
359 |
return iImageDataArray[aIndex]->GetAspectRatio();
|
|
360 |
}
|
|
361 |
else
|
|
362 |
{
|
|
363 |
return 0;
|
|
364 |
}
|
|
365 |
}
|
|
366 |
|
|
367 |
TReal CIEBgpsController::GetFacesAspectRatio(TInt aIndex)
|
|
368 |
{
|
|
369 |
DP0_IMAGIC(_L("CIEBgpsController::GetAspectRatio"));
|
|
370 |
|
|
371 |
iImageDataArray = iFileLoader->GetFacesFileNameArray();
|
|
372 |
|
|
373 |
if(aIndex < iImageDataArray.Count())
|
|
374 |
{
|
|
375 |
return iImageDataArray[aIndex]->GetAspectRatio();
|
|
376 |
}
|
|
377 |
else
|
|
378 |
return 0;
|
|
379 |
}
|
|
380 |
|
|
381 |
void CIEBgpsController::GenerateTNForEditedImage(const TFileName aEditedFileName, const TReal aAspectRatio)
|
|
382 |
{
|
|
383 |
DP0_IMAGIC(_L("CIEBgpsController::GenerateTNForEditedImage++"));
|
|
384 |
|
|
385 |
iSavedFileName.Copy(aEditedFileName);
|
|
386 |
|
|
387 |
//set iSingleTNGeneration mode on
|
|
388 |
iSingleTNGeneration = ETrue;
|
|
389 |
iAspectRatio = aAspectRatio;
|
|
390 |
|
|
391 |
/*Generating 128x128 Thumbnail path */
|
|
392 |
iIEEngineUtils.GenerateThumbnailFileName(ESize128x128, aEditedFileName, iTNFilename);
|
|
393 |
|
|
394 |
//Create new imagedata instance to be appended to filename array
|
|
395 |
iTmpImageData = CImageData::NewL();
|
|
396 |
iTmpImageData->SetSize(TSize(128 * iAspectRatio, 128)); // TODO no size info
|
|
397 |
|
|
398 |
iLatestCreatedTNSize = ESize128x128;
|
|
399 |
iIEBgpsClient->GenerateTN(aEditedFileName, iTNFilename, TSize(128,128));
|
|
400 |
//iIEBgpsClient->GenerateTN(aEditedFileName, iTNFilename, TSize(32,32));//mikares32
|
|
401 |
|
|
402 |
DP0_IMAGIC(_L("CIEBgpsController::GenerateTNForEditedImage--"));
|
|
403 |
}
|
|
404 |
|
|
405 |
void CIEBgpsController::FilenameArrayCountChanged(const RArray<CImageData*>& aImageDataArray)
|
|
406 |
{
|
|
407 |
iImageDataArray = aImageDataArray;
|
|
408 |
//iIEBgpsControllerObserver.TotalNumberOfImagesChanged(iImageDataArray.Count());
|
|
409 |
}
|
|
410 |
|
|
411 |
CImageData* CIEBgpsController::GetImageData(const TInt aIndex)
|
|
412 |
{
|
|
413 |
DP1_IMAGIC(_L("CIEBgpsController::GetImageData %d"), aIndex);
|
|
414 |
|
|
415 |
return (aIndex <= iImageDataArray.Count()) ? iImageDataArray[aIndex] : NULL;
|
|
416 |
}
|
|
417 |
|
|
418 |
void CIEBgpsController::GetFaceCoordinates(const TFileName aTNFileName, RArray<TRect>& aFaceCoordinateArray)
|
|
419 |
{
|
|
420 |
DP0_IMAGIC(_L("CIEBgpsController::GetFaceCoordinates"));
|
|
421 |
aFaceCoordinateArray.Reset();
|
|
422 |
//iIEBgpsClient->FindFaces(aTNFileName, aFaceCoordinateArray);
|
|
423 |
}
|
|
424 |
|
|
425 |
//If background face Detection is still continuing, we have to use GetSingleFaceCoordinates() function to get face coordinates
|
|
426 |
void CIEBgpsController::GetSingleFaceCoordinates(TInt aIndex, const TFileName /*aTNFileName*/, RArray<TRect>& aFaceCoordinateArray)
|
|
427 |
{
|
|
428 |
DP0_IMAGIC(_L("CIEBgpsController::GetSingleFaceCoordinates++"));
|
|
429 |
|
|
430 |
if(i128x128TNCreationOn || i512x512TNCreationOn || i32x32TNCreationOn)
|
|
431 |
{
|
|
432 |
iTnCreationCancelled = ETrue;
|
|
433 |
CancelTNGeneration();
|
|
434 |
i128x128TNCreationOn = EFalse;
|
|
435 |
i512x512TNCreationOn = EFalse;
|
|
436 |
i32x32TNCreationOn = EFalse;
|
|
437 |
}
|
|
438 |
|
|
439 |
iSingleFBIndex = aIndex;
|
|
440 |
iSingleFBCoordinateArray = &aFaceCoordinateArray;
|
|
441 |
|
|
442 |
//If BGPS face Detection was on, we have to stop it first. Othervice we can contiue directly to StartSingleFaceDetection()
|
|
443 |
if(iBackGroundFaceDetectionOn)
|
|
444 |
{//We just cancel background face Detection, when cancel is complete we get callback to StartSingleFaceDetection()
|
|
445 |
//iIEBgpsClient->CancelFaceDetection();
|
|
446 |
iBackGroundFaceDetectionOn = EFalse;
|
|
447 |
}
|
|
448 |
else
|
|
449 |
{
|
|
450 |
//StartSingleFaceDetection();
|
|
451 |
}
|
|
452 |
|
|
453 |
DP0_IMAGIC(_L("CIEBgpsController::GetSingleFaceCoordinates--"));
|
|
454 |
}
|
|
455 |
|
|
456 |
/* Creating Single Thumbnails for Editing. After editing the image we are
|
|
457 |
* genereating the thumbnails 128x128 & 640x480 resolution*/
|
|
458 |
void CIEBgpsController::CreateSingleTNL()
|
|
459 |
{
|
|
460 |
DP0_IMAGIC(_L("CIEBgpsController::CreateSingleTN++"));
|
|
461 |
|
|
462 |
if(iLatestCreatedTNSize == ESize128x128)
|
|
463 |
{
|
|
464 |
//Create and set data to image data item
|
|
465 |
iTmpImageData->SetFileNameL(iSavedFileName);
|
|
466 |
iImageDataArray[iImageIndex]->SetImageReady(EFullSize, ETrue);
|
|
467 |
iImageDataArray[iImageIndex]->SetImageReady(ESize32x32, EFalse);
|
|
468 |
iImageDataArray[iImageIndex]->SetImageReady(ESize512x512, EFalse);
|
|
469 |
iImageDataArray[iImageIndex]->SetImageReady(ESize128x128, ETrue);
|
|
470 |
|
|
471 |
//Insert new image data to filename array
|
|
472 |
iFileLoader->AddNewImage(iTmpImageData, iImageIndex);
|
|
473 |
iImageDataArray = iFileLoader->GetFileNameArray();
|
|
474 |
//iIEBgpsControllerObserver.TotalNumberOfImagesChanged(iImageDataArray.Count());
|
|
475 |
|
|
476 |
/*Generating 320x320 Tumbnail path */
|
|
477 |
iIEEngineUtils.GenerateThumbnailFileName(ESize32x32,iSavedFileName,iTNFilename);
|
|
478 |
iIEBgpsControllerObserver.TNGenerationComplete(ESize128x128);
|
|
479 |
|
|
480 |
iLatestCreatedTNSize = ESize32x32;
|
|
481 |
TSize size;
|
|
482 |
|
|
483 |
TInt w, h;
|
|
484 |
if(iImageDataArray[iImageIndex]->GetAspectRatio() > 1)
|
|
485 |
{//Landscape
|
|
486 |
w=320;
|
|
487 |
h = 320/iImageDataArray[iImageIndex]->GetAspectRatio();
|
|
488 |
if(h%2 != 0)
|
|
489 |
h++;
|
|
490 |
}
|
|
491 |
else//Portrait
|
|
492 |
{
|
|
493 |
h = 320;
|
|
494 |
w = 320 * iImageDataArray[iImageIndex]->GetAspectRatio();
|
|
495 |
if(w%2 != 0)
|
|
496 |
w++;
|
|
497 |
}
|
|
498 |
size.iHeight = h;
|
|
499 |
size.iWidth = w;
|
|
500 |
|
|
501 |
iTNSize = size;
|
|
502 |
iIEBgpsClient->GenerateTN(iSavedFileName, iTNFilename, size);
|
|
503 |
}
|
|
504 |
|
|
505 |
else if(iLatestCreatedTNSize == ESize32x32)
|
|
506 |
{
|
|
507 |
iImageDataArray = iFileLoader->GetFileNameArray();
|
|
508 |
iImageDataArray[iImageIndex]->SetImageReady(ESize32x32, ETrue);
|
|
509 |
//iSingleTNGeneration = EFalse;
|
|
510 |
|
|
511 |
iIEBgpsControllerObserver.TNGenerationComplete(ESize32x32);
|
|
512 |
|
|
513 |
TSize size;
|
|
514 |
size.iHeight = 512;
|
|
515 |
size.iWidth = 512;
|
|
516 |
|
|
517 |
iIEEngineUtils.GenerateThumbnailFileName(ESize512x512, iSavedFileName, iTNFilename);
|
|
518 |
|
|
519 |
iTNSize = size;
|
|
520 |
iIEBgpsClient->GenerateTN(iSavedFileName, iTNFilename, size);
|
|
521 |
|
|
522 |
iLatestCreatedTNSize = ESize512x512;
|
|
523 |
}
|
|
524 |
|
|
525 |
//TN creation complete
|
|
526 |
else
|
|
527 |
{
|
|
528 |
iSingleTNGeneration = EFalse;
|
|
529 |
|
|
530 |
iImageDataArray[iImageIndex]->SetImageReady(ESize512x512, ETrue);
|
|
531 |
|
|
532 |
//Insert new image data to filename array
|
|
533 |
iFileLoader->ModifyImageData(iTmpImageData, iImageIndex);
|
|
534 |
|
|
535 |
//Call observer/AppUI class about completing TN creation
|
|
536 |
iIEBgpsControllerObserver.TNGenerationComplete(ENotDefined);
|
|
537 |
}
|
|
538 |
|
|
539 |
DP0_IMAGIC(_L("CIEBgpsController::CreateSingleTN--"));
|
|
540 |
}
|
|
541 |
|
|
542 |
void CIEBgpsController::DeleteCorruptedThumbNailFile(TFileName aFileName)
|
|
543 |
{
|
|
544 |
DP0_IMAGIC(_L("CIEBgpsController::DeleteCorruptedThumbNailFile++"));
|
|
545 |
|
|
546 |
//Checking for if we generated Imgaic TN already from iCorrupted file and delete it
|
|
547 |
//if(aFileName.Find(KPAlbTNFilePath) != KErrNotFound)
|
|
548 |
if(BaflUtils::FileExists(iFileServer, aFileName))
|
|
549 |
{
|
|
550 |
TInt err = BaflUtils::DeleteFile(iFileServer, aFileName);
|
|
551 |
DP2_IMAGIC(_L("CIEBgpsController::DeleteCorruptedThumbNailFile - file found: %S, err:%d"), &aFileName, err);
|
|
552 |
}
|
|
553 |
|
|
554 |
DP0_IMAGIC(_L("CIEBgpsController::DeleteCorruptedThumbNailFile--"));
|
|
555 |
}
|
|
556 |
|
|
557 |
//Finds optimal size for 128x128 TN creation
|
|
558 |
void CIEBgpsController::CheckOptimalFileFor128x128TnCreation(TInt aIndex, TFileName& aFileName)
|
|
559 |
{
|
|
560 |
DP0_IMAGIC(_L("CIEBgpsController::CheckOptimalFileForTnCreation++"));
|
|
561 |
|
|
562 |
//TFileName tmpName;
|
|
563 |
//iImageDataArray[aIndex]->GetFileName(tmpName, E512x512Thumbnail);
|
|
564 |
if(iImageDataArray[aIndex]->IsImageReady(ESize512x512))
|
|
565 |
//if(BaflUtils::FileExists(iFileServer, tmpName))
|
|
566 |
{
|
|
567 |
iImageDataArray[aIndex]->GetFileName(aFileName, ESize512x512);
|
|
568 |
DP1_IMAGIC(_L("CIEBgpsController::CheckFileNmaesExitst - filename exits: %S"), &aFileName);
|
|
569 |
}
|
|
570 |
else//(iFileNameData[aIndex]->IsImageReady(EOriginalImage))
|
|
571 |
{
|
|
572 |
iImageDataArray[aIndex]->GetFileName(aFileName, EFullSize);
|
|
573 |
DP1_IMAGIC(_L("CIEBgpsController::CheckFileNmaesExitst - filename exits: %S"), &aFileName);
|
|
574 |
}
|
|
575 |
|
|
576 |
DP0_IMAGIC(_L("CIEBgpsController::CheckOptimalFileForTnCreation--"));
|
|
577 |
}
|
|
578 |
|
|
579 |
//Finds optimal size for 32x32 TN creation
|
|
580 |
void CIEBgpsController::CheckOptimalFileFor32x32TnCreation(TInt aIndex, TFileName& aFileName)
|
|
581 |
{
|
|
582 |
DP0_IMAGIC(_L("CIEBgpsController::CheckOptimalFileForTnCreation++"));
|
|
583 |
if(iImageDataArray[aIndex]->IsImageReady(ESize128x128))
|
|
584 |
{
|
|
585 |
iImageDataArray[aIndex]->GetFileName(aFileName, ESize128x128);
|
|
586 |
DP1_IMAGIC(_L("CIEBgpsController::CheckFileNmaesExitst - filename exits: %S"), &aFileName);
|
|
587 |
}
|
|
588 |
|
|
589 |
/* else if(iImageDataArray[aIndex]->IsImageReady(E128x96Thumbnail))
|
|
590 |
{
|
|
591 |
iImageDataArray[aIndex]->GetFileName(aFileName, E128x96Thumbnail);
|
|
592 |
DP1_IMAGIC(_L("CIEBgpsController::CheckFileNmaesExitst - filename did not exits: %S"), &aFileName);
|
|
593 |
}*/
|
|
594 |
else if(iImageDataArray[aIndex]->IsImageReady(ESize512x512))
|
|
595 |
|
|
596 |
{
|
|
597 |
iImageDataArray[aIndex]->GetFileName(aFileName, ESize512x512);
|
|
598 |
DP1_IMAGIC(_L("CIEBgpsController::CheckFileNmaesExitst - filename exits: %S"), &aFileName);
|
|
599 |
}
|
|
600 |
else//(iFileNameData[aIndex]->iMG_FileExist)
|
|
601 |
{
|
|
602 |
//DP1_IMAGIC(_L("CIEBgpsController::CheckFileNmaesExitst - filename OK: %S"), &aFilename);
|
|
603 |
iImageDataArray[aIndex]->GetFileName(aFileName, EFullSize);
|
|
604 |
DP1_IMAGIC(_L("CIEBgpsController::CheckFileNmaesExitst - filename exits: %S"), &aFileName);
|
|
605 |
}
|
|
606 |
|
|
607 |
DP0_IMAGIC(_L("CIEBgpsController::CheckOptimalFileForTnCreation--"));
|
|
608 |
}
|
|
609 |
|
|
610 |
void CIEBgpsController::Generate128x128Thumbnails(TInt aIndex)
|
|
611 |
{
|
|
612 |
DP0_IMAGIC(_L("CIEBgpsController::Generate128x128Thumbnails++"));
|
|
613 |
//DP1_IMAGIC(_L("CIEBgpsController::Generate128x128Thumbnails - New TN to be created: %S"), &iImageDataArray[aIndex]->iIETN_128x128_Filename);
|
|
614 |
iImageDataArray[aIndex]->GetFileName(iTNFilename, ESize128x128);
|
|
615 |
iImageDataArray[aIndex]->GetFileName(iJpegFilename, EFullSize);
|
|
616 |
CheckOptimalFileFor128x128TnCreation(aIndex,iJpegFilename);
|
|
617 |
#ifdef USE_64X64_BITMAP_TN
|
|
618 |
TSize size(64,64);
|
|
619 |
#else
|
|
620 |
TSize size(128,128);
|
|
621 |
#endif
|
|
622 |
|
|
623 |
iIEBgpsClient->GenerateTN(iJpegFilename, iTNFilename, size);
|
|
624 |
|
|
625 |
DP0_IMAGIC(_L("CIEBgpsController::Generate128x128Thumbnails--"));
|
|
626 |
}
|
|
627 |
|
|
628 |
void CIEBgpsController::Generate32x32Thumbnails(TInt aIndex)
|
|
629 |
{
|
|
630 |
DP0_IMAGIC(_L("CIEBgpsController::Generate32x32Thumbnails++"));
|
|
631 |
// DP1_IMAGIC(_L("CIEBgpsController::Generate320x320Thumbnails - New TN to be created: %S"), &iImageDataArray[aIndex]->iIETN_32x32_Filename);
|
|
632 |
iImageDataArray[aIndex]->GetFileName(iTNFilename, ESize32x32);
|
|
633 |
iImageDataArray[aIndex]->GetFileName(iJpegFilename, EFullSize);
|
|
634 |
CheckOptimalFileFor32x32TnCreation(aIndex,iJpegFilename);
|
|
635 |
TSize size(32,32);
|
|
636 |
iIEBgpsClient->GenerateTN(iJpegFilename, iTNFilename, size);
|
|
637 |
|
|
638 |
DP0_IMAGIC(_L("CIEBgpsController::Generate32x32Thumbnails--"));
|
|
639 |
}
|
|
640 |
|
|
641 |
void CIEBgpsController::Generate512x512Thumbnails(TInt aIndex)
|
|
642 |
{
|
|
643 |
DP0_IMAGIC(_L("CIEBgpsController::Generate512x512Thumbnails++"));
|
|
644 |
//DP1_IMAGIC(_L("CIEBgpsController::Generate640x480Thumbnails - New TN to be created: %S"), &iImageDataArray[aIndex]->iIETN_512x512_Filename);
|
|
645 |
|
|
646 |
iImageDataArray[aIndex]->GetFileName(iTNFilename, ESize512x512);
|
|
647 |
iImageDataArray[aIndex]->GetFileName(iJpegFilename, EFullSize);
|
|
648 |
TSize size(512,512);
|
|
649 |
iIEBgpsClient->GenerateTN(iJpegFilename, iTNFilename, size);
|
|
650 |
|
|
651 |
DP0_IMAGIC(_L("CIEBgpsController::Generate512x512Thumbnails--"));
|
|
652 |
}
|
|
653 |
|
|
654 |
|
|
655 |
/*TReal CIEBgpsController::ReadAspectRatioL(TFileName& aFileName)
|
|
656 |
{
|
|
657 |
DP0_IMAGIC(_L("CIEBgpsController::ReadAspectRatio++"));
|
|
658 |
|
|
659 |
CImageDecoder* imageDecoder = NULL;
|
|
660 |
imageDecoder = CImageDecoder::FileNewL(iFileServer, aFileName);
|
|
661 |
|
|
662 |
TFrameInfo frameInfo = imageDecoder->FrameInfo();
|
|
663 |
TSize size = frameInfo.iFrameCoordsInPixels.Size();
|
|
664 |
|
|
665 |
if(imageDecoder)
|
|
666 |
{
|
|
667 |
delete imageDecoder;
|
|
668 |
imageDecoder = NULL;
|
|
669 |
}
|
|
670 |
|
|
671 |
DP0_IMAGIC(_L("CIEBgpsController::ReadAspectRatio--"));
|
|
672 |
|
|
673 |
return (TReal)size.iWidth/(TReal)size.iHeight;
|
|
674 |
|
|
675 |
}*/
|
|
676 |
|
|
677 |
void CIEBgpsController::StartTNCreatorL()
|
|
678 |
{
|
|
679 |
DP0_IMAGIC(_L("CIEBgpsController::StartTNCreator++"));
|
|
680 |
|
|
681 |
TThumbSize res;
|
|
682 |
if((iTnCreationIndex = FindMissingTN(res)) < 0) {
|
|
683 |
iIEBgpsControllerObserver.TNGenerationComplete(ENotDefined);
|
|
684 |
return;
|
|
685 |
}
|
|
686 |
|
|
687 |
//start creating thumbnails by calling TN creator
|
|
688 |
//callback when one TN is created is done to CIEBgpsController::ThumbnailGenerationCompleted function
|
|
689 |
if(res == ESize512x512)
|
|
690 |
{
|
|
691 |
i512x512TNCreationOn = ETrue;
|
|
692 |
i128x128TNCreationOn = EFalse;
|
|
693 |
i32x32TNCreationOn = EFalse;
|
|
694 |
Generate512x512Thumbnails(iTnCreationIndex);
|
|
695 |
}
|
|
696 |
else if(res == ESize128x128)
|
|
697 |
{
|
|
698 |
i512x512TNCreationOn = EFalse;
|
|
699 |
i128x128TNCreationOn = ETrue;
|
|
700 |
i32x32TNCreationOn = EFalse;
|
|
701 |
Generate128x128Thumbnails(iTnCreationIndex);
|
|
702 |
}
|
|
703 |
else if(res == ESize32x32)
|
|
704 |
{
|
|
705 |
i512x512TNCreationOn = EFalse;
|
|
706 |
i128x128TNCreationOn = EFalse;
|
|
707 |
i32x32TNCreationOn = ETrue;
|
|
708 |
Generate32x32Thumbnails(iTnCreationIndex);
|
|
709 |
}
|
|
710 |
else
|
|
711 |
{
|
|
712 |
//All TNs were already done
|
|
713 |
iIEBgpsControllerObserver.TNGenerationComplete(ENotDefined);
|
|
714 |
//We complete face Detection here also because if there was no new images added -> no need to start face Detection in BGPS
|
|
715 |
iIEBgpsControllerObserver.FaceDetectionComplete();
|
|
716 |
}
|
|
717 |
|
|
718 |
DP0_IMAGIC(_L("CIEBgpsController::StartTNCreator--"));
|
|
719 |
}
|
|
720 |
|
|
721 |
//Returns index of first missing TN from any TN size
|
|
722 |
TInt CIEBgpsController::FindMissingTN(TThumbSize& aRes)
|
|
723 |
{
|
|
724 |
DP0_IMAGIC(_L("CIEBgpsController::FindMissingTN++"));
|
|
725 |
|
|
726 |
TInt currentIndex = iIEBgpsControllerObserver.GetSelectedImageIndex();
|
|
727 |
CImageData* gridData = iIEBgpsControllerObserver.GetImageData(currentIndex);
|
|
728 |
|
|
729 |
TInt tnIndex = -1;
|
|
730 |
|
|
731 |
for(TInt i = 0; i<iImageDataArray.Count(); i++)
|
|
732 |
{
|
|
733 |
// Check to positive and negative direction from current picture
|
|
734 |
for (TInt j=0; j<2; j++)
|
|
735 |
{
|
|
736 |
// Calculate image index
|
|
737 |
tnIndex = currentIndex + (j ? i : -i);
|
|
738 |
|
|
739 |
// Check that index is valid
|
|
740 |
if (tnIndex < 0 || tnIndex >= iImageDataArray.Count())
|
|
741 |
continue;
|
|
742 |
|
|
743 |
CImageData* imageData = iIEBgpsControllerObserver.GetImageData(tnIndex);
|
|
744 |
|
|
745 |
//Mark image as corrupted so we do not try to generate TN or load it
|
|
746 |
if(imageData->iGridData.iCorrupted)
|
|
747 |
{
|
|
748 |
tnIndex = -20/*KErrCorrupt*/;
|
|
749 |
continue;
|
|
750 |
}
|
|
751 |
|
|
752 |
if(!iImageDataArray[tnIndex]->IsImageReady(ESize512x512))
|
|
753 |
{
|
|
754 |
TFileName filename;
|
|
755 |
iImageDataArray[tnIndex]->GetFileName(filename,ESize512x512);
|
|
756 |
DP1_IMAGIC(_L("CIEBgpsController::FindMissingTN - Filename to be crated: %S"), &filename);
|
|
757 |
aRes = ESize512x512;
|
|
758 |
//break;
|
|
759 |
return tnIndex;
|
|
760 |
}
|
|
761 |
if(!iImageDataArray[tnIndex]->IsImageReady(ESize128x128))
|
|
762 |
{
|
|
763 |
TFileName filename;
|
|
764 |
iImageDataArray[tnIndex]->GetFileName(filename,ESize128x128);
|
|
765 |
DP1_IMAGIC(_L("CIEBgpsController::FindMissingTN - Filename to be crated: %S"), &filename);
|
|
766 |
aRes = ESize128x128;
|
|
767 |
//break;
|
|
768 |
return tnIndex;
|
|
769 |
}
|
|
770 |
if(!iImageDataArray[tnIndex]->IsImageReady(ESize32x32))
|
|
771 |
{
|
|
772 |
TFileName filename;
|
|
773 |
iImageDataArray[tnIndex]->GetFileName(filename,ESize32x32);
|
|
774 |
DP1_IMAGIC(_L("CIEBgpsController::FindMissingTN - Filename to be crated: %S"), &filename);
|
|
775 |
aRes = ESize32x32;
|
|
776 |
//break;
|
|
777 |
return tnIndex;
|
|
778 |
}
|
|
779 |
}
|
|
780 |
}
|
|
781 |
DP0_IMAGIC(_L("CIEBgpsController::FindMissingTN--"));
|
|
782 |
return -1;
|
|
783 |
}
|
|
784 |
|
|
785 |
void CIEBgpsController::CancelTNGeneration()
|
|
786 |
{
|
|
787 |
DP0_IMAGIC(_L("CIEBgpsController::CancelTNGeneration"));
|
|
788 |
|
|
789 |
iIEBgpsClient->CancelTNGeneration();
|
|
790 |
}
|
|
791 |
|
|
792 |
|
|
793 |
// EOF
|