The first number is the count of modules that contain a package that imports this one.
The module count is a better indicator of popularity than the package count.
A module with 100 importing packages is counted only once instead of 100 times,
reflecting the fact that the choice to use the package was likely made only once,
not 100 times.
A '?' means that the value hasn't been computed yet.
package main
import (
"fmt"
"image"
"image/png"
"os"
"github.com/vcaesar/screenshot"
)
// save *image.RGBA to filePath with PNG format.
func save(img *image.RGBA, filePath string) {
file, err := os.Create(filePath)
if err != nil {
panic(err)
}
defer file.Close()
err = png.Encode(file, img)
if err != nil {
panic(err)
}
}
func main() {
// Capture each displays.
n := screenshot.NumActiveDisplays()
if n <= 0 {
panic("Active display not found")
}
var all image.Rectangle = image.Rect(0, 0, 0, 0)
for i := 0; i < n; i++ {
bounds := screenshot.GetDisplayBounds(i)
all = bounds.Union(all)
img, err := screenshot.CaptureRect(bounds)
if err != nil {
panic(err)
}
fileName := fmt.Sprintf("%d_%dx%d.png", i, bounds.Dx(), bounds.Dy())
save(img, fileName)
fmt.Printf("#%d : %v \"%s\"\n", i, bounds, fileName)
}
// Capture all desktop region into an image.
fmt.Printf("%v\n", all)
img, err := screenshot.Capture(all.Min.X, all.Min.Y, all.Dx(), all.Dy())
if err != nil {
panic(err)
}
save(img, "all.png")
}
output example
$ go run main.go
#0 : (0,0)-(1280,800) "0_1280x800.png"
#1 : (-293,-1440)-(2267,0) "1_2560x1440.png"
#2 : (-1373,-1812)-(-293,108) "2_1080x1920.png"
(-1373,-1812)-(2267,800)
$ ls -1
0_1280x800.png
1_2560x1440.png
2_1080x1920.png
all.png
main.go
coordinate
Y-axis is downward direction in this library. The origin of coordinate is upper-left corner of main display. This means coordinate system is similar to Windows OS
var ErrUnsupported = errors.New("screenshot does not support your platform")
ErrUnsupported is returned when the platform or architecture used to compile the program
does not support screenshot, e.g. if you're compiling without CGO on Darwin
Capture returns screen capture of specified desktop region.
x and y represent distance from the upper-left corner of primary display.
Y-axis is downward direction. This means coordinates system is similar to Windows OS.