resize

void resize()
{
    ;
    if (toWidth > toHeight)
    {
        if(orgHeight > orgWidth)
        {
            retHeight = toHeight;
            retWidth = orgWidth / orgHeight * toHeight;

        }
        if (orgHeight < orgWidth)
        {

            if (orgHeight / orgWidth * toWidth > toHeight)
            {
                retHeight = toHeight;
                retWidth = orgWidth / orgHeight * toHeight;

            }
            else
            {
                retWidth = toWidth;
                retHeight = orgHeight /orgWidth * toWidth;
            }

        }
        if (orgHeight == orgWidth)
        {
            retHeight = toHeight;
            retWidth = orgWidth / orgHeight * toHeight;
        }
    }

    if (toWidth < toHeight)
    {
        if(orgHeight > orgWidth)
        {
            if (orgWidth / orgHeight * toHeight > toWidth)
            {
                retWidth = toWidth;
                retHeight = orgHeight / orgWidth * toWidth;
            }
            else
            {
                retHeight = toHeight;
                retWidth = orgWidth / orgHeight * toHeight;
            }
        }
        if (orgHeight < orgWidth)
        {
            retWidth = toWidth;
            retHeight = orgHeight / orgWidth * toWidth;
        }
        if (orgHeight == orgWidth)
        {
            retWidth = toWidth;
            retHeight = orgHeight / orgWidth * toWidth;
        }
    }

    if (toWidth == toHeight)
    {
        if(orgHeight > orgWidth)
        {
            retHeight = toHeight;
            retWidth = orgWidth / orgHeight * toHeight;
        }
        if (orgHeight < orgWidth)
        {
            retWidth = toWidth;
            retHeight = orgHeight / orgWidth * toWidth;
        }
        if (orgHeight == orgWidth)
        {
            retHeight = toHeight;
            retWidth  = toWidth;

        }
    }

}

posted @ 2012-06-20 10:42  perock  阅读(291)  评论(0编辑  收藏  举报