`
Lin_
  • 浏览: 15497 次
  • 性别: Icon_minigender_1
  • 来自: 汕头
社区版块
存档分类
最新评论

asp.net生成缩略图

web 
阅读更多
public static void SaveSmallImage(string photoPath, string savePath, int mWidth, int mHeight)
    {
        System.Drawing.Image image, aNewImage;
        int newWidth, newHeight;
        System.Drawing.Image.GetThumbnailImageAbort callb = null;
        image = System.Drawing.Image.FromFile(System.Web.HttpContext.Current.Server.MapPath(photoPath));
        newHeight = mHeight;
        newWidth = mWidth;

        if (mWidth == 0)
        {
            newWidth = image.Width / image.Height * newHeight;
        }
        if (mHeight == 0)
        {
            newHeight = image.Height / image.Width * newWidth;
        }

        aNewImage = image.GetThumbnailImage(newWidth, newHeight, callb, new System.IntPtr());
        aNewImage.Save(System.Web.HttpContext.Current.Server.MapPath(savePath), System.Drawing.Imaging.ImageFormat.Jpeg);
    }
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics