diff -r 2e2a89493e2b -r 48dd0f169f0d imagehandlingutilities/thumbnailmanager/inc/thumbnailprovider.inl --- a/imagehandlingutilities/thumbnailmanager/inc/thumbnailprovider.inl Fri Sep 03 10:29:37 2010 +0300 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,92 +0,0 @@ -/* -* Copyright (c) 2006-2007 Nokia Corporation and/or its subsidiary(-ies). -* All rights reserved. -* This component and the accompanying materials are made available -* under the terms of "Eclipse Public License v1.0" -* which accompanies this distribution, and is available -* at the URL "http://www.eclipse.org/legal/epl-v10.html". -* -* Initial Contributors: -* Nokia Corporation - initial contribution. -* -* Contributors: -* -* Description: Thumbnail provider class inline functions -* -*/ - - -#include - - -inline TSize CThumbnailProvider::FitToSize( const TSize& aOrigSize, - const TSize& aTargetSize, - TBool aCrop ) - { - TSize res; - TReal32 srcAspect = - static_cast( aOrigSize.iWidth ) / aOrigSize.iHeight; - TReal32 reqAspect = - static_cast( aTargetSize.iWidth ) / aTargetSize.iHeight; - - res = aTargetSize; - - // Check whether the width or the height is the limiting factor for - // the size - TBool widthLimited = srcAspect > reqAspect; - if ( aCrop ) - { - // When cropping, this works exactly the opposite way - widthLimited = srcAspect < reqAspect; - } - - if ( res.iWidth >= aOrigSize.iWidth && - res.iHeight >= aOrigSize.iHeight ) - { - // Original is smaller than requested. No scaling needed. - res = aOrigSize; - } - else if ( widthLimited ) - { - // Width is the limiting factor, ie. the thumbnail is - // wide compared to requested size. - TReal trg; - TReal src( aTargetSize.iWidth / srcAspect ); - Math::Round( trg, src, 1 ); - res.SetSize( - aTargetSize.iWidth, - trg ); - } - else - { - // Height is the limiting factor, ie. the thumbnail is - // taller compared to requested size. - TReal trg; - TReal src( aTargetSize.iHeight * srcAspect ); - Math::Round( trg, src, 1 ); - res.SetSize( - trg, - aTargetSize.iHeight ); - } - return res; - } - - -inline void CThumbnailProvider::ResolveSize() - { - // Get the actual target size for the thumbnail. - // This is the maximum of the non-cropped and cropped - // target sizes. - - TSize scaledSize = FitToSize( iOriginalSize, iTargetSize, EFalse ); - if ( iCroppedTargetSize.iHeight && iCroppedTargetSize.iWidth ) - { - TSize croppedSize = FitToSize( - iOriginalSize, iCroppedTargetSize, ETrue ); - scaledSize.iWidth = Max( scaledSize.iWidth, croppedSize.iWidth ); - scaledSize.iHeight = Max( scaledSize.iHeight, croppedSize.iHeight ); - } - iTargetSize = scaledSize; - TN_DEBUG3("CThumbnailProvider::ResolveSize() - iTargetSize=(%d, %d)", - iTargetSize.iWidth, iTargetSize.iHeight); - }