GridView显示图片
GridView如何按缩放比例显示大图片。
[解决办法]
图像的属性宽和高百分比设置
[解决办法]
图片可以同比缩小阿,就看你想怎么实现了;
public static void ShowImage(string imageUrl, System.Web.UI.WebControls.Image image1, int width, int height) { string Url = imageUrl; try { System.Drawing.Image image = System.Drawing.Image.FromFile(HttpContext.Current.Server.MapPath(Url)); System.Drawing.Size size = new System.Drawing.Size(image.Width, image.Height); int w = size.Width; int h = size.Height; if (w > h) { if (w > width) { w = width; h = (w * size.Height) / size.Width; } } else { if (h > height) { h = height; w = (h * size.Width) / size.Height; } } image1.Attributes.Add("style", "width:" + w + "px;height:" + h + "px;"); image1.ImageUrl = Url; } catch { image1.ImageUrl = Url; } }
[解决办法]
先正常加载,然后cs里 用楼上的方法,循环缩放。可以吗