我想获取屏幕上某一块的图像
例如我屏幕是1280*800的
我想获取到 左上角坐标为250,250
目标坐标为350,350的矩形范围内的图像
怎么获取?然后保存到Bitmap里

解决方案 »

  1.   

    public static void CaptureImage(Point SourcePoint, Point DestinationPoint, Rectangle SelectionRectangle, string FilePath)
    {
        using (Bitmap bitmap = new Bitmap(SelectionRectangle.Width, SelectionRectangle.Height))
        {
            using (Graphics g = Graphics.FromImage(bitmap))
            {
                g.CopyFromScreen(SourcePoint, DestinationPoint, SelectionRectangle.Size);
            }
            bitmap.Save(FilePath, System.Drawing.Imaging.ImageFormat.Bmp);
        }
    }或
    Rectangle R = System.Windows.Forms.Screen.PrimaryScreen.Bounds;
    Image img = new Bitmap(R.Width, R.Height);
    Graphics G = Graphics.FromImage(img);
    G.CopyFromScreen(new Point(0, 0), new Point(0, 0), new Size(R.Width, R.Height));。   
    IntPtr dc = G.GetHdc();   
    G.ReleaseHdc(dc);
    G.Dispose();
    img .Save("c:\\a.jpg");
      

  2.   

    哥啊
    我不是要截图的说 /(ㄒoㄒ)/~~
    我只是想放到Bitmap里