mirror of
https://bitbucket.org/s_l_teichmann/mtsatellite
synced 2025-02-08 22:00:21 +01:00
Use blake2b instead of sha1 to check for identical tiles to not regenerate the tiles pyramid.
This commit is contained in:
parent
540836b174
commit
12cfd32ad5
@ -172,7 +172,7 @@ func (btc *BaseTileCreator) CreateTile(x, z int16, i, j int) (bool, error) {
|
|||||||
return true, SaveAsPNG(path, image)
|
return true, SaveAsPNG(path, image)
|
||||||
}
|
}
|
||||||
|
|
||||||
if btc.update(i, j, SHA1Image(image)) {
|
if btc.update(i, j, HashImage(image)) {
|
||||||
log.Printf("Writing (%d, %d) to file %s.\n", x, z, path)
|
log.Printf("Writing (%d, %d) to file %s.\n", x, z, path)
|
||||||
return true, SaveAsPNGAtomic(path, image)
|
return true, SaveAsPNGAtomic(path, image)
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,6 @@ package common
|
|||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"crypto/sha1"
|
|
||||||
"errors"
|
"errors"
|
||||||
"image"
|
"image"
|
||||||
"image/color"
|
"image/color"
|
||||||
@ -18,6 +17,8 @@ import (
|
|||||||
"sync"
|
"sync"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
"golang.org/x/crypto/blake2b"
|
||||||
|
|
||||||
"github.com/bamiaux/rez"
|
"github.com/bamiaux/rez"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -112,9 +113,9 @@ func LoadPNG(path string, bg color.RGBA) image.Image {
|
|||||||
return img
|
return img
|
||||||
}
|
}
|
||||||
|
|
||||||
func SHA1Image(img *image.RGBA) []byte {
|
func HashImage(img *image.RGBA) []byte {
|
||||||
|
|
||||||
hash := sha1.New()
|
hash, _ := blake2b.New256(nil)
|
||||||
w, h := img.Rect.Dx()*4, img.Rect.Dy()
|
w, h := img.Rect.Dx()*4, img.Rect.Dy()
|
||||||
|
|
||||||
pos := img.PixOffset(img.Rect.Min.X, img.Rect.Min.Y)
|
pos := img.PixOffset(img.Rect.Min.X, img.Rect.Min.Y)
|
||||||
|
Loading…
Reference in New Issue
Block a user