开发者

Confused with CopyFromScreen signiture

I am trying to capture a screenshot using CopyFromScreen. However 开发者_如何学Gomethod signature is a bit confusing for me.

It looks like this:

public void CopyFromScreen(
    Point upperLeftSource,
    Point upperLeftDestination,
    Size blockRegionSize
)

Why there are 3 parameters instead of 2? And why there are both upperLeftCorner. In my understanding you can describe a square area on a surface using two points (upper left corner and bottom right corner). This could describe area of any size and in any position.

So the question is: how do I use this method to capture an area denoted: (X0,Y0) (X1,Y1)?


upperLeftDestination is the point in your new image where you want to place the image you have copied.

To copy a 50x50 square from the screen starting at the top left of the screen:

graphics.CopyFromScreen(new Point(0,0), new Point(0, 0), new Size(50, 50));

To copy a 50x50 square from the screen starting at (100, 100):

graphics.CopyFromScreen(new Point(100, 100), new Point(0, 0), new Size(50, 50));

To copy a 50x50 square from the top left of the screen into, say, a 60x60 image and give it an even border of 5px on all sides you'd do:

graphics.CopyFromScreen(new Point(0, 0), new Point(5, 5), new Size(50, 50));


The upperLeftDestination parameter tells it where in your image to draw the copy.
You probably want that to be 0, 0.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜