imageWidth = img_old.Width; imageHeight = img_old.Height; // Figure out the ratio 397, 561 the maximum size double ratioX = (double)397 / (double)imageWidth; double ratioY = (double)561 / (double)imageHeight; // use whichever multiplier is smaller double ratio = ratioX < ratioY ? ratioX : ratioY; // now we can get the new height and width int newHeight = Convert.ToInt32(imageHeight * ratio); int newWidth = Convert.ToInt32(imageWidth * ratio); panelimage.Width = newWidth; panelimage.Height = newHeight;
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)