首页 新闻 赞助 找找看

用户上传头像后,我怎么截取规定的尺寸大小

0
悬赏园豆:5 [已解决问题] 解决于 2009-11-25 14:58

用户上传头像后,我怎么截取规定的尺寸大小

拖鞋王子的主页 拖鞋王子 | 初学一级 | 园豆:37
提问于:2009-11-25 10:52
< >
分享
最佳答案
0

System.Drawing.Bitmap

 

 int Width = 200;
        int Height = 200;
        System.Drawing.Image image;
        string FilePath = Server.MapPath("UpFile/") + "woody.jpg";
        image = System.Drawing.Bitmap.FromFile(FilePath);
        Bitmap Img = new Bitmap(Width, Height);
        string newFilePath = Server.MapPath("UpFile/") + "newwoody.jpg";
        System.Drawing.Graphics gp = Graphics.FromImage(Img);
        Rectangle rl = new Rectangle(0, 0, 200, 200);
        gp.DrawImage(image, rl);
        Img.Save(newFilePath);
        Img.Dispose();
        gp.Dispose();
        image.Dispose();

收获园豆:5
woody.wu | 老鸟四级 |园豆:3621 | 2009-11-25 11:40
谢谢
拖鞋王子 | 园豆:37 (初学一级) | 2009-11-25 14:58
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册