|
1 // Copyright (c) 2008-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 <e32base.h> |
|
17 #include <panorama/panorama.h> |
|
18 #include "panoramaimpl.h" |
|
19 #include <fbs.h> |
|
20 |
|
21 /** |
|
22 Constructs a new image panorama object. |
|
23 |
|
24 A leave occurs if there is insufficient memory available. |
|
25 |
|
26 @return A pointer to the new image panorama object. |
|
27 */ |
|
28 EXPORT_C CImagePanorama* CImagePanorama::NewL() |
|
29 { |
|
30 CImagePanorama* self = new(ELeave) CImagePanorama(); |
|
31 CleanupStack::PushL(self); |
|
32 self->ConstructL(); |
|
33 CleanupStack::Pop(); |
|
34 return self; |
|
35 } |
|
36 |
|
37 CImagePanorama::CImagePanorama() |
|
38 { |
|
39 } |
|
40 |
|
41 void CImagePanorama::ConstructL() |
|
42 { |
|
43 iImgPanImpl = CImagePanoramaImpl::NewL(); |
|
44 } |
|
45 |
|
46 EXPORT_C CImagePanorama::~CImagePanorama() |
|
47 { |
|
48 delete iImgPanImpl; |
|
49 } |
|
50 |
|
51 /** |
|
52 Initialises the size, direction and panoramalens on plugin and creates the CCapsPanorama, |
|
53 CCapsPanoramaTransform objects. |
|
54 @param aSize |
|
55 Size of the image. |
|
56 @param aPanoramaLens |
|
57 Panorama lens which is specific to camera |
|
58 @param aDirection |
|
59 Direction of the panorama |
|
60 */ |
|
61 EXPORT_C void CImagePanorama::InitializeL(const TSize & aSize, const TPanoramaLens& aPanoramaLens, const TDirection& aDirection) |
|
62 { |
|
63 iImgPanImpl->InitializeL(aSize, aPanoramaLens, aDirection); |
|
64 } |
|
65 |
|
66 /** |
|
67 Renders the currest session image to file. |
|
68 @param aFilename |
|
69 Filename specifying where to store the output file. |
|
70 */ |
|
71 EXPORT_C void CImagePanorama::RenderL(const TDesC& aFilename) |
|
72 { |
|
73 iImgPanImpl->RenderL(aFilename); |
|
74 } |
|
75 |
|
76 /** |
|
77 Renders the current session image to file. |
|
78 @param aFilename |
|
79 Filename specifying where to store the output file. |
|
80 @param aSize |
|
81 Dimensions of the output image. |
|
82 @param aMaintainAspectRatio |
|
83 Aspect ratio based on which output options will be defined |
|
84 @param aImageTypeUid |
|
85 The format Uid in which to encode the output image |
|
86 */ |
|
87 EXPORT_C void CImagePanorama::RenderL(const TDesC& aFilename, const TSize& aSize, const TBool aMaintainAspectRatio, const TUid& aImageTypeUid) |
|
88 { |
|
89 iImgPanImpl->RenderL(aFilename, aSize, aMaintainAspectRatio, aImageTypeUid); |
|
90 } |
|
91 |
|
92 /** |
|
93 Renders the current session image to an open file handle. |
|
94 @param aFile |
|
95 A file handler. |
|
96 */ |
|
97 EXPORT_C void CImagePanorama::RenderL(RFile& aFile) |
|
98 { |
|
99 iImgPanImpl->RenderL(aFile); |
|
100 } |
|
101 |
|
102 /** |
|
103 Renders the current session image to an open file handle. |
|
104 @param aFile |
|
105 A file handler |
|
106 @param aSize |
|
107 Dimensions of the output image. |
|
108 @param aMaintainAspectRatio |
|
109 Aspect ratio based on which output options will be defined. |
|
110 @param aImageTypeUid |
|
111 The format Uid in which to encode the output image. |
|
112 */ |
|
113 EXPORT_C void CImagePanorama::RenderL(RFile& aFile, const TSize& aSize, const TBool aMaintainAspectRatio, const TUid& aImageTypeUid) |
|
114 { |
|
115 iImgPanImpl->RenderL(aFile, aSize, aMaintainAspectRatio, aImageTypeUid); |
|
116 } |
|
117 |
|
118 /** |
|
119 Renders the current session image encoded to a buffer. |
|
120 @param aDestData |
|
121 Pointer to a buffer which will recieve the encoded image data. |
|
122 */ |
|
123 EXPORT_C void CImagePanorama::RenderL(HBufC8*& aDestData) |
|
124 { |
|
125 iImgPanImpl->RenderL(aDestData); |
|
126 } |
|
127 |
|
128 /** |
|
129 Renders the current session image encoded to a buffer. |
|
130 @param aDestData |
|
131 Pointer to a buffer which will recieve the encoded image data. |
|
132 @param aMaxBufferSize |
|
133 The maximum size of the buffer in bytes. |
|
134 @param aSize |
|
135 Dimensions of the output image. |
|
136 @param aMaintainAspectRatio |
|
137 Aspect ratio based on which output options will be defined. |
|
138 @param aImageTypeUid |
|
139 The format Uid in which to encode the output image. |
|
140 */ |
|
141 EXPORT_C void CImagePanorama::RenderL(HBufC8*& aDestData, TUint32 aMaxBufferSize, const TSize& aSize, const TBool aMaintainAspectRatio, const TUid& aImageTypeUid) |
|
142 { |
|
143 iImgPanImpl->RenderL(aDestData, aMaxBufferSize, aSize, aMaintainAspectRatio, aImageTypeUid); |
|
144 } |
|
145 |
|
146 /** |
|
147 Renders the output to a buffer in raw format. |
|
148 @param aBitmap |
|
149 A bitmap to get the output image. |
|
150 */ |
|
151 EXPORT_C void CImagePanorama::RenderL(const CFbsBitmap& aBitmap) |
|
152 { |
|
153 if(aBitmap.Handle()!=0 && aBitmap.ExtendedBitmapType()!=KNullUid) |
|
154 { |
|
155 User::Leave(KErrNotSupported); |
|
156 } |
|
157 iImgPanImpl->RenderL(aBitmap); |
|
158 } |
|
159 |
|
160 /** |
|
161 Renders the output to a buffer in raw format. |
|
162 @param aBitmap |
|
163 A bitmap to get the output image. |
|
164 @param aMaintainAspectRatio |
|
165 Aspect ration based on which output options will be defined. |
|
166 */ |
|
167 EXPORT_C void CImagePanorama::RenderL(const CFbsBitmap& aBitmap, const TBool aMaintainAspectRatio) |
|
168 { |
|
169 if(aBitmap.Handle()!=0 && aBitmap.ExtendedBitmapType()!=KNullUid) |
|
170 { |
|
171 User::Leave(KErrNotSupported); |
|
172 } |
|
173 |
|
174 iImgPanImpl->RenderL(aBitmap, aMaintainAspectRatio); |
|
175 } |
|
176 |
|
177 /** |
|
178 Renders the output to a buffer in raw format. |
|
179 @param aImageFrame |
|
180 A imageframe object to get the output image. |
|
181 */ |
|
182 EXPORT_C void CImagePanorama::RenderL(const CImageFrame& aImageFrame) |
|
183 { |
|
184 iImgPanImpl->RenderL(aImageFrame); |
|
185 } |
|
186 |
|
187 /** |
|
188 Renders the output to a buffer in raw format. |
|
189 @param aImageFrame |
|
190 A imageframe object to get the output image. |
|
191 @param aMaintainAspectRatio |
|
192 Aspect ration based on which output options will be defined. |
|
193 */ |
|
194 EXPORT_C void CImagePanorama::RenderL(const CImageFrame& aImageFrame, const TBool aMaintainAspectRatio) |
|
195 { |
|
196 iImgPanImpl->RenderL(aImageFrame, aMaintainAspectRatio); |
|
197 } |
|
198 |
|
199 /** |
|
200 Retrieves the dimensions of the current session image. |
|
201 @param aSize |
|
202 Dimensions of the image. |
|
203 */ |
|
204 EXPORT_C void CImagePanorama::CurrentImageSizeL(TSize& aSize) |
|
205 { |
|
206 iImgPanImpl->CurrentImageSizeL(aSize); |
|
207 } |
|
208 |
|
209 /** |
|
210 Add an image to the panorama creation |
|
211 @param aFilename |
|
212 Input filename |
|
213 @param aPanTrans |
|
214 Panorama transform object |
|
215 */ |
|
216 EXPORT_C void CImagePanorama::AddFileL(const TDesC& aFilename, CPanoramaTransform& aPanTrans) |
|
217 { |
|
218 iImgPanImpl->AddFileL(aFilename, aPanTrans); |
|
219 } |
|
220 |
|
221 /** |
|
222 Add an image to the panorama creation |
|
223 @param aData |
|
224 The buffer containing the image data |
|
225 @param aPanTrans |
|
226 Panorama transform object |
|
227 */ |
|
228 EXPORT_C void CImagePanorama::AddBufferL(const TDesC8& aData, CPanoramaTransform& aPanTrans) |
|
229 { |
|
230 iImgPanImpl->AddBufferL(aData, aPanTrans); |
|
231 } |
|
232 |
|
233 /** |
|
234 Add an image to the panorama creation in progress |
|
235 @param aBitmap |
|
236 A bitmap that will contain the image |
|
237 @param aPanTrans |
|
238 Panorama transform object |
|
239 */ |
|
240 EXPORT_C void CImagePanorama::AddImageL(const CFbsBitmap& aBitmap, CPanoramaTransform& aPanTrans) |
|
241 { |
|
242 if(aBitmap.Handle()!=0 && aBitmap.ExtendedBitmapType()!=KNullUid) |
|
243 { |
|
244 User::Leave(KErrNotSupported); |
|
245 } |
|
246 |
|
247 iImgPanImpl->AddImageL(aBitmap, aPanTrans); |
|
248 } |
|
249 |
|
250 /** |
|
251 Add an image to the panorama creation in progress |
|
252 @param aImageFrame |
|
253 A imageframe object. |
|
254 @param aPanTrans |
|
255 Panorama transform object. |
|
256 */ |
|
257 EXPORT_C void CImagePanorama::AddImageL(const CImageFrame& aImageFrame, CPanoramaTransform& aPanTrans) |
|
258 { |
|
259 iImgPanImpl->AddImageL(aImageFrame, aPanTrans); |
|
260 } |
|
261 |
|
262 /** |
|
263 Retrieves a non-standard extension on the image panorama. |
|
264 |
|
265 @param aExtension |
|
266 The UID of the extension to be retrieved |
|
267 |
|
268 @return Extension corresponding to the UID given as a parameter. |
|
269 */ |
|
270 EXPORT_C TAny* CImagePanorama::Extension(TUid aExtension) |
|
271 { |
|
272 return iImgPanImpl->Extension(aExtension); |
|
273 } |
|
274 |
|
275 /** |
|
276 Constructs a new panorama transform object. |
|
277 |
|
278 A leave occurs if there is insufficient memory available. |
|
279 |
|
280 @return A pointer to the new panorama transform object. |
|
281 */ |
|
282 EXPORT_C CPanoramaTransform* CPanoramaTransform::NewL() |
|
283 { |
|
284 CPanoramaTransform* self = new(ELeave) CPanoramaTransform(); |
|
285 CleanupStack::PushL(self); |
|
286 self->ConstructL(); |
|
287 CleanupStack::Pop(); |
|
288 return self; |
|
289 } |
|
290 |
|
291 CPanoramaTransform::CPanoramaTransform() |
|
292 { |
|
293 } |
|
294 |
|
295 void CPanoramaTransform::ConstructL() |
|
296 { |
|
297 iPanTransImpl = CPanoramaTransformImpl::NewL(); |
|
298 } |
|
299 |
|
300 EXPORT_C CPanoramaTransform::~CPanoramaTransform() |
|
301 { |
|
302 delete iPanTransImpl; |
|
303 } |
|
304 |
|
305 /** |
|
306 Get the translation part of a PanoramaTransform |
|
307 @param aDxDy |
|
308 x and y coordinates |
|
309 @param aDims |
|
310 Image dimensions for the transform |
|
311 */ |
|
312 EXPORT_C void CPanoramaTransform::GetTranslation(TPoint& aDxDy, TSize& aDims) const |
|
313 { |
|
314 iPanTransImpl->GetTranslation(aDxDy, aDims); |
|
315 } |
|
316 |
|
317 /** |
|
318 Set the desired translation values on a panorama transform object. |
|
319 @param aDxDy |
|
320 x and y coordinates |
|
321 @param aDims |
|
322 Image dimenstion for the transform |
|
323 */ |
|
324 EXPORT_C void CPanoramaTransform::SetTranslationL(const TPoint& aDxDy, const TSize& aDims) |
|
325 { |
|
326 iPanTransImpl->SetTranslationL(aDxDy, aDims); |
|
327 } |
|
328 |
|
329 /** |
|
330 Get the direction of a panorama transform |
|
331 @param aDirection |
|
332 Direction of the panorama |
|
333 */ |
|
334 EXPORT_C void CPanoramaTransform::GetDirection(TDirection& aDirection) |
|
335 { |
|
336 return iPanTransImpl->GetDirection(aDirection); |
|
337 } |
|
338 |
|
339 /** |
|
340 Get the direction of a panorama transform |
|
341 @param aDirection |
|
342 Direction of the panorama |
|
343 @param aMinimumDelta |
|
344 Minimum translation in percent. |
|
345 */ |
|
346 EXPORT_C void CPanoramaTransform::GetDirection(TDirection& aDirection, TInt& aMinimumDelta) |
|
347 { |
|
348 return iPanTransImpl->GetDirection(aDirection, aMinimumDelta); |
|
349 } |
|
350 |
|
351 /** |
|
352 Set the desired direction of a panorama transform |
|
353 @param aDirection |
|
354 Direction of the panorama |
|
355 */ |
|
356 EXPORT_C void CPanoramaTransform::SetDirection(TDirection& aDirection) |
|
357 { |
|
358 iPanTransImpl->SetDirection(aDirection); |
|
359 } |
|
360 |
|
361 /** |
|
362 Set the desired direction of a panorama transform |
|
363 @param aDirection |
|
364 Direction of the panorama |
|
365 @param aMinDelta |
|
366 Minimum translation in percent. |
|
367 */ |
|
368 EXPORT_C void CPanoramaTransform::SetDirection(TDirection& aDirection, TInt aMinDelta) |
|
369 { |
|
370 iPanTransImpl->SetDirection(aDirection, aMinDelta); |
|
371 } |
|
372 |
|
373 /** |
|
374 Constructs a new VFTracker object. |
|
375 |
|
376 A leave occurs if there is insufficient memory available. |
|
377 |
|
378 @return A pointer to a new VFTracker object. |
|
379 */ |
|
380 EXPORT_C CVFTracker* CVFTracker::NewL() |
|
381 { |
|
382 CVFTracker* self = new(ELeave) CVFTracker(); |
|
383 CleanupStack::PushL(self); |
|
384 self->ConstructL(); |
|
385 CleanupStack::Pop(); |
|
386 return self; |
|
387 } |
|
388 |
|
389 CVFTracker::CVFTracker() |
|
390 { |
|
391 } |
|
392 |
|
393 void CVFTracker::ConstructL() |
|
394 { |
|
395 iVFTrackImpl = CVFTrackerImpl::NewL(); |
|
396 } |
|
397 |
|
398 EXPORT_C CVFTracker::~CVFTracker() |
|
399 { |
|
400 delete iVFTrackImpl; |
|
401 } |
|
402 |
|
403 /** |
|
404 Initialises the dimensions of the image on the plugin and creates the VFTracker object. |
|
405 @param aSize |
|
406 Dimensions of the image. |
|
407 */ |
|
408 EXPORT_C void CVFTracker::InitializeL(const TSize & aSize) |
|
409 { |
|
410 iVFTrackImpl->InitializeL(aSize); |
|
411 } |
|
412 |
|
413 /** |
|
414 Performs overlapping calculations from viewfinder image. |
|
415 Pass all viewfinder images to this function to find out when its time to capture a new image. |
|
416 @param aBitmap |
|
417 A bitmap that needs to be registered |
|
418 @param aPanTrans |
|
419 A panorama transform object. |
|
420 */ |
|
421 EXPORT_C void CVFTracker::RegisterImageL(const CFbsBitmap& aBitmap, CPanoramaTransform& aPanTrans) |
|
422 { |
|
423 if(aBitmap.Handle()!=0 && aBitmap.ExtendedBitmapType()!=KNullUid) |
|
424 { |
|
425 User::Leave(KErrNotSupported); |
|
426 } |
|
427 |
|
428 iVFTrackImpl->RegisterImageL(aBitmap, aPanTrans); |
|
429 } |
|
430 |
|
431 /** |
|
432 Performs overlapping calculations from viewfinder image. |
|
433 Pass all viewfinder images to this function to find out when its time to capture a new image. |
|
434 @param aImageFrame |
|
435 A imageframe object. |
|
436 @param aPanTrans |
|
437 A panorama transform object. |
|
438 */ |
|
439 EXPORT_C void CVFTracker::RegisterImageL(const CImageFrame& aImageFrame, CPanoramaTransform& aPanTrans) |
|
440 { |
|
441 iVFTrackImpl->RegisterImageL(aImageFrame, aPanTrans); |
|
442 } |
|
443 |
|
444 /** |
|
445 Determines from a PanoramaTransform if it is time to capture a new image. |
|
446 @param aDirection |
|
447 The type of panorama being created. |
|
448 */ |
|
449 EXPORT_C TBool CVFTracker::IsTimeToCapture(TDirection& aDirection) const |
|
450 { |
|
451 return iVFTrackImpl->IsTimeToCapture(aDirection); |
|
452 } |
|
453 |
|
454 /** |
|
455 Determines from a PanoramaTransform if it is time to capture a new image. |
|
456 @param aDirection |
|
457 The type of panorama being created. |
|
458 @param aOverlap |
|
459 Desired overlap in the panorama image. |
|
460 */ |
|
461 EXPORT_C TBool CVFTracker::IsTimeToCapture(TDirection& aDirection, TInt aOverlap) const |
|
462 { |
|
463 return iVFTrackImpl->IsTimeToCapture(aDirection, aOverlap); |
|
464 } |
|
465 |
|
466 /** |
|
467 Resets the transform return for the next RegisterImageL(). |
|
468 */ |
|
469 EXPORT_C void CVFTracker::Reset() |
|
470 { |
|
471 iVFTrackImpl->Reset(); |
|
472 } |
|
473 |
|
474 /** |
|
475 Retrieves a non-standard extension on the VFTracker |
|
476 |
|
477 @param aExtension |
|
478 The UID of the extension to be retrieved |
|
479 |
|
480 @return Extension corresponding to the UID given as a parameter. |
|
481 */ |
|
482 EXPORT_C TAny* CVFTracker::Extension(TUid aExtension) |
|
483 { |
|
484 return iVFTrackImpl->Extension(aExtension); |
|
485 } |
|
486 |
|
487 /** |
|
488 Creates a TPanoramaLens object |
|
489 |
|
490 @param aFocalLength |
|
491 Focal length coordinates, this is an array of size KPanLensIndex. |
|
492 |
|
493 @param aPrincipalPoint |
|
494 Principal point coordinates, this is an array of size KPanLensIndex. |
|
495 |
|
496 @param aSkew |
|
497 Skew coefficient. @remark 0.0f means no skew |
|
498 |
|
499 @param aDist |
|
500 Distortion coefficients, this is an array of size KPanLensDist. |
|
501 |
|
502 @param aWidth |
|
503 Image width when the camera was calibrated. |
|
504 |
|
505 @param aHeight |
|
506 Image height when the camera was calibrated. |
|
507 */ |
|
508 EXPORT_C TPanoramaLens::TPanoramaLens(TReal32* aFocalLength, TReal32* aPrincipalPoint, TReal32 aSkew, TReal32* aDist, TUint32 aWidth, TUint32 aHeight) |
|
509 { |
|
510 TInt i = 0; |
|
511 for (i = 0; i < KPanLensIndex; i++) |
|
512 { |
|
513 iFocalLength[i] = aFocalLength[i]; |
|
514 iPrincipalPoint[i] = aPrincipalPoint[i]; |
|
515 } |
|
516 iSkew = aSkew; |
|
517 for (i = 0; i < KPanLensDist; i++) |
|
518 { |
|
519 iDist[i] = aDist[i]; |
|
520 } |
|
521 iWidth = aWidth; |
|
522 iHeight = aHeight; |
|
523 } |
|
524 |
|
525 EXPORT_C TPanoramaLens::TPanoramaLens() |
|
526 { |
|
527 // Empirical values from CAPS documentation so forgive the magic numbers. The values should probably come from a configuration or resource file |
|
528 iFocalLength[0] = 665.0f; |
|
529 iPrincipalPoint[0] = 665.0f; |
|
530 iFocalLength[1] = 320.0f; |
|
531 iPrincipalPoint[1] = 240.0f; |
|
532 |
|
533 iSkew = 0.0f; |
|
534 |
|
535 for (TInt i = 0; i < KPanLensDist; i++) |
|
536 { |
|
537 iDist[i] = 0.0f; |
|
538 } |
|
539 |
|
540 iWidth = 640; // VGA |
|
541 iHeight = 480; |
|
542 } |
|
543 |