mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-06 18:05:35 +00:00
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.
|
// Screenshot returns an image with the content of the window.
|
||||||
func (w *Window) Screenshot() (*image.RGBA, error) {
|
func (w *Window) Screenshot() (*image.RGBA, error) {
|
||||||
img := image.NewRGBA(image.Rectangle{Max: w.size})
|
img := image.NewRGBA(image.Rectangle{Max: w.size})
|
||||||
contextDo(w.ctx, func() error {
|
err := contextDo(w.ctx, func() error {
|
||||||
return w.fbo.ReadPixels(
|
return w.fbo.ReadPixels(
|
||||||
image.Rectangle{
|
image.Rectangle{
|
||||||
Max: image.Point{X: w.size.X, Y: w.size.Y},
|
Max: image.Point{X: w.size.X, Y: w.size.Y},
|
||||||
}, img.Pix)
|
}, img.Pix)
|
||||||
})
|
})
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
// Flip image in y-direction. OpenGL's origin is in the lower
|
// Flip image in y-direction. OpenGL's origin is in the lower
|
||||||
// left corner.
|
// left corner.
|
||||||
row := make([]uint8, img.Stride)
|
row := make([]uint8, img.Stride)
|
||||||
|
|||||||
Reference in New Issue
Block a user