陋室铭
永远也不要停下学习的脚步(大道至简至易)

       //Server.MapPath(ImagePath))为取得图片绝对路径
         /// <summary>
        /// 按比例缩小图片(高度按缩小按宽度的缩小比例缩小)
        /// </summary>
        /// <param name="ImageMap">界面显示的Image</param>
        /// <param name="ImagePath">图片虚拟路径</param>
        /// <param name="WidthSize">图片缩小后定下的宽度</param>
        /// <param name="Server">本页的Server</param>
        public void ImageSize(System.Web.UI.WebControls.Image ImageMap, string ImagePath, int WidthSize,System.Web.HttpServerUtility Server)
        {
            System.Drawing.Image Img = System.Drawing.Image.FromFile(Server.MapPath(ImagePath));
            int ImgWidth = Img.Width;
            int ImgHeight = Img.Height;
            ImageMap.ImageUrl = ImagePath;
            if (ImgWidth > WidthSize)
            {
                ImageMap.Width = WidthSize;
                ImageMap.Height = WidthSize * ImgHeight / ImgWidth;
            }
        }
posted on 2007-01-19 09:19  宏宇  阅读(338)  评论(0编辑  收藏  举报