private Size NewSize(int maxWidth, int maxHeight, int width, int height) { double w = 0.0; double h = 0.0; double sw = Convert.ToDouble(width); double sh = Convert.ToDouble(height); double mw = Convert.ToDouble(maxWidth); double mh = Convert.ToDouble(maxHeight);
if ( sw < mw && sh < mh ) { w = sw; h = sh; } else if ( (sw/sh) > (mw/mh) ) { w = maxWidth; h = (w * sh)/sw; } else { h = maxHeight; w = (h * sw)/sh; }
return new Size(Convert.ToInt32(w), Convert.ToInt32(h)); }
private void SendSmallImage(string fileName, int maxWidth, int maxHeight) { System.Drawing.Image img = System.Drawing.Image.FromFile(Server.MapPath(fileName));