Use blake2b instead of sha1 to check for identical tiles to not regenerate the tiles pyramid.

This commit is contained in:
Sascha L. Teichmann 2017-02-26 21:47:50 +01:00
parent 540836b174
commit 12cfd32ad5
2 changed files with 5 additions and 4 deletions

View File

@ -172,7 +172,7 @@ func (btc *BaseTileCreator) CreateTile(x, z int16, i, j int) (bool, error) {
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)
return true, SaveAsPNGAtomic(path, image)
}

View File

@ -7,7 +7,6 @@ package common
import (
"bufio"
"bytes"
"crypto/sha1"
"errors"
"image"
"image/color"
@ -18,6 +17,8 @@ import (
"sync"
"time"
"golang.org/x/crypto/blake2b"
"github.com/bamiaux/rez"
)
@ -112,9 +113,9 @@ func LoadPNG(path string, bg color.RGBA) image.Image {
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()
pos := img.PixOffset(img.Rect.Min.X, img.Rect.Min.Y)