图片缩略图

 

   看到图片的缩略图,原理是读取原来的图片然后重新画一张缩小版的图,重新保存

  string filePath = context.Server.MapPath("FileUp/1.jpg");
        using (Image img=Image.FromFile(filePath))
        {
            using (Bitmap bmp=new Bitmap (200,150))
            {
                using (Graphics grap=Graphics.FromImage(bmp))
                {
                    grap.DrawImage(img,new Rectangle(0,0,bmp.Width,bmp.Height),new Rectangle(0,0,img.Width,img.Height),GraphicsUnit.Pixel);
                    bmp.Save(context.Response.OutputStream, ImageFormat.Jpeg);
                    bmp.Save(context.Server.MapPath("FileUP/11.jpg"));
                }
            }
        }

 

posted @ 2013-12-23 11:31  Flying_Boy  阅读(286)  评论(0编辑  收藏  举报