|
1 // Copyright (c) 1999-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 #include "TMDATEST.H" |
|
17 |
|
18 /* |
|
19 |
|
20 Video Test 5 - Client Utilities |
|
21 =============================== |
|
22 |
|
23 1. Bitmap -> file then file -> bitmap (including checking cancelling) |
|
24 2. Cached file -> bitmap |
|
25 3. Bitmap -> descriptor then descriptor -> bitmap |
|
26 4. Cached descriptor -> bitmap |
|
27 5. *** Bitmap -> bitmap (we no longer do this) |
|
28 6. Anonymous file -> bitmap using explicit format |
|
29 7. File -> bitmap with mask for transparent gif |
|
30 8. Rotation |
|
31 9. Scaling with results compared to \tmdavid\ref\scaledN.mbm where N = 0,1,... |
|
32 |
|
33 */ |
|
34 |
|
35 void CMdaVideo5Test::DoTestL() |
|
36 { |
|
37 iReferenceScaledBitmap = new(ELeave) CFbsBitmap; |
|
38 CleanupStack::PushL(iReferenceScaledBitmap); |
|
39 |
|
40 TestUtilitiesL(); |
|
41 TestRotationL(); |
|
42 TestScalingL(); |
|
43 |
|
44 CleanupStack::PopAndDestroy(); // iReferenceScaledBitmap |
|
45 } |
|
46 |
|
47 void CMdaVideo5Test::TestUtilitiesL() |
|
48 { |
|
49 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
50 CleanupStack::PushL(bmp); |
|
51 User::LeaveIfError(bmp->Load(iEngine->iSourceFileName)); |
|
52 |
|
53 CMdaServer* server = NULL; // jf 19/11/01. real objects no longer supported. CMdaServer::NewL(); |
|
54 CleanupStack::PushL(server); |
|
55 |
|
56 FileL(*bmp,server); |
|
57 FileCancelL(*bmp,server); |
|
58 FileBmpL(*bmp,server); |
|
59 // FileClippedL(*bmp,server); // don't call anymore (we don't support clipped save) |
|
60 FileCacheL(*bmp,server); |
|
61 FileBmpCacheL(*bmp,server); |
|
62 DescL(*bmp,server); |
|
63 DescCacheL(*bmp,server); |
|
64 BitmapL(*bmp); |
|
65 AnonymousFileL(server); |
|
66 TransparentL(server); |
|
67 BitmapStackL(*bmp); |
|
68 |
|
69 CleanupStack::PopAndDestroy(2); // server, bmp |
|
70 } |
|
71 |
|
72 void CMdaVideo5Test::FileL(CFbsBitmap& aBitmap,CMdaServer* aServer) |
|
73 { |
|
74 iEngine->Print(_L("File utility")); |
|
75 TMdaMbmClipFormat format; |
|
76 format.iDisplayMode = EColor16M; |
|
77 |
|
78 CMdaImageBitmapToFileUtility* btof = CMdaImageBitmapToFileUtility::NewL(*this,aServer); |
|
79 CleanupStack::PushL(btof); |
|
80 btof->CreateL(KVideoTestTempFileName,&format,NULL,NULL); |
|
81 WaitAndCheckL(); |
|
82 btof->ConvertL(aBitmap); |
|
83 WaitAndCheckL(); |
|
84 |
|
85 // *** Jim added coverage of CMdaImageDataWriteUtility::ConvertL() with mask |
|
86 CFbsBitmap* mask = new(ELeave) CFbsBitmap; |
|
87 CleanupStack::PushL(mask); |
|
88 User::LeaveIfError(mask->Create(aBitmap.SizeInPixels(),EGray2)); |
|
89 TRAPD(err, btof->ConvertL(aBitmap,*mask,0)); // should leave with KErrNotSupported |
|
90 CleanupStack::PopAndDestroy(); // mask |
|
91 |
|
92 // *** Jim added coverage of CMdaImageDataWriteUtility::ConvertL() with rect |
|
93 TRect rect(0,0,10,10); |
|
94 TRAP(err, btof->ConvertL(aBitmap,rect,0)); // should leave with KErrNotSupported |
|
95 CleanupStack::PopAndDestroy(); // btof |
|
96 |
|
97 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
98 CleanupStack::PushL(bmp); |
|
99 User::LeaveIfError(bmp->Create(aBitmap.SizeInPixels(),EColor16M)); |
|
100 |
|
101 CMdaImageFileToBitmapUtility* ftob = CMdaImageFileToBitmapUtility::NewL(*this); |
|
102 CleanupStack::PushL(ftob); |
|
103 ftob->OpenL(KVideoTestTempFileName); |
|
104 WaitAndCheckL(); |
|
105 ftob->ConvertL(*bmp,0); |
|
106 WaitAndCheckL(); |
|
107 CleanupStack::PopAndDestroy(); // ftob |
|
108 |
|
109 iEngine->iFs.Delete(KVideoTestTempFileName); |
|
110 |
|
111 CheckBitmaps(aBitmap,*bmp); |
|
112 |
|
113 CleanupStack::PopAndDestroy(); // bmp |
|
114 } |
|
115 |
|
116 void CMdaVideo5Test::FileCancelL(CFbsBitmap& aBitmap,CMdaServer* aServer) |
|
117 { |
|
118 iEngine->Print(_L("File utility cancelling")); |
|
119 TMdaMbmClipFormat format; |
|
120 format.iDisplayMode = EColor16M; |
|
121 |
|
122 CMdaImageBitmapToFileUtility* btof = CMdaImageBitmapToFileUtility::NewL(*this,aServer); |
|
123 CleanupStack::PushL(btof); |
|
124 btof->CreateL(KVideoTestTempFileName,&format,NULL,NULL); |
|
125 WaitAndCheckL(); |
|
126 btof->ConvertL(aBitmap); // check we can cancel before carrying on |
|
127 btof->CancelConvertL(); |
|
128 btof->ConvertL(aBitmap); |
|
129 btof->CancelConvertL(); |
|
130 btof->ConvertL(aBitmap); |
|
131 WaitAndCheckL(); |
|
132 CleanupStack::PopAndDestroy(); // btof |
|
133 |
|
134 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
135 CleanupStack::PushL(bmp); |
|
136 User::LeaveIfError(bmp->Create(aBitmap.SizeInPixels(),EColor16M)); |
|
137 |
|
138 CMdaImageFileToBitmapUtility* ftob = CMdaImageFileToBitmapUtility::NewL(*this); |
|
139 CleanupStack::PushL(ftob); |
|
140 ftob->OpenL(KVideoTestTempFileName); |
|
141 WaitAndCheckL(); |
|
142 ftob->ConvertL(*bmp,0); // check we can cancel before carrying on |
|
143 ftob->CancelConvertL(); |
|
144 ftob->ConvertL(*bmp,0); |
|
145 ftob->CancelConvertL(); |
|
146 ftob->ConvertL(*bmp,0); |
|
147 WaitAndCheckL(); |
|
148 CleanupStack::PopAndDestroy(); // ftob |
|
149 |
|
150 iEngine->iFs.Delete(KVideoTestTempFileName); |
|
151 |
|
152 CheckBitmaps(aBitmap,*bmp); |
|
153 |
|
154 CleanupStack::PopAndDestroy(); // bmp |
|
155 } |
|
156 |
|
157 void CMdaVideo5Test::FileBmpL(CFbsBitmap& aBitmap,CMdaServer* aServer) |
|
158 { |
|
159 iEngine->Print(_L("File utility Bmp")); |
|
160 TMdaBmpClipFormat format; |
|
161 TMda24BppBmpCodec codec; |
|
162 |
|
163 CMdaImageBitmapToFileUtility* btof = CMdaImageBitmapToFileUtility::NewL(*this,aServer); |
|
164 CleanupStack::PushL(btof); |
|
165 btof->CreateL(KVideoTestTempBmpFileName,&format,&codec,NULL); |
|
166 WaitAndCheckL(); |
|
167 btof->ConvertL(aBitmap); |
|
168 WaitAndCheckL(); |
|
169 CleanupStack::PopAndDestroy(); // btof |
|
170 |
|
171 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
172 CleanupStack::PushL(bmp); |
|
173 User::LeaveIfError(bmp->Create(aBitmap.SizeInPixels(),EColor16M)); |
|
174 |
|
175 CMdaImageFileToBitmapUtility* ftob = CMdaImageFileToBitmapUtility::NewL(*this); |
|
176 CleanupStack::PushL(ftob); |
|
177 ftob->OpenL(KVideoTestTempBmpFileName); |
|
178 WaitAndCheckL(); |
|
179 ftob->ConvertL(*bmp,0); |
|
180 WaitAndCheckL(); |
|
181 CleanupStack::PopAndDestroy(); // ftob |
|
182 |
|
183 iEngine->iFs.Delete(KVideoTestTempBmpFileName); |
|
184 |
|
185 CheckBitmaps(aBitmap,*bmp); |
|
186 |
|
187 CleanupStack::PopAndDestroy(); // bmp |
|
188 } |
|
189 |
|
190 TBool MagentaCheck(CFbsBitmap& aBitmap) |
|
191 { |
|
192 TSize size(aBitmap.SizeInPixels()); |
|
193 TInt pitch = aBitmap.ScanLineLength(size.iWidth,EColor16M); |
|
194 TUint8* ptr = (TUint8*)aBitmap.DataAddress(); |
|
195 TInt ptrSkip = pitch-size.iWidth*3; |
|
196 TBool flag = ETrue; |
|
197 |
|
198 for(TInt y=0; y<size.iHeight; y++) |
|
199 { |
|
200 for(TInt x=0; x<size.iWidth; x++) |
|
201 { |
|
202 if(ptr[0]==255 && ptr[1]==0 && ptr[2]==255) |
|
203 flag = EFalse; |
|
204 ptr[0] = 255; |
|
205 ptr[1] = 0; |
|
206 ptr[2] = 255; |
|
207 ptr += 3; |
|
208 } |
|
209 ptr += ptrSkip; |
|
210 } |
|
211 |
|
212 return flag; |
|
213 } |
|
214 |
|
215 void CMdaVideo5Test::FileClippedL(CFbsBitmap& /*aBitmap*/,CMdaServer* /*aServer*/) |
|
216 { |
|
217 ASSERT(EFalse); // should not get here anymore |
|
218 } |
|
219 |
|
220 void CMdaVideo5Test::FileCacheL(CFbsBitmap& aBitmap,CMdaServer* aServer) |
|
221 { |
|
222 iEngine->Print(_L("File utility (cached)")); |
|
223 |
|
224 RFile srcFile; |
|
225 TFileName fileName = iEngine->DefaultPath(); |
|
226 fileName.Append(KVideoTestSourceFileName); |
|
227 User::LeaveIfError(srcFile.Open(iEngine->iFs,fileName,EFileShareAny|EFileStream|EFileRead)); |
|
228 CleanupClosePushL(srcFile); |
|
229 |
|
230 TFileName tempFileName; |
|
231 RFile tempFile; |
|
232 User::LeaveIfError(tempFile.Temp(iEngine->iFs,_L("c:\\"),tempFileName,EFileShareAny|EFileStream|EFileWrite)); |
|
233 CleanupClosePushL(tempFile); |
|
234 |
|
235 TBuf8<128> buffer; |
|
236 buffer.SetLength(128); |
|
237 |
|
238 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
239 CleanupStack::PushL(bmp); |
|
240 User::LeaveIfError(bmp->Create(aBitmap.SizeInPixels(),EColor16M)); |
|
241 |
|
242 CMdaImageFileToBitmapUtility* ftob = CMdaImageFileToBitmapUtility::NewL(*this,aServer); |
|
243 CleanupStack::PushL(ftob); |
|
244 |
|
245 User::LeaveIfError(srcFile.Read(buffer)); |
|
246 User::LeaveIfError(tempFile.Write(buffer)); |
|
247 |
|
248 ftob->OpenL(tempFileName); |
|
249 WaitL(); |
|
250 |
|
251 if (iError != KErrNone) |
|
252 iEngine->TestFailed(iError); |
|
253 |
|
254 do { |
|
255 User::LeaveIfError(srcFile.Read(buffer)); |
|
256 User::LeaveIfError(tempFile.Write(buffer)); |
|
257 ftob->ConvertL(*bmp,0); |
|
258 WaitL(); |
|
259 } |
|
260 while (iError == KErrUnderflow); |
|
261 |
|
262 if (iError != KErrNone) |
|
263 iEngine->TestFailed(iError); |
|
264 |
|
265 CleanupStack::PopAndDestroy(); // ftob |
|
266 |
|
267 CheckBitmaps(aBitmap,*bmp); |
|
268 |
|
269 CleanupStack::PopAndDestroy(3); // bmp,tempFile,srcFile |
|
270 iEngine->iFs.Delete(tempFileName); |
|
271 } |
|
272 |
|
273 void CMdaVideo5Test::FileBmpCacheL(CFbsBitmap& aBitmap,CMdaServer* aServer) |
|
274 { |
|
275 iEngine->Print(_L("File utility Bmp (cached)")); |
|
276 |
|
277 // NB assumes that FileBmpL has passed OK and we can save OK to BMP file |
|
278 |
|
279 // 1st save passed bitmap to .bmp file |
|
280 TMdaBmpClipFormat format; |
|
281 TMda24BppBmpCodec codec; |
|
282 CMdaImageBitmapToFileUtility* btof = CMdaImageBitmapToFileUtility::NewL(*this,aServer); |
|
283 CleanupStack::PushL(btof); |
|
284 btof->CreateL(KVideoTestTempBmpFileName,&format,&codec,NULL); |
|
285 WaitL(); |
|
286 btof->ConvertL(aBitmap); |
|
287 WaitL(); |
|
288 CleanupStack::PopAndDestroy(); // btof |
|
289 |
|
290 RFile srcFile; |
|
291 User::LeaveIfError(srcFile.Open(iEngine->iFs,KVideoTestTempBmpFileName,EFileShareAny|EFileStream|EFileRead)); |
|
292 CleanupClosePushL(srcFile); |
|
293 |
|
294 TFileName tempFileName; |
|
295 RFile tempFile; |
|
296 User::LeaveIfError(tempFile.Temp(iEngine->iFs,_L("c:\\"),tempFileName,EFileShareAny|EFileStream|EFileWrite)); |
|
297 CleanupClosePushL(tempFile); |
|
298 |
|
299 TBuf8<128> buffer; |
|
300 buffer.SetLength(128); |
|
301 |
|
302 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
303 CleanupStack::PushL(bmp); |
|
304 User::LeaveIfError(bmp->Create(aBitmap.SizeInPixels(),EColor16M)); |
|
305 |
|
306 CMdaImageFileToBitmapUtility* ftob = CMdaImageFileToBitmapUtility::NewL(*this,aServer); |
|
307 CleanupStack::PushL(ftob); |
|
308 |
|
309 User::LeaveIfError(srcFile.Read(buffer)); |
|
310 User::LeaveIfError(tempFile.Write(buffer)); |
|
311 |
|
312 ftob->OpenL(tempFileName); |
|
313 WaitL(); |
|
314 |
|
315 if (iError != KErrNone) |
|
316 iEngine->TestFailed(iError); |
|
317 |
|
318 do { |
|
319 User::LeaveIfError(srcFile.Read(buffer)); |
|
320 User::LeaveIfError(tempFile.Write(buffer)); |
|
321 ftob->ConvertL(*bmp,0); |
|
322 WaitL(); |
|
323 } |
|
324 while (iError == KErrUnderflow); |
|
325 |
|
326 if (iError != KErrNone) |
|
327 iEngine->TestFailed(iError); |
|
328 |
|
329 CleanupStack::PopAndDestroy(); // ftob |
|
330 |
|
331 iEngine->iFs.Delete(KVideoTestTempBmpFileName); |
|
332 |
|
333 CheckBitmaps(aBitmap,*bmp); |
|
334 |
|
335 CleanupStack::PopAndDestroy(3); // bmp,tempFile,srcFile |
|
336 iEngine->iFs.Delete(tempFileName); |
|
337 } |
|
338 |
|
339 void CMdaVideo5Test::DescL(CFbsBitmap& aBitmap,CMdaServer* aServer) |
|
340 { |
|
341 iEngine->Print(_L("Desc utility")); |
|
342 const TSize size = aBitmap.SizeInPixels(); |
|
343 const TInt descSize = (size.iWidth * size.iHeight * 3) + 1024; |
|
344 HBufC8* descBuf = HBufC8::NewMaxLC(descSize); |
|
345 TPtr8 descDes(descBuf->Des()); |
|
346 |
|
347 TMdaBmpClipFormat format; |
|
348 TMda24BppBmpCodec codec; |
|
349 |
|
350 CMdaImageBitmapToDescUtility* btod = CMdaImageBitmapToDescUtility::NewL(*this); |
|
351 CleanupStack::PushL(btod); |
|
352 btod->CreateL(descDes,&format,&codec,NULL); |
|
353 WaitAndCheckL(); |
|
354 btod->ConvertL(aBitmap); |
|
355 WaitAndCheckL(); |
|
356 CleanupStack::PopAndDestroy(); // btod |
|
357 |
|
358 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
359 CleanupStack::PushL(bmp); |
|
360 User::LeaveIfError(bmp->Create(aBitmap.SizeInPixels(),EColor16M)); |
|
361 |
|
362 CMdaImageDescToBitmapUtility* dtob = CMdaImageDescToBitmapUtility::NewL(*this,aServer); |
|
363 CleanupStack::PushL(dtob); |
|
364 dtob->OpenL(*descBuf); |
|
365 WaitAndCheckL(); |
|
366 dtob->ConvertL(*bmp,0); |
|
367 WaitAndCheckL(); |
|
368 CleanupStack::PopAndDestroy(); // dtob |
|
369 |
|
370 CheckBitmaps(aBitmap,*bmp); |
|
371 |
|
372 CleanupStack::PopAndDestroy(2); // bmp, descBuf |
|
373 } |
|
374 |
|
375 void CMdaVideo5Test::DescCacheL(CFbsBitmap& aBitmap,CMdaServer* aServer) |
|
376 { |
|
377 iEngine->Print(_L("Desc utility (cached)")); |
|
378 |
|
379 RFile srcFile; |
|
380 TFileName fileName = iEngine->DefaultPath(); |
|
381 fileName.Append(KVideoTestSourceFileName); |
|
382 User::LeaveIfError(srcFile.Open(iEngine->iFs,fileName,EFileShareAny|EFileStream|EFileRead)); |
|
383 CleanupClosePushL(srcFile); |
|
384 |
|
385 TInt size = 0; |
|
386 User::LeaveIfError(srcFile.Size(size)); |
|
387 HBufC8* srcBuffer = HBufC8::NewLC(size); |
|
388 TPtr8 srcDes(srcBuffer->Des()); |
|
389 User::LeaveIfError(srcFile.Read(srcDes)); |
|
390 srcDes.SetLength(128); |
|
391 |
|
392 CleanupStack::Pop(); // srcBuffer |
|
393 CleanupStack::PopAndDestroy(); // srcFile |
|
394 CleanupStack::PushL(srcBuffer); |
|
395 |
|
396 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
397 CleanupStack::PushL(bmp); |
|
398 User::LeaveIfError(bmp->Create(aBitmap.SizeInPixels(),EColor16M)); |
|
399 |
|
400 CMdaImageDescToBitmapUtility* dtob = CMdaImageDescToBitmapUtility::NewL(*this,aServer); |
|
401 CleanupStack::PushL(dtob); |
|
402 |
|
403 dtob->OpenL(srcDes); |
|
404 WaitL(); |
|
405 |
|
406 if (iError != KErrNone) |
|
407 iEngine->TestFailed(iError); |
|
408 |
|
409 do { |
|
410 srcDes.SetLength(Min(srcDes.Length() + 128,size)); |
|
411 dtob->ConvertL(*bmp,0); |
|
412 WaitL(); |
|
413 } |
|
414 while (iError == KErrUnderflow && srcDes.Length() < size); |
|
415 |
|
416 if (iError != KErrNone) |
|
417 iEngine->TestFailed(iError); |
|
418 |
|
419 CleanupStack::PopAndDestroy(); // dtob |
|
420 |
|
421 CheckBitmaps(aBitmap,*bmp); |
|
422 |
|
423 CleanupStack::PopAndDestroy(2); // bmp,srcBuffer |
|
424 } |
|
425 |
|
426 void CMdaVideo5Test::BitmapL(CFbsBitmap& aBitmap) |
|
427 { |
|
428 iEngine->Print(_L("Bitmap utility")); |
|
429 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
430 CleanupStack::PushL(bmp); |
|
431 User::LeaveIfError(bmp->Create(aBitmap.SizeInPixels(),EColor16M)); |
|
432 |
|
433 CMdaImageBitmapToBitmapUtility* btob = CMdaImageBitmapToBitmapUtility::NewL(*this); |
|
434 CleanupStack::PushL(btob); |
|
435 btob->OpenL(aBitmap); |
|
436 WaitAndCheckL(); |
|
437 |
|
438 btob->ConvertL(*bmp,0); |
|
439 WaitAndCheckL(); |
|
440 |
|
441 CheckBitmaps(aBitmap,*bmp); |
|
442 |
|
443 // *** Jim added coverage of CMdaImageBitmapToBitmapUtility::ConvertL() with mask |
|
444 CFbsBitmap* mask = new(ELeave) CFbsBitmap; |
|
445 CleanupStack::PushL(mask); |
|
446 User::LeaveIfError(mask->Create(aBitmap.SizeInPixels(),EGray2)); |
|
447 TRAP_IGNORE(btob->ConvertL(*bmp,*mask,0)); // should leave with KErrNotSupported |
|
448 CleanupStack::PopAndDestroy(); // mask |
|
449 |
|
450 // *** Jim added coverage of CMdaImageBitmapToBitmapUtility::CancelConvertL() |
|
451 btob->ConvertL(*bmp,0); |
|
452 btob->CancelConvertL(); |
|
453 |
|
454 // *** Jim added coverage of CMdaImageUtility::Close() |
|
455 btob->Close(); |
|
456 |
|
457 CleanupStack::PopAndDestroy(); // btob |
|
458 |
|
459 |
|
460 CleanupStack::PopAndDestroy(); // bmp |
|
461 } |
|
462 |
|
463 void CMdaVideo5Test::BitmapStackL(CFbsBitmap& aBitmap) |
|
464 { |
|
465 iEngine->Print(_L("Bitmap utility stack overflow test")); |
|
466 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
467 CleanupStack::PushL(bmp); |
|
468 User::LeaveIfError(bmp->Create(aBitmap.SizeInPixels(),EColor16M)); |
|
469 |
|
470 CMdaImageBitmapToBitmapUtility* btob = CMdaImageBitmapToBitmapUtility::NewL(*this); |
|
471 CleanupStack::PushL(btob); |
|
472 btob->OpenL(aBitmap); |
|
473 // Destroy the utility immediately, whilst it is still in the EOpening |
|
474 // state. This is to test a stack overflow problem: INC037143 |
|
475 CleanupStack::PopAndDestroy(2, bmp); // bmp, btob |
|
476 } |
|
477 |
|
478 void CMdaVideo5Test::AnonymousFileL(CMdaServer* aServer) |
|
479 { |
|
480 iEngine->Print(_L("File utility with specified format")); |
|
481 |
|
482 CFbsBitmap* source = new(ELeave) CFbsBitmap; |
|
483 CleanupStack::PushL(source); |
|
484 |
|
485 TFileName fileName; |
|
486 fileName = iEngine->DefaultPath(); |
|
487 fileName.Append(KVideoTestOtaSourceFileName); |
|
488 |
|
489 User::LeaveIfError(source->Load(fileName)); |
|
490 |
|
491 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
492 CleanupStack::PushL(bmp); |
|
493 User::LeaveIfError(bmp->Create(source->SizeInPixels(),EGray2)); |
|
494 |
|
495 CMdaImageFileToBitmapUtility* ftob = CMdaImageFileToBitmapUtility::NewL(*this,aServer); |
|
496 CleanupStack::PushL(ftob); |
|
497 |
|
498 fileName = iEngine->DefaultPath(); |
|
499 fileName.Append(KVideoTestOtaFileName); |
|
500 |
|
501 ftob->OpenL(fileName,&iOtaClip); |
|
502 WaitAndCheckL(); |
|
503 ftob->ConvertL(*bmp,0); |
|
504 WaitAndCheckL(); |
|
505 |
|
506 CheckBitmaps(*source,*bmp); |
|
507 |
|
508 fileName = iEngine->DefaultPath(); |
|
509 fileName.Append(KVideoTestWbmpSourceFileName); |
|
510 |
|
511 User::LeaveIfError(source->Load(fileName)); |
|
512 User::LeaveIfError(bmp->Resize(source->SizeInPixels())); |
|
513 |
|
514 fileName = iEngine->DefaultPath(); |
|
515 fileName.Append(KVideoTestWbmpFileName); |
|
516 |
|
517 ftob->OpenL(fileName,&iWbmpClip); |
|
518 WaitAndCheckL(); |
|
519 ftob->ConvertL(*bmp,0); |
|
520 WaitAndCheckL(); |
|
521 CleanupStack::PopAndDestroy(); // ftob |
|
522 |
|
523 CheckBitmaps(*source,*bmp); |
|
524 |
|
525 CleanupStack::PopAndDestroy(2); // bmp, source |
|
526 } |
|
527 |
|
528 void CMdaVideo5Test::TransparentL(CMdaServer* aServer) |
|
529 { |
|
530 iEngine->Print(_L("Mask testing")); |
|
531 |
|
532 CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
533 CleanupStack::PushL(bmp); |
|
534 CFbsBitmap* mask = new(ELeave) CFbsBitmap; |
|
535 CleanupStack::PushL(mask); |
|
536 |
|
537 CMdaImageFileToBitmapUtility* ftob = CMdaImageFileToBitmapUtility::NewL(*this,aServer); |
|
538 CleanupStack::PushL(ftob); |
|
539 TFileName fileName = iEngine->DefaultPath(); |
|
540 fileName.Append(KVideoTestMaskFileName); |
|
541 ftob->OpenL(fileName); |
|
542 WaitAndCheckL(); |
|
543 |
|
544 // *** Jim added coverage of CMdaImageUtility::FrameCount() |
|
545 |
|
546 TFrameInfo info; |
|
547 ftob->FrameInfo(0,info); |
|
548 User::LeaveIfError(bmp->Create(info.iFrameCoordsInPixels.Size(),EGray2)); |
|
549 User::LeaveIfError(mask->Create(info.iFrameCoordsInPixels.Size(),EGray2)); |
|
550 |
|
551 ftob->ConvertL(*bmp,*mask,0); |
|
552 WaitAndCheckL(); |
|
553 |
|
554 CheckBitmaps(*bmp,*mask); |
|
555 |
|
556 CleanupStack::PopAndDestroy(3); // ftob,bmp,mask |
|
557 } |
|
558 |
|
559 void CMdaVideo5Test::TestRotationL() |
|
560 { |
|
561 iEngine->Print(_L("Rotation utility")); |
|
562 |
|
563 CFbsBitmap* srcBmp = new(ELeave) CFbsBitmap; |
|
564 CleanupStack::PushL(srcBmp); |
|
565 User::LeaveIfError(srcBmp->Load(iEngine->iSourceFileName)); |
|
566 |
|
567 CFbsBitmap* tgtBmp = new(ELeave) CFbsBitmap; |
|
568 CleanupStack::PushL(tgtBmp); |
|
569 User::LeaveIfError(tgtBmp->Create(TSize(0,0),EColor16M)); |
|
570 |
|
571 CMdaBitmapRotator* rotator = CMdaBitmapRotator::NewL(); |
|
572 CleanupStack::PushL(rotator); |
|
573 |
|
574 rotator->RotateL(*this,*srcBmp,*tgtBmp,CMdaBitmapRotator::TRotationAngle(0)); |
|
575 WaitAndCheckL(); |
|
576 CheckBitmaps(*srcBmp,*tgtBmp,1); |
|
577 rotator->RotateL(*this,*tgtBmp,CMdaBitmapRotator::TRotationAngle(2)); |
|
578 WaitAndCheckL(); |
|
579 CheckBitmaps(*srcBmp,*tgtBmp,0); |
|
580 |
|
581 rotator->RotateL(*this,*srcBmp,*tgtBmp,CMdaBitmapRotator::TRotationAngle(1)); |
|
582 WaitAndCheckL(); |
|
583 CheckBitmaps(*srcBmp,*tgtBmp,2); |
|
584 rotator->RotateL(*this,*tgtBmp,CMdaBitmapRotator::TRotationAngle(1)); |
|
585 WaitAndCheckL(); |
|
586 CheckBitmaps(*srcBmp,*tgtBmp,0); |
|
587 |
|
588 rotator->RotateL(*this,*srcBmp,*tgtBmp,CMdaBitmapRotator::TRotationAngle(2)); |
|
589 WaitAndCheckL(); |
|
590 CheckBitmaps(*srcBmp,*tgtBmp,3); |
|
591 rotator->RotateL(*this,*tgtBmp,CMdaBitmapRotator::TRotationAngle(0)); |
|
592 WaitAndCheckL(); |
|
593 CheckBitmaps(*srcBmp,*tgtBmp,0); |
|
594 |
|
595 rotator->RotateL(*this,*srcBmp,*tgtBmp,CMdaBitmapRotator::TRotationAngle(2)); |
|
596 rotator->CancelRotation(); |
|
597 rotator->RotateL(*this,*tgtBmp,CMdaBitmapRotator::TRotationAngle(0)); |
|
598 rotator->CancelRotation(); |
|
599 |
|
600 CleanupStack::PopAndDestroy(3); // rotator, tgtBmp, srcBmp |
|
601 } |
|
602 |
|
603 void CMdaVideo5Test::TestScalingL() |
|
604 { |
|
605 iEngine->Print(_L("Scaling utility")); |
|
606 |
|
607 CFbsBitmap* srcBmp = new(ELeave) CFbsBitmap; |
|
608 CleanupStack::PushL(srcBmp); |
|
609 User::LeaveIfError(srcBmp->Load(iEngine->iSourceFileName)); |
|
610 const TSize size(srcBmp->SizeInPixels()); |
|
611 |
|
612 CFbsBitmap* tgtBmp = new(ELeave) CFbsBitmap; |
|
613 CleanupStack::PushL(tgtBmp); |
|
614 User::LeaveIfError(tgtBmp->Create(TSize(0,0),EColor4K)); |
|
615 |
|
616 CMdaBitmapScaler* scaler = CMdaBitmapScaler::NewL(); |
|
617 CleanupStack::PushL(scaler); |
|
618 |
|
619 tgtBmp->Resize(TSize(size.iWidth / 2,size.iHeight / 2)); |
|
620 scaler->ScaleL(*this,*srcBmp,*tgtBmp); |
|
621 WaitAndCheckL(); |
|
622 CheckBitmapL(*tgtBmp); |
|
623 |
|
624 scaler->ScaleL(*this,*tgtBmp,TSize(size.iWidth * 2,size.iHeight * 2)); |
|
625 WaitAndCheckL(); |
|
626 CheckBitmapL(*tgtBmp); |
|
627 |
|
628 tgtBmp->Resize(TSize(size.iWidth,size.iHeight / 2)); |
|
629 scaler->ScaleL(*this,*srcBmp,*tgtBmp); |
|
630 WaitAndCheckL(); |
|
631 CheckBitmapL(*tgtBmp); |
|
632 |
|
633 scaler->ScaleL(*this,*tgtBmp,TSize(size.iWidth,size.iHeight / 2),EFalse); |
|
634 WaitAndCheckL(); |
|
635 CheckBitmapL(*tgtBmp); |
|
636 |
|
637 tgtBmp->Resize(TSize(size.iWidth / 2,size.iHeight)); |
|
638 scaler->ScaleL(*this,*srcBmp,*tgtBmp); |
|
639 WaitAndCheckL(); |
|
640 CheckBitmapL(*tgtBmp); |
|
641 |
|
642 scaler->ScaleL(*this,*tgtBmp,TSize(size.iWidth / 2,size.iHeight),EFalse); |
|
643 WaitAndCheckL(); |
|
644 CheckBitmapL(*tgtBmp); |
|
645 |
|
646 scaler->ScaleL(*this,*srcBmp,*tgtBmp); |
|
647 scaler->CancelScaling(); |
|
648 scaler->ScaleL(*this,*tgtBmp,srcBmp->SizeInPixels()); |
|
649 scaler->CancelScaling(); |
|
650 scaler->ScaleL(*this,*srcBmp,*tgtBmp,EFalse); |
|
651 scaler->CancelScaling(); |
|
652 scaler->ScaleL(*this,*tgtBmp,srcBmp->SizeInPixels(),EFalse); |
|
653 scaler->CancelScaling(); |
|
654 |
|
655 CleanupStack::PopAndDestroy(3); // scaler, tgtBmp, srcBmp |
|
656 } |
|
657 |
|
658 void CMdaVideo5Test::MiuoCreateComplete(TInt aError) |
|
659 { |
|
660 Signal(aError,_L("Create complete")); |
|
661 } |
|
662 |
|
663 void CMdaVideo5Test::MiuoOpenComplete(TInt aError) |
|
664 { |
|
665 Signal(aError,_L("Open complete")); |
|
666 } |
|
667 |
|
668 void CMdaVideo5Test::MiuoConvertComplete(TInt aError) |
|
669 { |
|
670 Signal(aError,_L("Convert complete")); |
|
671 } |
|
672 |
|
673 void CMdaVideo5Test::WaitL() |
|
674 { |
|
675 CActiveScheduler::Start(); |
|
676 } |
|
677 |
|
678 void CMdaVideo5Test::WaitAndCheckL() |
|
679 { |
|
680 CActiveScheduler::Start(); |
|
681 if (iError != KErrNone) |
|
682 iEngine->TestFailed(iError); |
|
683 } |
|
684 |
|
685 void CMdaVideo5Test::Signal(TInt aError,const TDesC& aMsg) |
|
686 { |
|
687 iError = aError; |
|
688 if (iError == KErrNone) |
|
689 iEngine->Print(aMsg); |
|
690 CActiveScheduler::Stop(); |
|
691 } |
|
692 |
|
693 void CMdaVideo5Test::CheckBitmapL(CFbsBitmap& aBitmap) |
|
694 { |
|
695 TFileName fileName; |
|
696 fileName = iEngine->DefaultPath(); |
|
697 fileName.Append(KVideoTestSourceScaledFileName); |
|
698 fileName.AppendNum(iScaledIndex++); |
|
699 fileName.Append(KVideoTestRefExt); |
|
700 |
|
701 User::LeaveIfError(iReferenceScaledBitmap->Load(fileName)); |
|
702 |
|
703 CheckBitmaps(aBitmap,*iReferenceScaledBitmap); |
|
704 |
|
705 iReferenceScaledBitmap->Reset(); |
|
706 } |