图像适配源码

 public struct FitSizeTable
        {
           public  long fitw ;
           public  long fith;
           public float fitsize;
        }

        public FitSizeTable FitSize(long Srw, long Srh, long Dsw, long Dsh)
        {
            float SrBL = (float)Srh / Srw;
            float DsBL = (float)Dsh / Dsw;
          
            FitSizeTable DsetFitsize;
            
            if (SrBL > DsBL)
            {
                DsetFitsize.fith = Dsh;


                DsetFitsize.fitw =((long)Math.Round((float)Srw / Srh * Dsh));
            }
            else
            {
                if (SrBL < DsBL)
                {
                    DsetFitsize.fitw = Dsw;
                    DsetFitsize.fith = (long)SrBL * Dsh;
                }
                else
                {
                    DsetFitsize.fith = Dsh;
                    DsetFitsize.fitw = Dsw;
                }
            }

           DsetFitsize.fitsize = (float)Math.Round((float)DsetFitsize.fith / Srh, 2);
           return DsetFitsize;
        }

posted @ 2012-12-04 17:34  dongzhaosheng73  阅读(130)  评论(0编辑  收藏  举报