📄 rectscaler.cpp
字号:
/*
* ==============================================================================
* Name : RectScaler.cpp
* Part of : OcrExample
* Interface :
* Description :
* Version :
*
* Copyright (c) 2006 Nokia Corporation.
* This material, including documentation and any related
* computer programs, is protected by copyright controlled by
* Nokia Corporation.
* ==============================================================================
*/
#include "RectScaler.h"
using namespace NOCRUtils;
// ----------------------------------------------------------------------------
// TRectScaler-class member functions
// ----------------------------------------------------------------------------
TRectScaler::TRectScaler() : iFactor(0)
{
}
void TRectScaler::CalculateFactor( TSize aOriginal, TSize aScaled )
{
// calculate relative factor from width
iFactor = TReal(aOriginal.iWidth) / TReal(aScaled.iWidth);
}
TRect TRectScaler::ScaleUp( const TRect& aScaledRect ) const
{
ASSERT(iFactor > 0);
TPoint Tl = aScaledRect.iTl;
Tl.iX *= iFactor;
Tl.iY *= iFactor;
TPoint Br = aScaledRect.iBr;
Br.iX *= iFactor;
Br.iY *= iFactor;
return TRect( Tl, Br);
}
TRect TRectScaler::ScaleDown( const TRect& aOriginalRect ) const
{
ASSERT(iFactor > 0);
TPoint Tl = aOriginalRect.iTl;
Tl.iX /= iFactor;
Tl.iY /= iFactor;
TPoint Br = aOriginalRect.iBr;
Br.iX /= iFactor;
Br.iY /= iFactor;
return TRect( Tl, Br);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -