165 iMediaReader = NULL; |
165 iMediaReader = NULL; |
166 iMediaReader = BubbleMediaReaderFactory::CreateReaderL( aFileName ); |
166 iMediaReader = BubbleMediaReaderFactory::CreateReaderL( aFileName ); |
167 |
167 |
168 TSize sourceSize( iMediaReader->SourceSize() ); |
168 TSize sourceSize( iMediaReader->SourceSize() ); |
169 |
169 |
170 TReal scaleFactor; |
170 TReal scaleFactor( 0 ); |
171 TRect clipRect; |
171 TRect clipRect( 0, 0, 0, 0 ); |
172 TSize targetSize; |
172 TSize targetSize( 0, 0 ); |
173 if ( BubbleCallObjectUtils::GetScaleFactorAndClipRect( |
173 |
|
174 // if the caller image (source size) is bigger than aPreferredImageSize (the whole caller-image area) |
|
175 // then some down scaling is required. |
|
176 if ( sourceSize.iHeight > aPreferredImageSize.iHeight && sourceSize.iWidth > aPreferredImageSize.iWidth ) |
|
177 { |
|
178 targetSize = aPreferredImageSize; |
|
179 |
|
180 BubbleCallObjectUtils::GetScaleFactorAndClipRect( |
174 sourceSize, |
181 sourceSize, |
175 aPreferredImageSize, |
182 aPreferredImageSize, |
176 BubbleCallObjectUtils::EFillTarget, |
183 BubbleCallObjectUtils::EFillTarget, |
177 scaleFactor, |
184 scaleFactor, |
178 clipRect ) && |
185 clipRect ); |
179 aTinyImageSize != TSize(0,0) ) |
186 } |
180 { |
187 else // no scaling. wide or tall images gets cropped from center if required. |
181 // Tiny image |
188 { |
182 BubbleCallObjectUtils::GetScaleFactorAndClipRect( |
189 targetSize = aPreferredImageSize; |
183 sourceSize, |
190 scaleFactor = 1; |
184 aTinyImageSize, |
191 TInt x_offset = 0; |
185 BubbleCallObjectUtils::EMaximumFit, |
192 TInt y_offset = 0; |
186 scaleFactor, |
193 |
187 clipRect ); |
194 if ( sourceSize.iWidth > aPreferredImageSize.iWidth ) |
188 |
195 { |
189 targetSize = aTinyImageSize; |
196 x_offset = ( sourceSize.iWidth - aPreferredImageSize.iWidth ) / 2; |
190 } |
197 } |
191 else |
198 if ( sourceSize.iHeight > aPreferredImageSize.iHeight ) |
192 { |
199 { |
193 targetSize = aPreferredImageSize; |
200 y_offset = ( sourceSize.iHeight - aPreferredImageSize.iHeight ) / 2; |
194 } |
201 } |
195 |
202 |
|
203 clipRect = sourceSize; |
|
204 |
|
205 if ( x_offset > 0 || y_offset > 0 ) |
|
206 { |
|
207 // clip from center of the source image |
|
208 clipRect.Shrink( x_offset, y_offset ); |
|
209 } |
|
210 } |
|
211 |
196 iMediaReader->StartReadingL( targetSize, |
212 iMediaReader->StartReadingL( targetSize, |
197 scaleFactor, |
213 scaleFactor, |
198 clipRect, |
214 clipRect, |
199 this ); |
215 this ); |
200 } |
216 } |
201 |
217 |
202 // --------------------------------------------------------------------------- |
218 // --------------------------------------------------------------------------- |
203 // CBubbleCallObjectManager::LoadImageFromText |
219 // CBubbleCallObjectManager::LoadImageFromText |
204 // |
220 // |