mirror of
https://github.com/hajimehoshi/ebiten.git
synced 2025-01-12 20:18:59 +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
|
package graphicscommand
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bufio"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"image"
|
"image"
|
||||||
@ -42,7 +43,11 @@ func (i *Image) Dump(graphicsDriver graphicsdriver.Graphics, path string, blackb
|
|||||||
_ = f.Close()
|
_ = 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
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -77,7 +82,11 @@ func DumpImages(images []*Image, graphicsDriver graphicsdriver.Graphics, dir str
|
|||||||
_ = f.Close()
|
_ = 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
|
return "", err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user