rectscaler.cpp

来自「基于symbian 平台 ocr 示例程序」· C++ 代码 · 共 64 行

CPP
64
字号
/*
* ==============================================================================
*  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 + =
减小字号Ctrl + -
显示快捷键?