Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/atotto/xwd
xwd image for golang
https://github.com/atotto/xwd
golang xwd
Last synced: 24 days ago
JSON representation
xwd image for golang
- Host: GitHub
- URL: https://github.com/atotto/xwd
- Owner: atotto
- License: mit
- Created: 2020-12-25T14:59:09.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2021-01-12T23:29:28.000Z (almost 4 years ago)
- Last Synced: 2024-06-20T11:11:12.841Z (5 months ago)
- Topics: golang, xwd
- Language: Go
- Homepage:
- Size: 3.91 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# xwd image library for golang
example:
```go
func main() {
f, err := os.Create("screenshot.png")
if err != nil {
log.Fatal(err)
}
defer f.Close()ctx := context.Background()
m, err := xwd.Capture(ctx)
if err != nil {
log.Fatal(err)
}
if err := png.Encode(f, m); err != nil {
log.Fatal(err)
}
}
``````go
// $ xwd -root -display :0 -out screenshot.xwd
func xwd2png(w io.Writer, r io.Reader) error {
m, err := xwd.Decode(r)
if err != nil {
return err
}
if err := png.Encode(w, m); err != nil {
return err
}
return nil
}
```