Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ximg doesn't get saved with SavePng. #36

Open
CamilleScholtz opened this issue Jan 25, 2017 · 6 comments
Open

ximg doesn't get saved with SavePng. #36

CamilleScholtz opened this issue Jan 25, 2017 · 6 comments

Comments

@CamilleScholtz
Copy link

CamilleScholtz commented Jan 25, 2017

Reproduce

Expected result

A window that pops up with the contents of the screenshot and a png gets written to disk with the contents of the screenshot.

Actual result

A window that pops up with the contents of the screenshot and blank png gets written to disk (https://punpun.xyz/hqgz.png)

@ghost
Copy link

ghost commented Jan 27, 2017

You can either show or save, not both at the same time, I think

@CamilleScholtz
Copy link
Author

CamilleScholtz commented Jan 27, 2017

Nope, commenting out the XShowExtra line doesn't fix it. I don't know I am somehow missing a dependency or something, or if this is an actual problem with xgbutil.

@ghost
Copy link

ghost commented Jan 27, 2017

Also comment out the last line, xevent.Main(x), otherwise the process hangs. if that doesn't work I can't help, it works fine on my system

@ghost
Copy link

ghost commented Jan 27, 2017

here's the full snippet

// Example screenshot shows how to take a screenshot of the current desktop
// and show it in a window. In a comment, it also shows how to save it as
// a png.
//
// It works by getting the image of the root window, which automatically
// includes all child windows.
package main

import (
	"log"

	"github.com/BurntSushi/xgb/xproto"

	"github.com/BurntSushi/xgbutil"
	"github.com/BurntSushi/xgbutil/xgraphics"
)

func main() {
	X, err := xgbutil.NewConn()
	if err != nil {
		log.Fatal(err)
	}

	// Use the "NewDrawable" constructor to create an xgraphics.Image value
	// from a drawable. (Usually this is done with pixmaps, but drawables
	// can also be windows.)
	ximg, err := xgraphics.NewDrawable(X, xproto.Drawable(X.RootWin()))
	if err != nil {
		log.Fatal(err)
	}

	// Shows the screenshot in a window.
	//ximg.XShowExtra("Screenshot", true)

	// If you'd like to save it as a png, use:
	err = ximg.SavePng("screenshot.png")
	if err != nil {
		log.Fatal(err)
	}

	//xevent.Main(X)
}

@CamilleScholtz
Copy link
Author

Yup, that's exactly what I tried, and yet it still produced a blank png image (that does have the right size though). The method you use in burdet does work, so I'm not sure what's going wrong here.

@alex3d
Copy link

alex3d commented Jul 22, 2024

This issue should be fixed by this PR jezek#6

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants