mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2024-12-24 18:58:54 +01:00
internal/graphicscommand: use bufio to make dumping images faster
This commit is contained in:
parent
fd5e2d39c0
commit
b29fc5672c
@ -17,6 +17,7 @@
|
||||
package graphicscommand
|
||||
|
||||
import (
|
||||
"bufio"
|
||||
"errors"
|
||||
"fmt"
|
||||
"image"
|
||||
@ -42,7 +43,11 @@ func (i *Image) Dump(graphicsDriver graphicsdriver.Graphics, path string, blackb
|
||||
_ = f.Close()
|
||||
}()
|
||||
|
||||
if err := i.dumpTo(f, graphicsDriver, blackbg, rect); err != nil {
|
||||
w := bufio.NewWriter(f)
|
||||
if err := i.dumpTo(w, graphicsDriver, blackbg, rect); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := w.Flush(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
@ -77,7 +82,11 @@ func DumpImages(images []*Image, graphicsDriver graphicsdriver.Graphics, dir str
|
||||
_ = f.Close()
|
||||
}()
|
||||
|
||||
if err := img.dumpTo(f, graphicsDriver, false, image.Rect(0, 0, img.width, img.height)); err != nil {
|
||||
w := bufio.NewWriter(f)
|
||||
if err := img.dumpTo(w, graphicsDriver, false, image.Rect(0, 0, img.width, img.height)); err != nil {
|
||||
return "", err
|
||||
}
|
||||
if err := w.Flush(); err != nil {
|
||||
return "", err
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user