示例#1
0
        //added fix by caching capture object references
        public System.Drawing.Image ScreenCapture(bool followMouse, System.Drawing.Point coordinates)
        {
            var size = new System.Drawing.Point(width, height);


            if (followMouse)
            {
                GDI32.BitBlt(hdcDest, 0, 0, width, height, hdcSrc, coordinates.X - width / 2, coordinates.Y - height / 2, GDI32.SRCCOPY);
            }
            else
            {
                GDI32.BitBlt(hdcDest, 0, 0, width, height, hdcSrc, screen_width / 2 - width / 2, screen_height / 2 - height / 2, GDI32.SRCCOPY);
            }

            try
            {
                return(System.Drawing.Image.FromHbitmap(hBitmap));
            }
            catch (Exception)
            {
                setHandle();
                return(System.Drawing.Image.FromHbitmap(hBitmap));
            }
        }