forked from joejulian/gio
app/headless: handle error from Framebuffer.ReadPixels
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -116,12 +116,15 @@ func (w *Window) Frame(frame *op.Ops) {
|
||||
// Screenshot returns an image with the content of the window.
|
||||
func (w *Window) Screenshot() (*image.RGBA, error) {
|
||||
img := image.NewRGBA(image.Rectangle{Max: w.size})
|
||||
contextDo(w.ctx, func() error {
|
||||
err := contextDo(w.ctx, func() error {
|
||||
return w.fbo.ReadPixels(
|
||||
image.Rectangle{
|
||||
Max: image.Point{X: w.size.X, Y: w.size.Y},
|
||||
}, img.Pix)
|
||||
})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
// Flip image in y-direction. OpenGL's origin is in the lower
|
||||
// left corner.
|
||||
row := make([]uint8, img.Stride)
|
||||
|
||||
Reference in New Issue
Block a user