diff --git a/internal/atlas/image.go b/internal/atlas/image.go index 51d901ae9..9a874b8af 100644 --- a/internal/atlas/image.go +++ b/internal/atlas/image.go @@ -564,12 +564,7 @@ func (i *Image) ReadPixels(graphicsDriver graphicsdriver.Graphics, pixels []byte return true, nil } - if err := i.backend.restorable.Image.ReadPixels(graphicsDriver, []graphicsdriver.PixelsArgs{ - { - Pixels: pixels, - Region: region.Add(i.regionWithPadding().Min), - }, - }); err != nil { + if err := i.backend.restorable.ReadPixels(graphicsDriver, pixels, region.Add(i.regionWithPadding().Min)); err != nil { return false, err } return true, nil diff --git a/internal/restorable/image.go b/internal/restorable/image.go index 0ce4d25c1..34643661c 100644 --- a/internal/restorable/image.go +++ b/internal/restorable/image.go @@ -136,3 +136,15 @@ func (i *Image) DrawTriangles(srcs [graphics.ShaderSrcImageCount]*Image, vertice } i.Image.DrawTriangles(imgs, vertices, indices, blend, dstRegion, srcRegions, shader.shader, uniforms, fillRule) } + +func (i *Image) ReadPixels(graphicsDriver graphicsdriver.Graphics, pixels []byte, region image.Rectangle) error { + if err := i.Image.ReadPixels(graphicsDriver, []graphicsdriver.PixelsArgs{ + { + Pixels: pixels, + Region: region, + }, + }); err != nil { + return err + } + return nil +}