/// <summary>
/// 显示图片
/// </summary>
/// <param name="image"></param>
void ShowImage(string image, int max)
{
string str = Server.MapPath("~/productimages/" + image);
System.Drawing.Bitmap bit = new Bitmap(str);
double bili = Convert.ToDouble(bit.Height) / Convert.ToDouble(bit.Width);
if (bit.Width > bit.Height)
{
if (bit.Width < max)
{
this.Image1.Width = bit.Width;
this.Image1.Height = bit.Height;
}
else
{
int height = Convert.ToInt32((bili * max));
this.Image1.Width = max;
this.Image1.Height = height;
}
}
else
{
if (bit.Height < max)
{
this.Image1.Width = bit.Width;
this.Image1.Height = bit.Height;
}
else
{
int width = Convert.ToInt32(((1 / bili) * max));
this.Image1.Width = width;
this.Image1.Height = max;
}
}
Image1.ImageUrl = "~/productimages/" + image;
}