• 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;

            }
        }

    }

  • 相关阅读:
    Java实现 LeetCode 27 移除元素
    Java实现 LeetCode 26 删除排序数组中的重复项
    Java实现 LeetCode 26 删除排序数组中的重复项
    Java实现 LeetCode 26 删除排序数组中的重复项
    Java实现 LeetCode 25 K个一组翻转链表
    Java实现 LeetCode 25 K个一组翻转链表
    Java实现 LeetCode 25 K个一组翻转链表
    Java实现 LeetCode 24 两两交换链表中的节点
    Java实现 LeetCode 24 两两交换链表中的节点
    Java实现 LeetCode 24 两两交换链表中的节点
  • 原文地址:https://www.cnblogs.com/perock/p/2555878.html
Copyright © 2020-2023  润新知