-
Notifications
You must be signed in to change notification settings - Fork 899
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #559 from go-vgo/bitmap-pr
Add: add more capture screens hot support and fixed bug
- Loading branch information
Showing
5 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
// Copyright 2016 The go-vgo Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// https://github.com/go-vgo/robotgo/blob/master/LICENSE | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
package robotgo | ||
|
||
import ( | ||
"image" | ||
|
||
"github.com/kbinani/screenshot" | ||
) | ||
|
||
// GetScreenBound gets the display screen bounds | ||
func GetDisplayBounds(i int) (x, y, w, h int) { | ||
bs := screenshot.GetDisplayBounds(i) | ||
return bs.Min.X, bs.Min.Y, bs.Dx(), bs.Dy() | ||
} | ||
|
||
// GetDisplayBounds gets the display rect | ||
func GetDisplayRect(i int) Rect { | ||
x, y, w, h := GetDisplayBounds(i) | ||
return Rect{ | ||
Point{X: x, Y: y}, | ||
Size{W: w, H: h}} | ||
} | ||
|
||
// Capture capture the screenshot | ||
func Capture(args ...int) (*image.RGBA, error) { | ||
displayId := 0 | ||
if DisplayID != -1 { | ||
displayId = DisplayID | ||
} | ||
|
||
if len(args) > 4 { | ||
displayId = args[4] | ||
} | ||
|
||
var x, y, w, h int | ||
if len(args) > 3 { | ||
x, y, w, h = args[0], args[1], args[2], args[3] | ||
} else { | ||
x, y, w, h = GetDisplayBounds(displayId) | ||
} | ||
|
||
return screenshot.Capture(x, y, w, h) | ||
} |