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