コード例 #1
0
ファイル: Form1.cs プロジェクト: quocdunginfo/khoangCach
        private MousePoint calculate(int wrapperH, int wrapperW, int realImgH, int realImgW)
        {
            MousePoint re = new MousePoint(0,0);

            int relativeImgH = 0;
            int relativeImgW = 0;
            float wraperTL = (float)wrapperH / wrapperW;
            float realImgTL = (float)realImgH / realImgW;
            if (wraperTL >= realImgTL)
            {
                relativeImgW = wrapperW;
                relativeImgH = (int)(relativeImgW * realImgTL);
            }
            else
            {
                relativeImgH = wrapperH;
                relativeImgW = (int)(relativeImgH / realImgTL);
            }
            re.setX(relativeImgW);
            re.setY(relativeImgH);
            return re;
        }