在asp.net中上传图片,怎样用C# 把gif和bmp格试转换为jpg格试
求代码

解决方案 »

  1.   

    System.Drawing.Image img = System.Drawing.Image.FromStream(new System.Net.WebClient().OpenRead(url));//获得图象
    System.IO.MemoryStream MS = new System.IO.MemoryStream();
    Bitmap bmp = new Bitmap(img);//生成位图
    bmp.Save(MS, System.Drawing.Imaging.ImageFormat.Jpg);
    MS.WriteTo(Response.OutputStream);//从内存流中输出位图到页面输出流,也可以写到文件或别的类型的流里面可以参考帮助,都有现成代码的
      

  2.   

    bmp.Save(MS, System.Drawing.Imaging.ImageFormat.Jpg);把ms变量换为本地路径的字符变量