phoneuis/BubbleManager/Src/BMCallObjectManager.cpp
branchRCL_3
changeset 22 94dc1107e8b2
parent 0 5f000ab63145
--- a/phoneuis/BubbleManager/Src/BMCallObjectManager.cpp	Mon Jun 21 15:39:45 2010 +0300
+++ b/phoneuis/BubbleManager/Src/BMCallObjectManager.cpp	Thu Jul 15 18:38:16 2010 +0300
@@ -167,36 +167,52 @@
     
     TSize sourceSize( iMediaReader->SourceSize() );
     
-    TReal scaleFactor;
-    TRect clipRect;
-    TSize targetSize;
-    if ( BubbleCallObjectUtils::GetScaleFactorAndClipRect(
+    TReal scaleFactor( 0 );
+    TRect clipRect( 0, 0, 0, 0 );
+    TSize targetSize( 0, 0 );
+    
+    // if the caller image (source size) is bigger than aPreferredImageSize (the whole caller-image area)
+    // then some down scaling is required.
+    if ( sourceSize.iHeight > aPreferredImageSize.iHeight && sourceSize.iWidth > aPreferredImageSize.iWidth )
+        {
+        targetSize = aPreferredImageSize;
+        
+        BubbleCallObjectUtils::GetScaleFactorAndClipRect(
              sourceSize,
              aPreferredImageSize,
              BubbleCallObjectUtils::EFillTarget,
              scaleFactor,
-             clipRect ) &&
-         aTinyImageSize != TSize(0,0) )
+             clipRect ); 
+        }
+    else // no scaling. wide or tall images gets cropped from center if required.
         {
-        // Tiny image
-        BubbleCallObjectUtils::GetScaleFactorAndClipRect(
-             sourceSize,
-             aTinyImageSize,
-             BubbleCallObjectUtils::EMaximumFit,
-             scaleFactor,
-             clipRect );
-        
-        targetSize = aTinyImageSize;           
+        targetSize = aPreferredImageSize;
+        scaleFactor = 1;
+        TInt x_offset = 0;
+        TInt y_offset = 0;
+
+        if ( sourceSize.iWidth > aPreferredImageSize.iWidth )
+            {
+            x_offset = ( sourceSize.iWidth - aPreferredImageSize.iWidth ) / 2;
+            }
+        if ( sourceSize.iHeight > aPreferredImageSize.iHeight )
+            {
+            y_offset = ( sourceSize.iHeight - aPreferredImageSize.iHeight ) / 2; 
+            }
+
+        clipRect = sourceSize;
+                
+        if ( x_offset > 0 || y_offset > 0 )
+            {
+            // clip from center of the source image
+            clipRect.Shrink( x_offset, y_offset );
+            }
         }
-    else
-        {
-        targetSize = aPreferredImageSize;    
-        }        
-    
+
     iMediaReader->StartReadingL( targetSize, 
                                  scaleFactor, 
                                  clipRect, 
-                                 this );    
+                                 this );   
     }
 
 // ---------------------------------------------------------------------------