|
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 <ImageConversion.h> //CImageDecoder |
|
19 #include <FBS.H> //CFbsBitmap |
|
20 #include <BAUTILS.H> |
|
21 //#include <IEBGPSTrace.h> |
|
22 |
|
23 #include "IETNGenerator.h" |
|
24 #include "IEBgpServerSession.h" |
|
25 #include <hal.h> |
|
26 #include "ImagicConsts.h" |
|
27 #include "ieengineutils.h" |
|
28 |
|
29 _LIT8(KMimeJpeg, "image/jpeg"); |
|
30 _LIT8(KMimePng, "image/png"); |
|
31 |
|
32 #define DO_NOT_USE_SCALING |
|
33 |
|
34 |
|
35 |
|
36 CIETNGeneratorAO* CIETNGeneratorAO::NewL(RFs& aFileServer, MIEThumbNailObserver &aObserver) |
|
37 { |
|
38 CIETNGeneratorAO* self = new (ELeave) CIETNGeneratorAO(aFileServer, aObserver); |
|
39 CleanupStack::PushL(self); |
|
40 self->ConstructL(); |
|
41 CleanupStack::Pop(); |
|
42 return self; |
|
43 } |
|
44 |
|
45 CIETNGeneratorAO::~CIETNGeneratorAO() |
|
46 { |
|
47 DP0_IMAGIC((_L("CIETNGeneratorAO::~CIETNGeneratorAO ++"))); |
|
48 if(IsActive()) |
|
49 Cancel(); |
|
50 |
|
51 CancelOutStaningRequests(); |
|
52 DeleteObjects(); |
|
53 |
|
54 DP0_IMAGIC((_L("CIETNGeneratorAO::~CIETNGeneratorAO --"))); |
|
55 } |
|
56 |
|
57 //EPriorityIdle, EPriorityLow, EPriorityStandard, EPriorityUserInput, EPriorityHigh |
|
58 CIETNGeneratorAO::CIETNGeneratorAO(RFs& aFileServer, MIEThumbNailObserver &aObserver) |
|
59 : iFileServer(aFileServer), |
|
60 iThumbnailObserver(aObserver), |
|
61 CActive(EPriorityStandard) |
|
62 { |
|
63 |
|
64 } |
|
65 |
|
66 void CIETNGeneratorAO::ConstructL() |
|
67 { |
|
68 DP0_IMAGIC((_L("CIETNGeneratorAO::ConstructL ++"))); |
|
69 |
|
70 CActiveScheduler::Add(this); |
|
71 iError = KErrNone; |
|
72 decoderUid = CIEEngineUtils::GetImageDecoderUid(); |
|
73 //i512x512TnBitmap = new (ELeave) CFbsBitmap(); |
|
74 |
|
75 DP0_IMAGIC((_L("CIETNGeneratorAO::ConstructL --"))); |
|
76 } |
|
77 |
|
78 void CIETNGeneratorAO::RunL() |
|
79 { |
|
80 DP0_IMAGIC((_L("CIETNGeneratorAO::RunL ++"))); |
|
81 iError = iStatus.Int(); |
|
82 |
|
83 #ifdef _IMAGIC_DEBUG |
|
84 TInt mem = 0; |
|
85 TInt ret = HAL::Get(HALData::EMemoryRAMFree, mem); |
|
86 DP1_IMAGIC(_L("CIETNGeneratorAO::RunL - mem: %d"),mem); |
|
87 #endif |
|
88 |
|
89 if(iError != KErrNone) |
|
90 { |
|
91 DeleteObjects(); |
|
92 |
|
93 iConvertStatus = ENone; |
|
94 |
|
95 // inform to higher layer... and delete thumbnails we tried to create |
|
96 DP1_IMAGIC(_L("CIETNGeneratorAO::RunL - Something wrong %d"), iError); |
|
97 iThumbnailObserver.ThumbNailGenerationCompleted(iError); |
|
98 } |
|
99 |
|
100 switch (iConvertStatus) |
|
101 { |
|
102 case EDecoding: |
|
103 { |
|
104 DP0_IMAGIC((_L("CIETNGeneratorAO::RunL - EDecoding"))); |
|
105 TRAPD(err, DecodeL()); // TODO handle errors |
|
106 if (err != KErrNone) |
|
107 { |
|
108 DP1_IMAGIC((_L("CIETNGeneratorAO::RunL - EDecoding error: %d")), err); |
|
109 iThumbnailObserver.ThumbNailGenerationCompleted(err); //ASSERT(0); |
|
110 iConvertStatus = ENone; |
|
111 } |
|
112 else |
|
113 { |
|
114 #ifdef DO_NOT_USE_SCALING |
|
115 iConvertStatus = EEncoding; |
|
116 #else |
|
117 iConvertStatus = EScaling; |
|
118 #endif |
|
119 SetActive(); |
|
120 } |
|
121 } |
|
122 break; |
|
123 |
|
124 case EScaling: |
|
125 { |
|
126 DP0_IMAGIC((_L("CIETNGeneratorAO::RunL - EScaling"))); |
|
127 TRAPD(err, ScaleL()); |
|
128 if (err != KErrNone) |
|
129 { |
|
130 DP1_IMAGIC((_L("CIETNGeneratorAO::RunL - EScaling error: %d")), err); |
|
131 iThumbnailObserver.ThumbNailGenerationCompleted(err); //ASSERT(0); |
|
132 iConvertStatus = ENone; |
|
133 } |
|
134 else |
|
135 { |
|
136 iConvertStatus = EEncoding; |
|
137 SetActive(); |
|
138 } |
|
139 } |
|
140 break; |
|
141 |
|
142 case EEncoding: |
|
143 { |
|
144 DP0_IMAGIC((_L("CIETNGeneratorAO::RunL - EEncoding"))); |
|
145 TRAPD(err, EncodeL()); // TODO handle errors |
|
146 if (err != KErrNone) |
|
147 { |
|
148 DP1_IMAGIC((_L("CIETNGeneratorAO::RunL - EEncoding error: %d")), err); |
|
149 iThumbnailObserver.ThumbNailGenerationCompleted(err); //ASSERT(0); |
|
150 iConvertStatus = ENone; |
|
151 } |
|
152 else |
|
153 { |
|
154 iConvertStatus = EReady; |
|
155 |
|
156 #ifdef USE_BITMAPS_TNS |
|
157 if(!IsJPEG(iThumbnailSize)) |
|
158 { |
|
159 //When saving TN as bitmap we need to complete request immeadtely |
|
160 //because bitmap saving is handled by CFbsBitmap class instead of image encoder |
|
161 SetActive(); |
|
162 TRequestStatus* status = &iStatus; |
|
163 User::RequestComplete( status, KErrNone ); |
|
164 } |
|
165 else |
|
166 { |
|
167 SetActive(); |
|
168 } |
|
169 #else |
|
170 SetActive(); |
|
171 #endif |
|
172 } |
|
173 } |
|
174 break; |
|
175 |
|
176 case EReady: |
|
177 { |
|
178 DP0_IMAGIC((_L("CIETNGeneratorAO::RunL - EReady"))); |
|
179 |
|
180 // use same image for generating smaller thumbnails |
|
181 if (IsLargeThumbnail(iThumbnailSize)) |
|
182 { |
|
183 /*DP0_IMAGIC((_L("CIETNGeneratorAO::RunL - EScaling"))); |
|
184 TRAPD(err, ScaleL()); |
|
185 if (err != KErrNone) |
|
186 ASSERT(0);// TODO handle errors |
|
187 iConvertStatus = EEncoding; |
|
188 SetActive();*/ |
|
189 } |
|
190 |
|
191 if( iImageEncoder ) |
|
192 { |
|
193 delete iImageEncoder; |
|
194 iImageEncoder = NULL; |
|
195 } |
|
196 |
|
197 if( iBitmap ) |
|
198 { |
|
199 iBitmap->Reset(); |
|
200 delete iBitmap; |
|
201 iBitmap = NULL; |
|
202 } |
|
203 |
|
204 #ifdef DECODE_FROM_BUFFER |
|
205 if(iSourceData) |
|
206 { |
|
207 delete iSourceData; |
|
208 iSourceData = NULL; |
|
209 } |
|
210 #endif |
|
211 |
|
212 iConvertStatus = ENone; |
|
213 |
|
214 #ifndef USE_BITMAPS_TNS |
|
215 WriteExifData(iThumbnailFileName, iResolutionSize); |
|
216 #else |
|
217 if(IsJPEG(iThumbnailSize)) |
|
218 { |
|
219 TRAPD(err, WriteExifDataL(iThumbnailFileName, iThumbnailSize)); |
|
220 } |
|
221 #endif |
|
222 |
|
223 iFileServer.SetModified(iThumbnailFileName, iSourceTime); |
|
224 iThumbnailObserver.ThumbNailGenerationCompleted(KErrNone); |
|
225 } |
|
226 break; |
|
227 } |
|
228 |
|
229 DP0_IMAGIC(_L("CIETNGeneratorAO::RunL --")); |
|
230 } |
|
231 |
|
232 TBool CIETNGeneratorAO::IsJPEG(const TSize& aResolution) const |
|
233 { |
|
234 #ifdef USE_64X64_BITMAP_TN |
|
235 return (aResolution.iWidth >= 512 || aResolution.iHeight >= 512); |
|
236 #else |
|
237 return (aResolution.iWidth >= 128 || aResolution.iHeight >= 128); |
|
238 #endif |
|
239 } |
|
240 |
|
241 TBool CIETNGeneratorAO::IsLargeThumbnail(const TSize& aResolution) const |
|
242 { |
|
243 return (aResolution.iHeight >= 512); |
|
244 } |
|
245 |
|
246 void CIETNGeneratorAO::ScaleL() |
|
247 { |
|
248 DP0_IMAGIC((_L("CIETNGeneratorAO::Scale++"))); |
|
249 |
|
250 if ( iImageDecoder ) |
|
251 { |
|
252 delete iImageDecoder; |
|
253 iImageDecoder = NULL; |
|
254 } |
|
255 |
|
256 if (iBitmapScaler ) |
|
257 { |
|
258 delete iImageDecoder; |
|
259 iImageDecoder = NULL; |
|
260 } |
|
261 |
|
262 iBitmapScaler = CBitmapScaler::NewL(); |
|
263 iBitmapScaler->UseLowMemoryAlgorithm(ETrue); |
|
264 |
|
265 TSize tgtBitmapize; |
|
266 |
|
267 // If we want to create high resolution thumbnail, we use 512x512 resolution |
|
268 // for low resolution TN we use size set in iResolutionSize |
|
269 if(IsLargeThumbnail(iThumbnailSize)) |
|
270 { |
|
271 tgtBitmapize.iWidth = 512; |
|
272 tgtBitmapize.iHeight = 512; |
|
273 |
|
274 if(iSourceSize.iWidth > iSourceSize.iHeight) |
|
275 { |
|
276 // If we have wide panorama, use higher resolution to width |
|
277 if((iSourceSize.iWidth / iSourceSize.iHeight) > 1.6) |
|
278 tgtBitmapize.iWidth = 1024; |
|
279 } |
|
280 else |
|
281 { |
|
282 // If we have wide panorama, use higher resolution to height |
|
283 if((iSourceSize.iHeight / iSourceSize.iWidth) > 1.6) |
|
284 tgtBitmapize.iHeight = 1024; |
|
285 } |
|
286 } |
|
287 else |
|
288 { |
|
289 tgtBitmapize = iThumbnailSize; |
|
290 } |
|
291 |
|
292 // Use max quality |
|
293 iBitmapScaler->SetQualityAlgorithm(CBitmapScaler::EMaximumQuality); |
|
294 //iBitmapScaler->SetQualityAlgorithm(CBitmapScaler::EMediumQuality); |
|
295 //iBitmapScaler->SetQualityAlgorithm(CBitmapScaler::EMinimumQuality); |
|
296 |
|
297 DP2_IMAGIC(_L("CIETNGeneratorAO::Scale to %dx%d"), tgtBitmapize.iWidth, tgtBitmapize.iHeight); |
|
298 |
|
299 iBitmapScaler->Scale(&iStatus, *iBitmap, tgtBitmapize, EFalse); |
|
300 |
|
301 DP0_IMAGIC((_L("CIETNGeneratorAO::Scale--"))); |
|
302 } |
|
303 |
|
304 void CIETNGeneratorAO::EncodeL() |
|
305 { |
|
306 DP0_IMAGIC((_L("CIETNGeneratorAO::Encode++"))); |
|
307 |
|
308 if (iImageDecoder ) |
|
309 { |
|
310 delete iImageDecoder; |
|
311 iImageDecoder = NULL; |
|
312 } |
|
313 if( iBitmapScaler ) |
|
314 { |
|
315 delete iBitmapScaler; |
|
316 iBitmapScaler = NULL; |
|
317 } |
|
318 if( iImageEncoder ) |
|
319 { |
|
320 delete iImageEncoder; |
|
321 iImageEncoder = NULL; |
|
322 } |
|
323 |
|
324 TParse parser; |
|
325 parser.Set(iThumbnailFileName, NULL, NULL ); |
|
326 TFileName tnPath = parser.DriveAndPath(); |
|
327 CIEEngineUtils::CreateTNFolder(iFileServer, tnPath); |
|
328 |
|
329 #ifdef USE_BITMAPS_TNS |
|
330 // Save Bitmap thumbnails if resolution is 128x128 or smaller |
|
331 if(!IsJPEG(iThumbnailSize)) |
|
332 { |
|
333 iBitmap->Save(iThumbnailFileName); |
|
334 } |
|
335 else //if bigger than then save jpg thumbnails |
|
336 #endif |
|
337 { |
|
338 #if 0 |
|
339 //If we had 512x512 resolution bitmap we make copy of it |
|
340 if(iBitmap->SizeInPixels().iWidth == 512 && iBitmap->SizeInPixels().iHeight == 512) |
|
341 { |
|
342 i512x512TnBitmap->Reset(); |
|
343 TInt error = i512x512TnBitmap->Create(iBitmap->SizeInPixels(), EColor16M); |
|
344 |
|
345 TUint8* dstData = (TUint8 *)i512x512TnBitmap->DataAddress(); |
|
346 TUint8* srcData = (TUint8 *)iBitmap->DataAddress(); |
|
347 TInt dataSize = iBitmap->SizeInPixels().iWidth * iBitmap->SizeInPixels().iHeight; |
|
348 dataSize*=3; |
|
349 |
|
350 //Copy bitmap |
|
351 for(TInt i=0; i<dataSize; i++) |
|
352 { |
|
353 dstData[i] = srcData[i]; |
|
354 } |
|
355 } |
|
356 #endif |
|
357 |
|
358 SetJpegImageDataL(); |
|
359 DP1_IMAGIC(_L("CIETNGeneratorAO::Encode - iThumbnailFileName: %S"), &iThumbnailFileName); |
|
360 iMimeString = KMimeJpeg; |
|
361 iImageEncoder = CImageEncoder::FileNewL( iFileServer, iThumbnailFileName, iMimeString ); |
|
362 iImageEncoder->Convert(&iStatus, *iBitmap, iFrameImageData); |
|
363 } |
|
364 |
|
365 TEntry entry; |
|
366 User::LeaveIfError(iFileServer.Entry(iThumbnailFileName, entry)); |
|
367 // Remember the modified time of the source file |
|
368 iSourceTime = entry.iModified; |
|
369 |
|
370 DP0_IMAGIC((_L("CIETNGeneratorAO::Encode--"))); |
|
371 } |
|
372 |
|
373 void CIETNGeneratorAO::DecodeL() |
|
374 { |
|
375 DP0_IMAGIC((_L("CIETNGeneratorAO::Decode++"))); |
|
376 |
|
377 if(iImageDecoder) |
|
378 { |
|
379 delete iImageDecoder; |
|
380 iImageDecoder = NULL; |
|
381 } |
|
382 |
|
383 DP1_IMAGIC((_L("CIETNGeneratorAO::Decode - Creating decoder... with filename: %S")),&iSourceFileName); |
|
384 #ifdef USE_EXT_JPEG_DEC |
|
385 iImageDecoder = CExtJpegDecoder::FileNewL(iFileServer, iSourceFileName); |
|
386 #else |
|
387 |
|
388 #ifdef DECODE_FROM_BUFFER |
|
389 if(iSourceData) { |
|
390 delete iSourceData; |
|
391 iSourceData = NULL; |
|
392 } |
|
393 |
|
394 RFile jpgFile; |
|
395 TInt fileSize; |
|
396 |
|
397 User::LeaveIfError(jpgFile.Open(iFileServer, iSourceFileName, EFileRead)); |
|
398 jpgFile.Size(fileSize); |
|
399 iSourceData = HBufC8::NewL(fileSize); |
|
400 |
|
401 TPtr8 buffer = iSourceData->Des(); |
|
402 |
|
403 jpgFile.Read(buffer, fileSize); |
|
404 |
|
405 jpgFile.Close(); |
|
406 |
|
407 iImageDecoder = CImageDecoder::DataNewL( |
|
408 iFileServer, |
|
409 *iSourceData, |
|
410 CImageDecoder::EOptionNone, |
|
411 KNullUid, |
|
412 KNullUid, |
|
413 decoderUid); |
|
414 |
|
415 |
|
416 #else |
|
417 iImageDecoder = CImageDecoder::FileNewL( |
|
418 iFileServer, |
|
419 iSourceFileName, |
|
420 CImageDecoder::EOptionNone, |
|
421 KNullUid, |
|
422 KNullUid, |
|
423 decoderUid); |
|
424 #endif |
|
425 |
|
426 #endif |
|
427 |
|
428 |
|
429 iMimeString = KMimeJpeg; |
|
430 #ifdef DECODE_FROM_BUFFER |
|
431 CImageDecoder::GetMimeTypeDataL( *iSourceData, iMimeString ); |
|
432 #else |
|
433 CImageDecoder::GetMimeTypeFileL( iFileServer, iSourceFileName, iMimeString ); |
|
434 #endif |
|
435 |
|
436 iSourceSize = iImageDecoder->FrameInfo().iOverallSizeInPixels; |
|
437 |
|
438 DP2_IMAGIC((_L("CIETNGeneratorAO::Decode - image %dx%d")), iSourceSize.iWidth, iSourceSize.iHeight ); |
|
439 |
|
440 iBitmap = new (ELeave) CFbsBitmap(); |
|
441 |
|
442 TargetDecodingSize(iThumbnailSize, iSourceSize); |
|
443 |
|
444 #ifdef DO_NOT_USE_SCALING |
|
445 if(IsLargeThumbnail(iThumbnailSize)) |
|
446 { |
|
447 iSourceSize.iHeight=512; |
|
448 iSourceSize.iWidth=512; |
|
449 } |
|
450 #endif |
|
451 |
|
452 TInt error = iBitmap->Create(iSourceSize, EColor16M); |
|
453 |
|
454 iImageDecoder->Convert(&iStatus, *iBitmap, 0); |
|
455 |
|
456 DP0_IMAGIC((_L("CIETNGeneratorAO::Decode - convert bitmap... OK"))); |
|
457 DP0_IMAGIC((_L("CIETNGeneratorAO::Decode--"))); |
|
458 } |
|
459 |
|
460 void CIETNGeneratorAO::TargetDecodingSize(const TSize aTgtSize, TSize& aSrcSize) |
|
461 { |
|
462 DP0_IMAGIC(_L("CIETNGeneratorAO::TargetDecodingSize++")); |
|
463 |
|
464 DP2_IMAGIC(_L("CIETNGeneratorAO::TargetDecodingSize - Tgt %dx%d"),aTgtSize.iHeight, aTgtSize.iWidth); |
|
465 DP2_IMAGIC(_L("CIETNGeneratorAO::TargetDecodingSize - Src %dx%d"),aSrcSize.iHeight, aSrcSize.iWidth); |
|
466 |
|
467 // up to 32 times downscale in scaler |
|
468 for (TInt i = 0;i < 5;i++) |
|
469 { |
|
470 if (aSrcSize.iWidth < aTgtSize.iWidth * 2 || |
|
471 aSrcSize.iHeight < aTgtSize.iHeight * 2) |
|
472 { |
|
473 break; |
|
474 } |
|
475 |
|
476 aSrcSize.iWidth >>= 1; |
|
477 aSrcSize.iHeight >>= 1; |
|
478 } |
|
479 |
|
480 // Check that we do not create odd resolution size thumbnail |
|
481 if(aSrcSize.iHeight & 1) |
|
482 aSrcSize.iHeight++; |
|
483 if(aSrcSize.iWidth & 1) |
|
484 aSrcSize.iWidth++; |
|
485 |
|
486 DP2_IMAGIC(_L("CIETNGeneratorAO::TargetDecodingSize - New Src %dx%d"), aSrcSize.iHeight, aSrcSize.iWidth); |
|
487 DP0_IMAGIC((_L("CIETNGeneratorAO::TargetDecodingSize--"))); |
|
488 } |
|
489 |
|
490 void CIETNGeneratorAO::WriteExifDataL(const TDes &aFilename, TSize aSize) |
|
491 { |
|
492 DP0_IMAGIC(_L("CIETNGeneratorAO::WriteExifData++")); |
|
493 |
|
494 // 1. Read JPEG image from the file to a buffer... |
|
495 RFile file; |
|
496 User::LeaveIfError( file.Open( iFileServer, aFilename, EFileWrite ) ); |
|
497 CleanupClosePushL( file ); |
|
498 TInt size = 0; |
|
499 file.Size(size); |
|
500 HBufC8* jpegImage = HBufC8::NewL( size ); |
|
501 CleanupStack::PushL( jpegImage ); |
|
502 TPtr8 bufferDes( jpegImage->Des() ); |
|
503 User::LeaveIfError( file.Read( bufferDes ) ); |
|
504 CleanupStack::Pop( jpegImage ); |
|
505 CleanupStack::PopAndDestroy(); |
|
506 CleanupStack::PushL( jpegImage ); |
|
507 |
|
508 file.Close(); |
|
509 |
|
510 // 2. Instantiate Exif modifier in ECreate mode... |
|
511 CExifModify* modify = CExifModify::NewL( jpegImage->Des(), CExifModify::ECreate ); |
|
512 CleanupStack::PushL( modify ); |
|
513 |
|
514 // 3. Insert (Set) at least the mandatory Exif data... |
|
515 modify->SetXResolutionL( aSize.iWidth, 1 ); |
|
516 modify->SetYResolutionL( aSize.iHeight, 1 ); |
|
517 modify->SetResolutionUnitL( 2 ); |
|
518 modify->SetYCbCrPositioningL( 1 ); |
|
519 modify->SetComponentsConfigurationL( 1, 2, 3, 0 ); |
|
520 modify->SetColorSpaceL( 1 ); |
|
521 modify->SetPixelXDimensionL( aSize.iWidth ); |
|
522 modify->SetPixelYDimensionL( aSize.iHeight ); |
|
523 |
|
524 // 4. Get the new Exif image... |
|
525 // If zero length descriptor is given instead of jpeg->Des(), then only the |
|
526 // Exif meta data is returned. |
|
527 HBufC8* newExif = modify->WriteDataL( jpegImage->Des() ); |
|
528 TPtr8 tmp = newExif->Des(); |
|
529 |
|
530 User::LeaveIfError( file.Replace( iFileServer, aFilename, EFileWrite ) ); |
|
531 //Write Exif and jpeg image back to jpeg file |
|
532 User::LeaveIfError(file.Write(*newExif)); |
|
533 |
|
534 /* Process the new Exif data */ |
|
535 delete newExif; |
|
536 newExif = NULL; |
|
537 |
|
538 // 5. Delete the modifier instance... |
|
539 CleanupStack::PopAndDestroy( modify ); |
|
540 CleanupStack::PopAndDestroy( jpegImage ); |
|
541 |
|
542 file.Close(); |
|
543 |
|
544 DP0_IMAGIC(_L("CIETNGeneratorAO::WriteExifData--")); |
|
545 } |
|
546 |
|
547 |
|
548 //Set JPEG image quality for encoding |
|
549 void CIETNGeneratorAO::SetJpegImageDataL() |
|
550 { |
|
551 DP0_IMAGIC((_L("CIETNGeneratorAO::SetJpegImageDataL++"))); |
|
552 |
|
553 TJpegImageData* jpegImageData; |
|
554 jpegImageData = new (ELeave) TJpegImageData; |
|
555 jpegImageData->iSampleScheme = TJpegImageData::EColor420; |
|
556 jpegImageData->iQualityFactor = 80; |
|
557 |
|
558 if (iFrameImageData) |
|
559 { |
|
560 delete iFrameImageData; |
|
561 iFrameImageData = NULL; |
|
562 } |
|
563 |
|
564 iFrameImageData = CFrameImageData::NewL(); |
|
565 |
|
566 //Ownership of jpegImageData lies with CFrameImageData |
|
567 User::LeaveIfError(iFrameImageData->AppendImageData(jpegImageData)); |
|
568 |
|
569 DP0_IMAGIC((_L("CIETNGeneratorAO::SetJpegImageDataL--"))); |
|
570 } |
|
571 |
|
572 void CIETNGeneratorAO::DoCancel() |
|
573 { |
|
574 } |
|
575 |
|
576 TInt CIETNGeneratorAO::RunError(TInt /*aError*/) |
|
577 { |
|
578 return KErrNone; |
|
579 } |
|
580 |
|
581 /* Set Image arrary received from Client.*/ |
|
582 void CIETNGeneratorAO::SetImageArray(RArray<CImageData*> aImageArray) |
|
583 { |
|
584 DP0_IMAGIC((_L("CIETNGeneratorAO::SetImageArray ++"))); |
|
585 |
|
586 iImageArray = aImageArray; |
|
587 |
|
588 DP0_IMAGIC((_L("CIETNGeneratorAO::SetImageArray --"))); |
|
589 } |
|
590 |
|
591 void CIETNGeneratorAO::CreateThumbnailL( |
|
592 const TDes& aSourceFile, |
|
593 const TDes& aThumbnailFile, |
|
594 const TSize &aSize) |
|
595 { |
|
596 DP0_IMAGIC((_L("CIETNGeneratorAO::CreateThumbnailL ++"))); |
|
597 |
|
598 iSourceFileName.Copy(aSourceFile); |
|
599 iThumbnailFileName.Copy(aThumbnailFile); |
|
600 iThumbnailSize = aSize; |
|
601 |
|
602 iConvertStatus = EDecoding; |
|
603 if(!IsActive()) |
|
604 { |
|
605 SetActive(); |
|
606 TRequestStatus* status = &iStatus; |
|
607 User::RequestComplete( status, KErrNone ); |
|
608 } |
|
609 |
|
610 DP0_IMAGIC((_L("CIETNGeneratorAO::CreateThumbnailL --"))); |
|
611 } |
|
612 |
|
613 |
|
614 void CIETNGeneratorAO::CreateThumbnailL( |
|
615 const TDes& aSourceFile, |
|
616 const TDes& aThumbnailFile, |
|
617 const TSize &aSize, |
|
618 CFbsBitmap* /*a512x512TnBitmap*/) |
|
619 { |
|
620 DP0_IMAGIC((_L("CIETNGeneratorAO::CreateThumbnailL ++"))); |
|
621 |
|
622 iSourceFileName.Copy(aSourceFile); |
|
623 iThumbnailFileName.Copy(aThumbnailFile); |
|
624 iThumbnailSize = aSize; |
|
625 |
|
626 iConvertStatus = EDecoding; |
|
627 if(!IsActive()) |
|
628 { |
|
629 SetActive(); |
|
630 TRequestStatus* status = &iStatus; |
|
631 User::RequestComplete( status, KErrNone ); |
|
632 } |
|
633 |
|
634 DP0_IMAGIC((_L("CIETNGeneratorAO::CreateThumbnailL --"))); |
|
635 } |
|
636 |
|
637 void CIETNGeneratorAO::CancelOutStaningRequests() |
|
638 { |
|
639 DP0_IMAGIC((_L("CIETNGeneratorAO::CancelOutStaningRequests ++"))); |
|
640 |
|
641 if(iError != KErrNone) |
|
642 { |
|
643 if(BaflUtils::FileExists(iFileServer, iThumbnailFileName)) |
|
644 { |
|
645 TInt err = BaflUtils::DeleteFile(iFileServer, iThumbnailFileName); |
|
646 DP2_IMAGIC(_L("CIETNGeneratorAO::CancelOutStaningRequests - DeleteCorruptedThumbNailFile - file found: %S, err:%d"), &iThumbnailFileName, err); |
|
647 } |
|
648 } |
|
649 |
|
650 DeleteObjects(); |
|
651 |
|
652 DP0_IMAGIC((_L("CIETNGeneratorAO::CancelOutStaningRequests --"))); |
|
653 } |
|
654 |
|
655 void CIETNGeneratorAO::DeleteObjects() |
|
656 { |
|
657 DP0_IMAGIC((_L("CIETNGeneratorAO::DeleteObjects ++"))); |
|
658 |
|
659 if(iImageDecoder) |
|
660 { |
|
661 delete iImageDecoder; |
|
662 iImageDecoder = NULL; |
|
663 } |
|
664 |
|
665 if( iBitmapScaler ) |
|
666 { |
|
667 delete iBitmapScaler; |
|
668 iBitmapScaler = NULL; |
|
669 } |
|
670 |
|
671 if( iBitmap ) |
|
672 { |
|
673 delete iBitmap; |
|
674 iBitmap = NULL; |
|
675 } |
|
676 |
|
677 if( iImageEncoder ) |
|
678 { |
|
679 delete iImageEncoder; |
|
680 iImageEncoder = NULL; |
|
681 } |
|
682 |
|
683 if (iFrameImageData) |
|
684 { |
|
685 delete iFrameImageData; |
|
686 iFrameImageData = NULL; |
|
687 } |
|
688 |
|
689 #ifdef DECODE_FROM_BUFFER |
|
690 if(iSourceData) |
|
691 { |
|
692 delete iSourceData; |
|
693 iSourceData = NULL; |
|
694 } |
|
695 #endif |
|
696 //delete i512x512TnBitmap; |
|
697 |
|
698 DP0_IMAGIC((_L("CIETNGeneratorAO::DeleteObjects --"))); |
|
699 } |
|
700 |
|
701 void CIETNGeneratorAO::CancelRequestsAndDeleteObjects() |
|
702 { |
|
703 DP0_IMAGIC((_L("CIETNGeneratorAO::CancelRequestsAndDeleteObjects ++"))); |
|
704 |
|
705 CancelOutStaningRequests(); |
|
706 DeleteObjects(); |
|
707 |
|
708 DP0_IMAGIC((_L("CIETNGeneratorAO::CancelRequestsAndDeleteObjects --"))); |
|
709 } |