使用C#从网页中保存一张图片,保存的同时只截取图片的上半部分保存 ,怎么写C#

解决方案 »

  1.   

    Bitmap newbitmap=new Bitmap(source.Width/2,source.Height/2);
    Graphics g=Graphics.FromImage(newbitmap);
    g.DrawImage(source,0,0);
    g.Dispose();
    newbitmap.Save("");
    newbitmap.Dispose();
      

  2.   

    Bitmap newbitmap=new Bitmap(source.Width,source.Height/2);搞错了
      

  3.   

     Bitmap bmp = new Bitmap(@"E:\4.1\209\mobile.jpg");
                Graphics g = Graphics.FromImage(bmp);
                Rectangle aaa = new Rectangle(0, 0, 2, 2);
                g.DrawImage(bmp, 0, 0, aaa, GraphicsUnit.Pixel);
                bmp.Save(@"E:\4.1\209\mobile1.jpg", System.Drawing.Imaging.ImageFormat.Bmp);
    目前写成这样 没用 求该
      

  4.   


    Bitmap source = new Bitmap(@"E:\4.1\209\mobile.jpg");Bitmap newbitmap=new Bitmap(source.Width,source.Height/2);
    Graphics g=Graphics.FromImage(newbitmap);
    g.DrawImage(source,0,0);
    g.Dispose();newbitmap.Save(@"E:\4.1\209\mobile1.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);
    newbitmap.Dispose(); 
    source.Dispose();
      

  5.   

     Bitmap newbitmap = new Bitmap(source.Width, source.Height);按照原比例出的图和原图范围不一致呢
      

  6.   

    指定大小就可以了
    g.DrawImage(source,0,0,newbitmap.Width,newbitmap.Height,....自己补充);