ShawnMolloy
MIS
Hello,
Can someone help me figure out a method of calculating the resize dimension of an image using an Image object in c#? This is what I have so far:
Thanks.
-- shawn
Can someone help me figure out a method of calculating the resize dimension of an image using an Image object in c#? This is what I have so far:
Code:
// Calculate the size and limit it to
// a max of either 500px height or
// 500px width, whichever is greater
// then assign the latter dimenion its new
// size
Image img = new Image();
int h = img.Height;
int w = img.Width;
// set height
if (img.Height >= 500) { // img is bigger that 500px heigh
imgDetail.Height = 500;
} else if (img.Width >= 500) { // img is bigger that 500px wide
// this doesn't work
imgDetail.Width = 500;
}
// calculate the amount to shink the height and width
w = Convert.ToInt32(Math.Round((Convert.ToDouble(h) /
img.Height) * img.Width));
imgDetail.Width = w;
Thanks.
-- shawn