add image capturing for linux
This commit is contained in:
@@ -4,10 +4,18 @@ package capture
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"image"
|
"image"
|
||||||
|
|
||||||
|
"github.com/kbinani/screenshot"
|
||||||
)
|
)
|
||||||
|
|
||||||
var activeDisplays = func() int { return 0 }
|
var activeDisplays = func() int {
|
||||||
|
return screenshot.NumActiveDisplays()
|
||||||
|
}
|
||||||
|
|
||||||
var captureDisplayFn = func(int) (*image.RGBA, error) { return nil, nil }
|
var captureDisplayFn = func(display int) (*image.RGBA, error) {
|
||||||
|
return screenshot.CaptureDisplay(display)
|
||||||
|
}
|
||||||
|
|
||||||
func displayCount() int { return 0 }
|
func displayCount() int {
|
||||||
|
return screenshot.NumActiveDisplays()
|
||||||
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
//go:build linux
|
||||||
|
|
||||||
|
package capture
|
||||||
|
|
||||||
|
import (
|
||||||
|
"image"
|
||||||
|
|
||||||
|
"github.com/kbinani/screenshot"
|
||||||
|
)
|
||||||
|
|
||||||
|
func displayBounds(idx int) image.Rectangle {
|
||||||
|
return screenshot.GetDisplayBounds(idx)
|
||||||
|
}
|
||||||
|
|
||||||
|
func displayScale(idx int) float64 {
|
||||||
|
return 1.0
|
||||||
|
}
|
||||||
|
|
||||||
|
func MonitorInfos() []MonitorInfo {
|
||||||
|
n := screenshot.NumActiveDisplays()
|
||||||
|
infos := make([]MonitorInfo, 0, n)
|
||||||
|
for i := 0; i < n; i++ {
|
||||||
|
b := screenshot.GetDisplayBounds(i)
|
||||||
|
infos = append(infos, MonitorInfo{
|
||||||
|
Width: b.Dx(),
|
||||||
|
Height: b.Dy(),
|
||||||
|
})
|
||||||
|
}
|
||||||
|
return infos
|
||||||
|
}
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
//go:build !windows
|
//go:build !windows && !linux
|
||||||
|
|
||||||
package capture
|
package capture
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user