生成缩略图(不失真)

       #region 获取缩略图
        /// <summary>
        /// 获取缩略图
        /// </summary>
        /// <param name="imgPath">要做缩略图的图片路径</param>
        /// <param name="savePaty">保存缩略图的路径</param>
        /// <returns>是否成功</returns>
        public static bool makeListImage(string imgPath, string savePaty)
        {
            try
            {
                System.Drawing.Image img = System.Drawing.Image.FromFile(imgPath);
                Graphics g = Graphics.FromImage(img);
                Font font = new Font("宋体", 14);
                Brush brush = Brushes.Black;
                g.DrawString("100wx.com", font, brush, 3, 3);
                //创建委托
                System.Drawing.Image.GetThumbnailImageAbort callback = new System.Drawing.Image.GetThumbnailImageAbort(gett);
               //生成图片的大小
                img = img.GetThumbnailImage(45, 45, callback, new IntPtr());
                img.Save(savePaty, System.Drawing.Imaging.ImageFormat.Jpeg);
                g.Dispose();
                img.Dispose();
                //PPD1aGlm
            }
            catch { return false; }
            return true;
        }
        public static bool gett()
        {
            return true;
        }
        #endregion
来自:http://blog.csdn.net/hellojimmy520/article/details/7278804

你可能感兴趣的:(生成缩略图(不失真))