internal/graphicscommand: bug fix: 0-sized image was included in dumped internal images

Updates #2270
This commit is contained in:
Hajime Hoshi 2022-08-31 12:22:28 +09:00
parent b53c686017
commit d66c552912
2 changed files with 7 additions and 2 deletions

View File

@ -15,6 +15,7 @@
package graphicscommand
import (
"fmt"
"image"
"io"
"sort"
@ -204,9 +205,8 @@ func (i *Image) dumpName(path string) string {
//
// This is for testing usage.
func (i *Image) dumpTo(w io.Writer, graphicsDriver graphicsdriver.Graphics, blackbg bool, rect image.Rectangle) error {
// Screen image cannot be dumped.
if i.screen {
return nil
return fmt.Errorf("graphicscommand: a screen image cannot be dumped")
}
pix := make([]byte, 4*i.width*i.height)

View File

@ -63,6 +63,11 @@ func DumpImages(images []*Image, graphicsDriver graphicsdriver.Graphics, dir str
zw := zip.NewWriter(buf)
for _, img := range images {
// Screen image cannot be dumped.
if img.screen {
continue
}
f, err := zw.Create(img.dumpName("*.png"))
if err != nil {
return err