Miscellaneous > The Orphanage

Capturing a rectangle

(1/3) > >>

shankle:
                    5-21-2017

    I need an API that will capture a small rectangle
    from a 3rd party screen, so that I can put it in a
    folder of my choosing.
    There are tons of other programs out there that will do
    this but they are abysmally to slow for my needs and
    they have other restrictions. EX: FastStone Capture
    and the Snipping Tool.
    Use of the Clipboard also makes the speed I need to slow.
    Thanks for any help.
   

Vortex:
Hi shankle,

There is no any specific API to capture a portion of the screen. I modified my desktop capturing tool and  here is my function :


--- Code: ---    invoke  SaveDeskToFile,sx,\ ;x-coordinate, in logical units, of the upper-left corner
                           sy,\ ;y-coordinate, in logical units, of the upper-left corner
                           x,\ ; width, in logical units, of the rectange to capture
                           y,\ ; height, in logical units, of the rectange to capture
                           fname ; file name of the bitmap to save
--- End code ---

For example, if you wish to capture the full desktop with SaveDeskop.exe assuming that your screen resolution is 1280X1024 :


--- Code: ---SaveDesktop 0 0 1280 1024 Desktop.bmp
--- End code ---

The righ lower quarter of the desktop :


--- Code: ---SaveDesktop 640 512 640 512 Desktop2.bmp
--- End code ---

shankle:
Thank you Vortex.
Makes one wonder how all these 3rd parties get the portion of the screen that is asked for.
I thought there was an API to handle it.

I need a small portion of the screen in the middle of the screen.
Not having played with your example yet, I don't see how it would address a rectangle at
500x and 600y  by 560x and 650y.
 

Vortex:
Hi shankle,

Assuming that :


--- Code: ---x-coordinate, in logical units, of the upper-left corner = 500
y-coordinate, in logical units, of the upper-left corner = 600
width, in logical units, of the rectange to capture      = 560
height, in logical units, of the rectange to capture     = 650
--- End code ---

The command-line should be :


--- Code: ---SaveDesktop.exe 500 600 560 650 Desktop.bmp
--- End code ---

fearless:
In relation to this topic, anyone know how to have a rectangle drawn around an external window that you want to capture - similar to a lot of spy++, WinID, Inspect tools, that show the window region with a red rectangle for the window that the tool is interested in?

Navigation

[0] Message Index

[#] Next page

Go to full version